From 9654835b4f3c0e7b5fe41405f12c762875b54c6b Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 26 Sep 2023 17:08:20 +0200 Subject: Tests/RunCMake/Autogen: Add expect_n_times() function --- Tests/RunCMake/Autogen/RunCMakeTest.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake index 12a8f8e..5c2ea2b 100644 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake @@ -239,6 +239,16 @@ ${make_program_stderr} endif() endfunction() + function(expect_n_times string_to_check expected_output expected_count test_name) + count_substring("${string_to_check}" "${expected_output}" count) + if(NOT count EQUAL ${expected_count}) + message(STATUS "${test_name}-expect_${expected_count}_times - FAILED") + message(FATAL_ERROR "Expected to find ${expected_output} exactly ${expected_count} times in ${string_to_check} but found ${count} occurrences of ${expected_output}") + else() + message(STATUS "${test_name}-expect_${expected_count}_times - PASSED") + endif() + endfunction() + function(not_expect make_program_stdout unexpected_output test_name) count_substring("${make_program_stdout}" "${unexpected_output}" count) if(NOT count EQUAL 0) -- cgit v0.12