Blog: 2023-08-24

From razwiki
Revision as of 21:46, 23 August 2023 by Razzi (talk | contribs) (Created page with "Trying to figure out how to run single test in fish Makefile: <pre> .PHONY: test test: build/fish $(CMAKE) --build build --target test </pre> Tests.cmake: <pre> # CMake b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.