Diff options
Diffstat (limited to 'tests/t0401-serve.sh')
| -rwxr-xr-x | tests/t0401-serve.sh | 34 |
1 file changed, 31 insertions, 3 deletions
diff --git a/tests/t0401-serve.sh b/tests/t0401-serve.sh index 4a2d08b..ca15e1c 100755 --- a/tests/t0401-serve.sh +++ b/tests/t0401-serve.sh @@ -9,9 +9,16 @@ test_description='Check the preview server splits CGI output correctly' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh +# A version manager's shim may find its interpreters through HOME, which the +# library has moved into the trash directory, so the interpreter is looked up +# once under the account's own. -I keeps the user's site packages and PYTHON +# variables out of the checks. +PYTHON=$(HOME=$USER_HOME python3 -I -c 'import sys; print(sys.executable)' 2>/dev/null) + # 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 -n "$PYTHON" && + "$PYTHON" -I -c "import sys; sys.exit(sys.version_info < (3, 8))" ' test_have_prereq PYTHON || { @@ -19,8 +26,29 @@ test_have_prereq PYTHON || { test_done } -test_expect_success 'CGI headers and body are split at the first blank line' ' - python3 "$TEST_OUTPUT_DIRECTORY/serve-split-check.py" "$TEST_OUTPUT_DIRECTORY/.." +split_check() { + "$PYTHON" -I "$TEST_OUTPUT_DIRECTORY/serve-split-check.py" \ + "$TEST_OUTPUT_DIRECTORY/.." "$1" +} + +test_expect_success 'a CRLF blank line in the body stays in the body' ' + split_check crlf-in-body +' + +test_expect_success 'an LF blank line after CRLF headers stays in the body' ' + split_check lf-in-body +' + +test_expect_success 'a status line is taken off the headers' ' + split_check status +' + +test_expect_success 'an empty body survives, as a redirect leaves one' ' + split_check empty-body +' + +test_expect_success 'output with no blank line at all is all headers' ' + split_check no-blank-line ' test_done |
