Skip to content

Commit 9517fa1

Browse files
committed
DONT MERGE
1 parent 1fad77b commit 9517fa1

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

cmake/Assertion.cmake

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,24 @@ endfunction()
3131
macro(fail FIRST_LINE)
3232
set(MESSAGE "${FIRST_LINE}")
3333

34+
unset(PREV_LINE_IS_MULTI_LINE)
3435
foreach(LINE IN ITEMS ${ARGN})
3536
if(DEFINED "${LINE}")
36-
string(REPLACE "\n" "\n " LINE "${${LINE}}")
37-
string(APPEND MESSAGE ":\n ${LINE}")
37+
if("${${LINE}}" MATCHES "\n")
38+
string(REPLACE "\n" "\n " LINE "${${LINE}}")
39+
string(APPEND MESSAGE ":\n ${LINE}")
40+
else()
41+
string(APPEND MESSAGE " '${${LINE}}'")
42+
endif()
3843
else()
39-
string(APPEND MESSAGE "\n${LINE}")
44+
if(PREV_LINE_IS_MULTI_LINE)
45+
string(APPEND MESSAGE "\n${LINE}")
46+
else()
47+
string(APPEND MESSAGE " ${LINE}")
48+
endif()
4049
endif()
4150
endforeach()
51+
unset(PREV_LINE_IS_MULTI_LINE)
4252

4353
message(FATAL_ERROR "${MESSAGE}")
4454
endmacro()

test/AssertExecuteProcess.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ section("execute process assertions")
88

99
assert_fatal_error(
1010
CALL assert_execute_process "${CMAKE_COMMAND}" -E true ERROR .*
11-
MESSAGE "expected command:\n ${CMAKE_COMMAND} -E true\nto fail")
11+
MESSAGE "expected command '${CMAKE_COMMAND} -E true' to fail")
1212

1313
assert_fatal_error(
1414
CALL assert_execute_process "${CMAKE_COMMAND}" -E make_directory some-file
15-
MESSAGE "expected command:\n"
16-
" ${CMAKE_COMMAND} -E make_directory some-file\n"
17-
"not to fail with error:\n"
18-
" Error creating directory \"some-file\".")
15+
MESSAGE "expected command '${CMAKE_COMMAND} -E make_directory some-file' "
16+
"not to fail with error 'Error creating directory \"some-file\".'")
1917
endsection()
2018

2119
section("execute process output assertions")

test/Fail.cmake

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ section("it should fail with a formatted fatal error message")
88
MESSAGE "something happened\non multiple lines")
99

1010
assert_fatal_error(
11-
CALL fail "something happened" "on multiple lines"
12-
MESSAGE "something happened\non multiple lines")
11+
CALL fail "something happened" "not on multiple lines"
12+
MESSAGE "something happened not on multiple lines")
1313
endsection()
1414

1515
section("it should fail with a formatted fatal error message "
@@ -18,30 +18,32 @@ section("it should fail with a formatted fatal error message "
1818
set(REASON_MULTILINE "some reason\non multiple lines")
1919

2020
assert_fatal_error(
21-
CALL fail "something happened" REASON
22-
MESSAGE "something happened:\n some reason")
21+
CALL fail "something happened because of" REASON
22+
MESSAGE "something happened because of 'some reason'")
2323

2424
assert_fatal_error(
25-
CALL fail "something happened" REASON_MULTILINE
26-
MESSAGE "something happened:\n some reason\n on multiple lines")
25+
CALL fail "something happened because of" REASON_MULTILINE
26+
MESSAGE "something happened because of:\n"
27+
" some reason\n on multiple lines")
2728

2829
assert_fatal_error(
29-
CALL fail "something happened\non multiple lines" REASON
30-
MESSAGE "something happened\non multiple lines:\n some reason")
30+
CALL fail "something happened\non multiple lines because of" REASON
31+
MESSAGE "something happened\non multiple lines because of 'some reason'")
3132

3233
assert_fatal_error(
33-
CALL fail "something happened\non multiple lines" REASON_MULTILINE
34-
MESSAGE "something happened\non multiple lines:\n"
34+
CALL fail "something happened\non multiple lines because of"
35+
REASON_MULTILINE
36+
MESSAGE "something happened\non multiple lines because of:\n"
3537
" some reason\n on multiple lines")
3638

3739
assert_fatal_error(
38-
CALL fail "something happened" "on multiple lines" REASON
39-
MESSAGE "something happened\non multiple lines:\n some reason")
40+
CALL fail "something happened" "not on multiple lines because of" REASON
41+
MESSAGE "something happened not on multiple lines because of 'some reason'")
4042

4143
assert_fatal_error(
4244
CALL fail
43-
"something happened" "on multiple lines" REASON
44-
"something else happened" REASON_MULTILINE
45-
MESSAGE "something happened\non multiple lines:\n some reason\n"
46-
"something else happened:\n some reason\n on multiple lines")
45+
"something happened" "not on multiple lines because of" REASON
46+
"something else happened because of" REASON_MULTILINE
47+
MESSAGE "something happened not on multiple lines because of 'some reason' "
48+
"something else happened because of:\n some reason\n on multiple lines")
4749
endsection()

0 commit comments

Comments
 (0)