generated from threeal/cmake-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: organize sections in
test/assert_execute_process.cmake
- Loading branch information
Showing
1 changed file
with
60 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,73 @@ | ||
section("execute process assertions") | ||
file(TOUCH some-file) | ||
section("process execution assertion") | ||
section("it should assert a process execution") | ||
assert_execute_process("${CMAKE_COMMAND}" -E true) | ||
endsection() | ||
|
||
assert_execute_process("${CMAKE_COMMAND}" -E true) | ||
section("it should fail to assert a process execution") | ||
assert_fatal_error( | ||
CALL assert_execute_process "${CMAKE_COMMAND}" -E true ERROR .* | ||
MESSAGE "expected command:\n ${CMAKE_COMMAND} -E true\nto fail") | ||
endsection() | ||
endsection() | ||
|
||
assert_execute_process( | ||
"${CMAKE_COMMAND}" -E make_directory some-file ERROR .*) | ||
section("failed process execution assertion") | ||
file(TOUCH some-file) | ||
|
||
assert_fatal_error( | ||
CALL assert_execute_process "${CMAKE_COMMAND}" -E true ERROR .* | ||
MESSAGE "expected command:\n ${CMAKE_COMMAND} -E true\nto fail") | ||
section("it should assert a failed process execution") | ||
assert_execute_process( | ||
"${CMAKE_COMMAND}" -E make_directory some-file ERROR .*) | ||
endsection() | ||
|
||
assert_fatal_error( | ||
CALL assert_execute_process "${CMAKE_COMMAND}" -E make_directory some-file | ||
MESSAGE "expected command:\n" | ||
" ${CMAKE_COMMAND} -E make_directory some-file\n" | ||
"not to fail with error:\n" | ||
" Error creating directory \"some-file\".") | ||
section("it should fail to assert a failed process execution") | ||
assert_fatal_error( | ||
CALL assert_execute_process "${CMAKE_COMMAND}" -E make_directory some-file | ||
MESSAGE "expected command:\n" | ||
" ${CMAKE_COMMAND} -E make_directory some-file\n" | ||
"not to fail with error:\n" | ||
" Error creating directory \"some-file\".") | ||
endsection() | ||
endsection() | ||
|
||
section("execute process output assertions") | ||
assert_execute_process( | ||
COMMAND "${CMAKE_COMMAND}" -E echo "Hello world!" | ||
OUTPUT "Hello" ".*!") | ||
|
||
assert_fatal_error( | ||
CALL assert_execute_process | ||
section("process execution output assertion") | ||
section("it should assert a process execution output") | ||
assert_execute_process( | ||
COMMAND "${CMAKE_COMMAND}" -E echo "Hello world!" | ||
OUTPUT "Hello" ".*earth!" | ||
MESSAGE "expected the output:\n" | ||
".*\n" | ||
"of command:\n" | ||
" ${CMAKE_COMMAND} -E echo Hello world!\n" | ||
"to match:\n" | ||
" Hello.*earth!") | ||
OUTPUT "Hello" ".*!") | ||
endsection() | ||
|
||
section("it should fail to assert a process execution output") | ||
assert_fatal_error( | ||
CALL assert_execute_process | ||
COMMAND "${CMAKE_COMMAND}" -E echo "Hello world!" | ||
OUTPUT "Hello" ".*earth!" | ||
MESSAGE "expected the output:\n" | ||
".*\n" | ||
"of command:\n" | ||
" ${CMAKE_COMMAND} -E echo Hello world!\n" | ||
"to match:\n" | ||
" Hello.*earth!") | ||
endsection() | ||
endsection() | ||
|
||
section("execute process error assertions") | ||
section("process execution error assertion") | ||
file(TOUCH some-file) | ||
|
||
assert_execute_process( | ||
COMMAND "${CMAKE_COMMAND}" -E make_directory some-file | ||
ERROR "Error creating directory" ".*some-file") | ||
|
||
assert_fatal_error( | ||
CALL assert_execute_process | ||
section("it should assert a process execution error") | ||
assert_execute_process( | ||
COMMAND "${CMAKE_COMMAND}" -E make_directory some-file | ||
ERROR "Error creating directory" ".*some-other-file" | ||
MESSAGE "expected the error:\n" | ||
".*\n" | ||
"of command:\n" | ||
" ${CMAKE_COMMAND} -E make_directory some-file\n" | ||
"to match:\n" | ||
" Error creating directory.*some-other-file") | ||
ERROR "Error creating directory" ".*some-file") | ||
endsection() | ||
|
||
section("it should fail to assert a process execution error") | ||
assert_fatal_error( | ||
CALL assert_execute_process | ||
COMMAND "${CMAKE_COMMAND}" -E make_directory some-file | ||
ERROR "Error creating directory" ".*some-other-file" | ||
MESSAGE "expected the error:\n" | ||
".*\n" | ||
"of command:\n" | ||
" ${CMAKE_COMMAND} -E make_directory some-file\n" | ||
"to match:\n" | ||
" Error creating directory.*some-other-file") | ||
endsection() | ||
endsection() |