Add pexpect tests to new test driver

This commit is contained in:
Mahmoud Al-Qudsi 2021-03-18 13:23:31 -05:00 committed by Johannes Altmanninger
parent aaac759d9a
commit 2962fbcf7a
2 changed files with 23 additions and 17 deletions

View file

@ -135,3 +135,14 @@ foreach(CHECK ${FISH_CHECKS})
) )
add_test_target("${CHECK_NAME}") add_test_target("${CHECK_NAME}")
endforeach(CHECK) endforeach(CHECK)
FILE(GLOB PEXPECTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/pexpects/*.py)
foreach(PEXPECT ${PEXPECTS})
get_filename_component(PEXPECT ${PEXPECT} NAME)
add_test(NAME ${PEXPECT}
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
${CMAKE_CURRENT_BINARY_DIR}/tests/interactive.fish ${PEXPECT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
)
add_test_target("${PEXPECT}")
endforeach(PEXPECT)

View file

@ -1,8 +1,6 @@
# Interactive tests using `expect` #! /bin/echo "interactive.fish must be run via the test driver!"
# #
# There is no shebang line because you shouldn't be running this by hand. You # Interactive tests using `pexpect`
# should be running it via `make test` to ensure the environment is properly
# setup.
# Set this var to modify behavior of the code being tests. Such as avoiding running # Set this var to modify behavior of the code being tests. Such as avoiding running
# `fish_update_completions` when running tests. # `fish_update_completions` when running tests.
@ -11,29 +9,22 @@ set -gx FISH_UNIT_TESTS_RUNNING 1
# Change to directory containing this script # Change to directory containing this script
cd (status dirname) cd (status dirname)
# These env vars should not be inherited from the user environment because they can affect the
# behavior of the tests. So either remove them or set them to a known value.
# See also tests/test.fish.
set -gx TERM xterm
set -e ITERM_PROFILE
# Test files specified on commandline, or all pexpect files. # Test files specified on commandline, or all pexpect files.
if set -q argv[1] if set -q argv[1] && test -n "$argv[1]"
set pexpect_files_to_test pexpects/$argv.py set pexpect_files_to_test pexpects/$argv
else if set -q FISH_PEXPECT_FILES else if set -q FISH_PEXPECT_FILES
set pexpect_files_to_test (string replace -r '^.*/(?=pexpects/)' '' -- $FISH_PEXPECT_FILES) set pexpect_files_to_test (string replace -r '^.*/(?=pexpects/)' '' -- $FISH_PEXPECT_FILES)
else else
say -o cyan "Testing interactive functionality"
set pexpect_files_to_test pexpects/*.py set pexpect_files_to_test pexpects/*.py
end end
source test_util.fish (status -f) $argv source test_util.fish || exit
or exit
cat interactive.config >>$XDG_CONFIG_HOME/fish/config.fish cat interactive.config >>$XDG_CONFIG_HOME/fish/config.fish
say -o cyan "Testing interactive functionality"
function test_pexpect_file function test_pexpect_file
set -l file $argv[1] set -l file $argv[1]
echo -n "Testing file $file ... " echo -n "Testing file $file:"
begin begin
set starttime (timestamp) set starttime (timestamp)
@ -77,7 +68,11 @@ end
set failed (count $failed) set failed (count $failed)
if test $failed -eq 0 if test $failed -eq 0
say green "All interactive tests completed successfully" if test (count $pexpect_files_to_test) -gt 1
say green "All interactive tests completed successfully"
else
say green "$pexpect_files_to_test completed successfully"
end
exit 0 exit 0
else else
set plural (test $failed -eq 1; or echo s) set plural (test $failed -eq 1; or echo s)