Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Let a test run require the tools it must not skip
Nothing could make a missing prerequisite fail. A host without
pkg-config builds without Lua, and make test then passed with every
Lua test skipped and the lua pass of t0201 never run. The whole-script
skips become named prerequisites so the same list covers them, and the
strace probe now traces the file class of calls the tests use, so an
strace too old for it skips rather than fails.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/setup.sh | 7 | |
| -rwxr-xr-x | tests/t0002-html-validity.sh | 26 | |
| -rwxr-xr-x | tests/t0006-nolua.sh | 4 | |
| -rwxr-xr-x | tests/t0302-home-access.sh | 16 | |
| -rwxr-xr-x | tests/t0401-serve.sh | 9 |
5 files changed, 39 insertions, 23 deletions
diff --git a/tests/setup.sh b/tests/setup.sh index 68b7a5b..c61fa85 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -145,6 +145,13 @@ then fi unset cgit_version cgit_flags +# A run that has to cover everything names the prerequisites it cannot go +# without in CGIT_TEST_REQUIRE, and the library then stops a script that finds +# one missing rather than skip the tests that need it. Lua is asked about at +# once, as a few scripts leave whole tests out when cgit has none. +GIT_TEST_REQUIRE_PREREQ="$GIT_TEST_REQUIRE_PREREQ $CGIT_TEST_REQUIRE" +test_have_prereq CGIT_LUA || : + # Creates a repository holding the given number of one file commits. A third # argument asks for a variant, either testplus for a file and a branch whose # names have to be escaped in a URL, or commit-graph for a written commit graph. diff --git a/tests/t0002-html-validity.sh b/tests/t0002-html-validity.sh index bdccaf2..a4a6725 100755 --- a/tests/t0002-html-validity.sh +++ b/tests/t0002-html-validity.sh @@ -17,22 +17,24 @@ test_url() { strip_headers <tidy-$test_count.tmp >tidy-$test_count || return # Tidy leaves with 1 for warnings and 2 for errors, and only an error is # worth failing the test over. - "$tidy" -eq tidy-$test_count + tidy -eq tidy-$test_count test $? != 2 } -tidy=$(command -v tidy) || { - skip_all='Skipping html validation tests: tidy not found' - test_done -} - # Releases of tidy that predate HTML5 reject the semantic elements cgit emits, -# header, nav, main and footer among them, reporting each as an error. Skip the -# validation unless tidy is new enough to understand them. -printf '<!DOCTYPE html>\n<html lang="en"><head><title>t</title></head><body><header>x</header></body></html>\n' \ - | "$tidy" -q -e >/dev/null 2>&1 -test $? -ge 2 && { - skip_all='Skipping html validation tests: tidy is too old for HTML5' +# header, nav, main and footer among them, reporting each as an error, so only +# a tidy new enough to understand them will do. +test_lazy_prereq TIDY ' + cat >probe.html <<-\EOF && + <!DOCTYPE html> + <html lang="en"><head><title>t</title></head><body><header>x</header></body></html> + EOF + tidy -q -e probe.html >/dev/null 2>&1 + test $? -lt 2 +' + +test_have_prereq TIDY || { + skip_all='Skipping html validation tests: no tidy that knows HTML5' test_done } diff --git a/tests/t0006-nolua.sh b/tests/t0006-nolua.sh index cd35fca..f68e731 100755 --- a/tests/t0006-nolua.sh +++ b/tests/t0006-nolua.sh @@ -10,7 +10,9 @@ test_description='Check the build without Lua' . ./setup.sh nolua="$TEST_OUTPUT_DIRECTORY/../build/nolua/cgit" -test -x "$nolua" || { +test_lazy_prereq CGIT_NOLUA 'test -x "$nolua"' + +test_have_prereq CGIT_NOLUA || { skip_all='Skipping the Lua-less checks: build/nolua/cgit is missing, run make test' test_done } diff --git a/tests/t0302-home-access.sh b/tests/t0302-home-access.sh index 6447927..0c0fcd2 100755 --- a/tests/t0302-home-access.sh +++ b/tests/t0302-home-access.sh @@ -11,14 +11,14 @@ test_description='Ensure that git does not access $HOME' . ./setup.sh # strace needs ptrace, which a system can refuse even where the binary is -# installed, so a working run is checked as well as a present binary. -command -v strace >/dev/null 2>&1 || { - skip_all='Skipping access validation tests: strace not found' - test_done -} - -strace true 2>/dev/null || { - skip_all='Skipping access validation tests: strace not functional' +# installed, and a release that knows the file class of calls, so the probe +# traces that class. +test_lazy_prereq STRACE ' + strace -o /dev/null -e trace=%file true +' + +test_have_prereq STRACE || { + skip_all='Skipping access validation tests: no strace that can trace here' test_done } diff --git a/tests/t0401-serve.sh b/tests/t0401-serve.sh index 341bbb6..4a2d08b 100755 --- a/tests/t0401-serve.sh +++ b/tests/t0401-serve.sh @@ -9,8 +9,13 @@ test_description='Check the preview server splits CGI output correctly' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh -command -v python3 >/dev/null 2>&1 || { - skip_all='Skipping preview server tests: python3 not found' +# serve.py uses syntax that came with Python 3.8. +test_lazy_prereq PYTHON ' + python3 -c "import sys; sys.exit(sys.version_info < (3, 8))" +' + +test_have_prereq PYTHON || { + skip_all='Skipping preview server tests: no python3 3.8 or later' test_done } |
