Skip to content

Commit

Permalink
docs: update readme to showcase execute process assertion (#55)
Browse files Browse the repository at this point in the history
* docs(readme): add process execution assertion to key features

* docs(readme): add assert process execution to example usages

* chore: bump project to version 0.2.0
  • Loading branch information
threeal authored May 28, 2024
1 parent c921b64 commit 2a2119d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
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

0 comments on commit 2a2119d

Please sign in to comment.