@@ -1946,6 +1946,13 @@ namespace
19461946 return result.code ;
19471947 }
19481948
1949+ static bool ctest_output_has_no_tests (const std::string &output)
1950+ {
1951+ return output.find (" No tests were found" ) != std::string::npos ||
1952+ output.find (" No tests were found!!!" ) != std::string::npos ||
1953+ output.find (" Total Tests: 0" ) != std::string::npos;
1954+ }
1955+
19491956 static int run_ctest (const vix::commands::TestsCommand::detail::Options &opt)
19501957 {
19511958 const std::string presetName = resolve_preset_name (opt);
@@ -2010,7 +2017,7 @@ namespace
20102017 const std::vector<std::string> tests =
20112018 parse_ctest_list_output (result.output );
20122019
2013- if (tests.empty () && has_test_sources (opt. projectDir ))
2020+ if (tests.empty () && ctest_output_has_no_tests (result. output ))
20142021 return 2 ;
20152022
20162023 print_test_header (opt);
@@ -2027,19 +2034,15 @@ namespace
20272034 return 0 ;
20282035 }
20292036
2030- print_test_header (opt);
2031-
20322037 if (ok)
20332038 {
20342039 const std::vector<CTestItem> tests =
20352040 parse_ctest_run_output (result.output );
20362041
2037- if (tests.empty () &&
2038- has_test_sources (opt.projectDir ) &&
2039- result.output .find (" No tests were found" ) != std::string::npos)
2040- {
2042+ if (tests.empty () && ctest_output_has_no_tests (result.output ))
20412043 return 2 ;
2042- }
2044+
2045+ print_test_header (opt);
20432046
20442047 if (opt.raw )
20452048 {
@@ -2065,6 +2068,13 @@ namespace
20652068 return 0 ;
20662069 }
20672070
2071+ print_test_header (opt);
2072+
2073+ build::print_task_failure_timed (
2074+ std::cout,
2075+ failed_tests_message (result),
2076+ ms);
2077+
20682078 build::print_task_failure_timed (
20692079 std::cout,
20702080 failed_tests_message (result),
@@ -2088,6 +2098,9 @@ namespace
20882098 {
20892099 auto run_available_tests = [&]() -> int
20902100 {
2101+ if (should_force_ctest (opt))
2102+ return run_ctest (opt);
2103+
20912104 const std::string presetName = resolve_preset_name (opt);
20922105 const fs::path buildDir =
20932106 resolve_build_dir_from_preset (opt.projectDir , presetName);
0 commit comments