mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:39:42 +00:00
Merge pull request #245 from JackPhallen/chore/skip-tests-requiring-timeout
chore: Skip tests that require timeout
This commit is contained in:
@@ -137,6 +137,10 @@ setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "clean_project_caches handles timeout gracefully" {
|
@test "clean_project_caches handles timeout gracefully" {
|
||||||
|
if ! command -v gtimeout >/dev/null 2>&1 && ! command -v timeout >/dev/null 2>&1; then
|
||||||
|
skip "gtimeout/timeout not available"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$HOME/test-project/.next"
|
mkdir -p "$HOME/test-project/.next"
|
||||||
|
|
||||||
function find() {
|
function find() {
|
||||||
@@ -145,7 +149,10 @@ setup() {
|
|||||||
}
|
}
|
||||||
export -f find
|
export -f find
|
||||||
|
|
||||||
run timeout 15 bash -c "
|
timeout_cmd="timeout"
|
||||||
|
command -v timeout >/dev/null 2>&1 || timeout_cmd="gtimeout"
|
||||||
|
|
||||||
|
run $timeout_cmd 15 bash -c "
|
||||||
source '$PROJECT_ROOT/lib/core/common.sh'
|
source '$PROJECT_ROOT/lib/core/common.sh'
|
||||||
source '$PROJECT_ROOT/lib/clean/caches.sh'
|
source '$PROJECT_ROOT/lib/clean/caches.sh'
|
||||||
clean_project_caches
|
clean_project_caches
|
||||||
|
|||||||
@@ -483,14 +483,21 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "clean_project_artifacts: scans and finds artifacts" {
|
@test "clean_project_artifacts: scans and finds artifacts" {
|
||||||
|
if ! command -v gtimeout >/dev/null 2>&1 && ! command -v timeout >/dev/null 2>&1; then
|
||||||
|
skip "gtimeout/timeout not available"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$HOME/www/test-project/node_modules/package1"
|
mkdir -p "$HOME/www/test-project/node_modules/package1"
|
||||||
echo "test data" > "$HOME/www/test-project/node_modules/package1/index.js"
|
echo "test data" > "$HOME/www/test-project/node_modules/package1/index.js"
|
||||||
|
|
||||||
mkdir -p "$HOME/www/test-project"
|
mkdir -p "$HOME/www/test-project"
|
||||||
|
|
||||||
|
timeout_cmd="timeout"
|
||||||
|
command -v timeout >/dev/null 2>&1 || timeout_cmd="gtimeout"
|
||||||
|
|
||||||
run bash -c "
|
run bash -c "
|
||||||
export HOME='$HOME'
|
export HOME='$HOME'
|
||||||
timeout 5 '$PROJECT_ROOT/bin/purge.sh' 2>&1 < /dev/null || true
|
$timeout_cmd 5 '$PROJECT_ROOT/bin/purge.sh' 2>&1 < /dev/null || true
|
||||||
"
|
"
|
||||||
|
|
||||||
[[ "$output" =~ "Scanning" ]] ||
|
[[ "$output" =~ "Scanning" ]] ||
|
||||||
@@ -511,17 +518,31 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "mo purge: accepts --debug flag" {
|
@test "mo purge: accepts --debug flag" {
|
||||||
|
if ! command -v gtimeout >/dev/null 2>&1 && ! command -v timeout >/dev/null 2>&1; then
|
||||||
|
skip "gtimeout/timeout not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
timeout_cmd="timeout"
|
||||||
|
command -v timeout >/dev/null 2>&1 || timeout_cmd="gtimeout"
|
||||||
|
|
||||||
run bash -c "
|
run bash -c "
|
||||||
export HOME='$HOME'
|
export HOME='$HOME'
|
||||||
timeout 2 '$PROJECT_ROOT/mole' purge --debug < /dev/null 2>&1 || true
|
$timeout_cmd 2 '$PROJECT_ROOT/mole' purge --debug < /dev/null 2>&1 || true
|
||||||
"
|
"
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "mo purge: creates cache directory for stats" {
|
@test "mo purge: creates cache directory for stats" {
|
||||||
|
if ! command -v gtimeout >/dev/null 2>&1 && ! command -v timeout >/dev/null 2>&1; then
|
||||||
|
skip "gtimeout/timeout not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
timeout_cmd="timeout"
|
||||||
|
command -v timeout >/dev/null 2>&1 || timeout_cmd="gtimeout"
|
||||||
|
|
||||||
bash -c "
|
bash -c "
|
||||||
export HOME='$HOME'
|
export HOME='$HOME'
|
||||||
timeout 2 '$PROJECT_ROOT/mole' purge < /dev/null 2>&1 || true
|
$timeout_cmd 2 '$PROJECT_ROOT/mole' purge < /dev/null 2>&1 || true
|
||||||
"
|
"
|
||||||
|
|
||||||
[ -d "$HOME/.cache/mole" ] || [ -d "${XDG_CACHE_HOME:-$HOME/.cache}/mole" ]
|
[ -d "$HOME/.cache/mole" ] || [ -d "${XDG_CACHE_HOME:-$HOME/.cache}/mole" ]
|
||||||
|
|||||||
@@ -81,8 +81,15 @@ setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "network timeout prevents hanging (simulated)" {
|
@test "network timeout prevents hanging (simulated)" {
|
||||||
|
if ! command -v gtimeout >/dev/null 2>&1 && ! command -v timeout >/dev/null 2>&1; then
|
||||||
|
skip "gtimeout/timeout not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
timeout_cmd="timeout"
|
||||||
|
command -v timeout >/dev/null 2>&1 || timeout_cmd="gtimeout"
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
result=$(timeout 5 bash -c '
|
result=$($timeout_cmd 5 bash -c '
|
||||||
result=$(curl -fsSL --connect-timeout 1 --max-time 2 "http://192.0.2.1:12345/test" 2>/dev/null || echo "failed")
|
result=$(curl -fsSL --connect-timeout 1 --max-time 2 "http://192.0.2.1:12345/test" 2>/dev/null || echo "failed")
|
||||||
if [[ "$result" == "failed" ]]; then
|
if [[ "$result" == "failed" ]]; then
|
||||||
echo "timeout_works"
|
echo "timeout_works"
|
||||||
|
|||||||
Reference in New Issue
Block a user