Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Formatting Symbolic Link Path Assertion Errors #183

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmake/Assertion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ function(assert)
elseif(ARGV0 STREQUAL "IS_DIRECTORY")
fail("expected path" ARGV1 "to be a directory")
return()
elseif(ARGV0 STREQUAL "IS_SYMLINK")
fail("expected path" ARGV1 "to be a symbolic link")
return()
endif()
endif()
elseif(ARGC EQUAL 3)
Expand Down Expand Up @@ -180,6 +183,9 @@ function(assert)
elseif(ARGV1 STREQUAL "IS_DIRECTORY")
fail("expected path" ARGV2 "not to be a directory")
return()
elseif(ARGV1 STREQUAL "IS_SYMLINK")
fail("expected path" ARGV2 "not to be a symbolic link")
return()
endif()
else()
if(ARGV1 STREQUAL "IN_LIST")
Expand Down
20 changes: 20 additions & 0 deletions test/assert.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,26 @@ section("executable path condition assertions")
endsection()
endsection()

section("symbolic link path condition assertions")
file(TOUCH some_file)
file(CREATE_LINK some_file some_symlink SYMBOLIC)

section("it should assert symbolic link path conditions")
assert(IS_SYMLINK some_symlink)
assert(NOT IS_SYMLINK some_file)
endsection()

section("it should fail to assert symbolic link path conditions")
assert_fatal_error(
CALL assert IS_SYMLINK some_file
MESSAGE "expected path:\n some_file\nto be a symbolic link")

assert_fatal_error(
CALL assert NOT IS_SYMLINK some_symlink
MESSAGE "expected path:\n some_symlink\nnot to be a symbolic link")
endsection()
endsection()

section("regular expression match condition assertions")
section("given a string")
section("it should assert regular expression match conditions")
Expand Down