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

Update Readme to Showcase Execute Process Assertion #55

Merged
merged 3 commits into from
May 28, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.19)

project(
Assertion
VERSION 0.1.0
VERSION 0.2.0
DESCRIPTION "A collection of assertion functions for testing purposes"
HOMEPAGE_URL https://github.com/threeal/assertion-cmake
LANGUAGES NONE
Expand Down
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ A [CMake](https://cmake.org/) module containing a collection of assertion functi

- Contains a collection of assertion functions for testing purposes.
- Supports mocking and asserting the `message` function.
- Supports asserting process execution.

## Integration

Expand All @@ -18,14 +19,14 @@ This module can be integrated into a CMake project in the following ways:
- Use [`file(DOWNLOAD)`](https://cmake.org/cmake/help/latest/command/file.html#download) to automatically download the `Assertion.cmake` file:
```cmake
file(
DOWNLOAD https://threeal.github.io/assertion-cmake/v0.1.0
DOWNLOAD https://threeal.github.io/assertion-cmake/v0.2.0
${CMAKE_BINARY_DIR}/Assertion.cmake
)
include(${CMAKE_BINARY_DIR}/Assertion.cmake)
```
- Use [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to add this package to the CMake project:
```cmake
cpmaddpackage(gh:threeal/assertion-cmake@0.1.0)
cpmaddpackage(gh:threeal/assertion-cmake@0.2.0)
include(${Assertion_SOURCE_DIR}/cmake/Assertion.cmake)
```

Expand Down Expand Up @@ -64,6 +65,28 @@ assert_message(STATUS "some status message")
assert_message(ERROR "some error message")
```

### Assert Process Execution

Use the `assert_execute_process` function to assert whether the given command successfully executed a process:

```cmake
assert_execute_process(COMMAND "${CMAKE_COMMAND}" -E true)
```

This function can also assert the standard output and error of the executed process:

```cmake
assert_execute_process(
COMMAND "${CMAKE_COMMAND}" -E echo "Hello world!"
OUTPUT "Hello world!"
)

assert_execute_process(
COMMAND "${CMAKE_COMMAND}" invalid-dir
ERROR "CMake Error: The source directory .* does not exist."
)
```

## License

This project is licensed under the terms of the [MIT License](./LICENSE).
Expand Down