Blog: 2023-08-24
Jump to navigation
Jump to search
Trying to figure out how to run single test in fish
Makefile:
.PHONY: test test: build/fish $(CMAKE) --build build --target test
Tests.cmake:
# CMake being CMake, you can't just add a DEPENDS argument to add_test to make it depend on any of # your binaries actually being built before `make test` is executed (requiring `make all` first), # and the only dependency a test can have is on another test. So we make building fish and # `fish_tests` prerequisites to our entire top-level `test` target. function(add_test_target NAME) string(REPLACE "/" "-" NAME ${NAME}) add_custom_target("test_${NAME}" COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R "^${NAME}$$" DEPENDS fish_tests tests_buildroot_target USES_TERMINAL ) endfunction()
Aha, the -R argument.
Solution:
cmake --build build --target test_tmux-complete.fish
For a test name tmux-complete.fish.
The error I'm getting doesn't seem to relate to the code I have changed... it seems to be completing a directory ~/temp when ~/file-1 and ~/file-2 should be the only options.
[1/9] cd /home/razzi/forks/fish-shell && /home/razzi/forks/fish-shell/build_tools/git_version_gen.sh /home/razzi/forks/fish-shell/build
[3/7] Running utility command for _cargo-build_fish-rust
[3/4] Install the project...
-- Install configuration: "RelWithDebInfo"
[6/7] cd /home/razzi/forks/fish-shell/build && /usr/bin/ctest --output-on-failure -R ^tmux-complete.fish$
Test project /home/razzi/forks/fish-shell/build
Start 181: tmux-complete.fish
1/1 Test #181: tmux-complete.fish ...............***Failed 3.38 sec
Testing file checks/tmux-complete.fish ... Failure:
The CHECK on line 16 wants:
prompt 0> HOME=$PWD ls ~/file-{{1?}}
which failed to match line stdout:1:
prompt 0> HOME=$PWD ls ~/temp/
Context:
prompt 0> HOME=$PWD ls ~/temp/ <= does not match CHECK on line 16: prompt 0> HOME=$PWD ls ~/file-{{1?}}
~/file-1 ~/file-2
prompt 1> cat cmake/
cmake/ CMakeFiles/ <= does not match CHECK on line 32: prompt 2> foo2 aabc
prompt 2> foo2 Aabc <= no check matches this, previous check on line 32
aabc aaBd
prompt 3> begin
rows 1 to 6 of 10
prompt 3> foo2 <= does not match CHECK on line 53: prompt 3> foo2 aa
prompt 3> foo2 aabc aabc
aabc aaBd
foo4 b-short-arg a-long-arg-________________________________________…
when running command:
../test/root/bin/fish checks/tmux-complete.fish
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 3.38 sec
The following tests FAILED:
181 - tmux-complete.fish (Failed)
Errors while running CTest
FAILED: CMakeFiles/test_tmux-complete.fish /home/razzi/forks/fish-shell/build/CMakeFiles/test_tmux-complete.fish
cd /home/razzi/forks/fish-shell/build && /usr/bin/ctest --output-on-failure -R ^tmux-complete.fish$
ninja: build stopped: subcommand failed.
Digging in to how that directory got there with:
env fish_trace=1 FISH_DEBUG_OUTPUT=/tmp/debugfish.txt cmake --build build --target test_tmux-complete.fish
Which produces this output:
> source /home/razzi/forks/fish-shell/share/config.fish
--> set -g IFS \n\ \t
--> set -qg __fish_added_user_paths
--> set -g __fish_added_user_paths
--> function __fish_default_command_not_found_handler
--> if
--> status --is-interactive
---> function fish_command_not_found --on-event fish_command_not_found
--> end if
--> set -l __extra_completionsdir
--> set -l __extra_functionsdir
--> set -l __extra_confdir
--> if
--> test -f /home/razzi/forks/fish-shell/share/__fish_build_paths.fish
--> end if
--> set -l xdg_data_dirs
--> if
--> set -q XDG_DATA_DIRS
--> else
---> set xdg_data_dirs /home/razzi/forks/fish-shell/share
--> end if
--> set -g __fish_vendor_completionsdirs
--> set -g __fish_vendor_functionsdirs
--> set -g __fish_vendor_confdirs
--> if
--> set -q FISH_UNIT_TESTS_RUNNING
---> set __fish_vendor_completionsdirs /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_completions.d /home/razzi/forks/fish-shell/share/vendor_completions.d
---> set __fish_vendor_functionsdirs /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_functions.d /home/razzi/forks/fish-shell/share/vendor_functions.d
---> set __fish_vendor_confdirs /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_conf.d /home/razzi/forks/fish-shell/share/vendor_conf.d
---> if
---> contains -- /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_completions.d /home/razzi/forks/fish-shell/share/vendor_completions.d
----> set -a __fish_vendor_completionsdirs
---> end if
---> if
---> contains -- /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_functions.d /home/razzi/forks/fish-shell/share/vendor_functions.d
----> set -a __fish_vendor_functionsdirs
---> end if
---> if
---> contains -- /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_conf.d /home/razzi/forks/fish-shell/share/vendor_conf.d
----> set -a __fish_vendor_confdirs
---> end if
--> end if
--> if
--> set -q fish_function_path
---> set fish_function_path /tmp/tmp.knzAnERNxs/xdg_config_home/fish/functions /home/razzi/forks/fish-shell/etc/functions /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_functions.d /home/razzi/forks/fish-shell/share/vendor_functions.d /home/razzi/forks/fish-shell/share/functions
--> end if
--> if
--> set -q fish_complete_path
---> set fish_complete_path /tmp/tmp.knzAnERNxs/xdg_config_home/fish/completions /home/razzi/forks/fish-shell/etc/completions /tmp/tmp.knzAnERNxs/xdg_data_home/fish/vendor_completions.d /home/razzi/forks/fish-shell/share/vendor_completions.d /home/razzi/forks/fish-shell/share/completions /tmp/tmp.knzAnERNxs/xdg_data_home/fish/generated_completions
--> end if
--> function __fish_reconstruct_path -d 'Update PATH when fish_user_paths changes' --on-variable fish_user_paths
--> function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description 'TRAP handler: debug prompt'
--> function __fish_on_interactive --on-event fish_prompt --on-event fish_read
---> source /home/razzi/forks/fish-shell/share/functions/__fish_set_locale.fish
-----> function __fish_set_locale
--> __fish_set_locale
----> set -l LOCALE_VARS
----> set -a LOCALE_VARS LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE
----> set -a LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
----> set -a LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
----> for LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION LC_ALL
-----> if
-----> set -q LANG
------> return 0
-----> end if
----> end for
--> if
--> status --is-login
--> end if
--> __fish_reconstruct_path
----> set -l new_user_path
-----> string split : --
----> for
----> end for
----> if
-----> count
-----> count
----> test 0 -lt 0
----> end if
----> set -l local_path /home/razzi/.local/bin /home/razzi/.cargo/bin /home/razzi/.yarn/bin /home/razzi/.asdf/shims/ /home/razzi/.asdf/bin /home/razzi/.local/bin /home/razzi/.cargo/bin /home/razzi/.nix-profile/bin /nix/var/nix/profiles/default/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/local/games /usr/games /home/razzi/.local/share/gem/ruby/3.1.0/bin /home/razzi/gopath/bin /home/razzi/.local/share/gem/ruby/3.1.0/bin /home/razzi/gopath/bin
----> for
----> end for
----> set -g __fish_added_user_paths
----> if
----> set -q fish_user_paths
----> end if
----> set -xg PATH /home/razzi/.local/bin /home/razzi/.cargo/bin /home/razzi/.yarn/bin /home/razzi/.asdf/shims/ /home/razzi/.asdf/bin /home/razzi/.local/bin /home/razzi/.cargo/bin /home/razzi/.nix-profile/bin /nix/var/nix/profiles/default/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/local/games /usr/games /home/razzi/.local/share/gem/ruby/3.1.0/bin /home/razzi/gopath/bin /home/razzi/.local/share/gem/ruby/3.1.0/bin /home/razzi/gopath/bin
--> function __fish_expand_pid_args
--> for bg wait disown
---> function bg -V jobbltn
---> function wait -V jobbltn
---> function disown -V jobbltn
--> end for
--> function fg
--> if
--> command -q kill
---> function kill
--> end if
--> set -l sourcelist
--> for
--> end for
> source /home/razzi/forks/fish-shell/etc/config.fish
> set fish_function_path /tmp/tmp.knzAnERNxs/xdg_config_home/fish/functions /home/razzi/forks/fish-shell/build/share/functions
> source /home/razzi/forks/fish-shell/build/tests/test_util.fish
--> function die
--> function say -V suppress_color
--> for gdate date
---> if
---> command -q gdate
---> else
----> set -g unit sec
---> end if
---> if
---> command -q date
---> date --version
----> set -g milli date
----> set -g unit ms
----> break
---> end if
--> end for
--> function timestamp
--> function delta
> set -x FISH_UNIT_TESTS_RUNNING 1
-> source /home/razzi/forks/fish-shell/build/share/functions/cd.fish
---> function cd --description 'Change directory'
-> status dirname
> cd /home/razzi/forks/fish-shell/build/tests
--> set -l MAX_DIR_HIST 25
--> if
--> set -q 'argv[2]'
--> end if
--> if
--> status --is-command-substitution
--> end if
--> set -l previous /tmp/tmp.knzAnERNxs/temp
--> if
--> test /home/razzi/forks/fish-shell/build/tests = -
--> end if
--> cd /home/razzi/forks/fish-shell/build/tests
--> set -l cd_status 0
--> if
--> test 0 -eq 0 -a /home/razzi/forks/fish-shell/build/tests != /tmp/tmp.knzAnERNxs/temp
---> set -q dirprev
---> set -l dirprev
---> set -q 'dirprev[25]'
---> set -U -q dirprev
---> set -g -a dirprev /tmp/tmp.knzAnERNxs/temp
---> set -U -q dirnext
---> set -e dirnext
---> set -U -q __fish_cd_direction
---> set -g __fish_cd_direction prev
--> end if
--> return 0
> set -l files_to_test
> if
> set -q 'argv[1]'
-> set files_to_test checks/tmux-complete.fish
> end if
> if
-> count checks/tmux-complete.fish
> test 1 -gt 1
> end if
--> source /home/razzi/forks/fish-shell/build/share/functions/__fish_anypython.fish
----> function __fish_anypython
-> __fish_anypython
---> for python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python2 python2.7 python
----> if
-----> command -s python3
----> set -l py_path /home/razzi/.asdf/shims/python3
-----> if
-----> string match -q /usr/bin/python3 -- /home/razzi/.asdf/shims/python3
-----> end if
-----> echo python3
-----> return 0
----> end if
---> end for
> set -g python python3
> set -l skipped 0
> set -l failed 0
> if
> set -q 'files_to_test[1]'
-> set -l force_color
-> test 1 = 1
-> set force_color --force-color
-> python3 -S ../littlecheck.py --progress --force-color -s fish=../test/root/bin/fish -s fish_test_helper=../test/root/bin/fish_test_helper checks/tmux-complete.fish
-> set -l littlecheck_status 1
-> if
-> test 1 -eq 125
-> else
--> set failed 1
-> end if
> end if
> if
> test 1 -eq 0
> else if
> test 1 -eq 0
> else
--> count checks/tmux-complete.fish
-> test 1 -gt 1
-> exit 1
> end if
Which seems to wrap the call to littlecheck.py:
-> python3 -S ../littlecheck.py --progress --force-color -s fish=../test/root/bin/fish -s fish_test_helper=../test/root/bin/fish_test_helper checks/tmux-complete.fish
Haven't figured out where this is running from to run it manually, yet.