Skip to content

Commit

Permalink
Merge pull request #45 from fdefelici/release_v2.3.0
Browse files Browse the repository at this point in the history
Release v2.3.0
  • Loading branch information
fdefelici authored Sep 23, 2022
2 parents dd647a2 + 15c68f5 commit 3684d6d
Show file tree
Hide file tree
Showing 26 changed files with 2,618 additions and 675 deletions.
37 changes: 1 addition & 36 deletions .github/workflows/ci_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- '**'
- '!master'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- '**'
Expand Down Expand Up @@ -55,37 +53,4 @@ jobs:
cd ${{env.BUILD_DIR}}
ctest -C Release -T test --output-on-failure
cd ${{ github.workspace }}
release:
name: Create Github Release
needs: build
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./clove-unit.h
asset_name: clove-unit.h
asset_content_type: text/plain
- name: Compute Archive SHA256
run: |
URL=${{ github.server_url }}/${{ github.repository }}/archive/${{ github.ref }}.tar.gz
echo "URL: ${URL}"
curl -L ${URL} -o archive.tar.gz
sha256sum archive.tar.gz
27 changes: 27 additions & 0 deletions .github/workflows/release_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release Action
on:
release:
types: [published]
jobs:
release:
name: Update Github Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./clove-unit.h
asset_name: clove-unit.h
asset_content_type: text/plain
- name: Compute Archive SHA256
run: |
URL=${{ github.server_url }}/${{ github.repository }}/archive/${{ github.ref }}.tar.gz
echo "URL: ${URL}"
curl -L ${URL} -o archive.tar.gz
sha256sum archive.tar.gz
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include(CTest)
add_subdirectory(tests)
add_subdirectory(examples/clove101)
add_subdirectory(examples/clovepp)

if (NOT DEFINED CI_TRIGGERED)
add_subdirectory(perfs)
endif()
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@

The aim of this library is to reduce at the minimum the boilder-plate for C developers and just focus on unit test development (such as avoiding to register manually the tests to an execution list).

`CLove-Unit` is able to discover and run your tests, gathering information about positives and failures (file, line, reason), with a colored syntax (if ANSI is supported by your shell).
`CLove-Unit` is able to discover and run your tests, gathering information about positives and failures (file, line, reason), with possibility to show the result in different output formats (configurable by a powerful command-line api).

Here an example of the default report format (pretty printing on console with ansi support)

![Clove test run result](./examples/result.png)

# Features
Here a list of features provided by `CLove-Unit`:
* Single Header
* Tests Autodiscovery (reducing at minimum developer boiler-plate on writing tests)
* Console Report in ANSI format (if supported by the shell)
* Test Report with different format (pretty print ansi, csv, json) and output (console or file)
* Tests / Run duration
* Tests / Run failure pointing to the file/line where the assertions are unsatisfied
* Selective test execution (opportunity to include/exclude tests from the execution)
* Command-line api to interact with the test binary, useful for creating IDE Plugins and Automations

# IDE Extension
For the one, who prefer UI oriented test executor, `CLove-Unit` is supported on the following IDEs:
Expand All @@ -28,7 +31,7 @@ Have a look and enjoy ;-)

# How it works
`CLove-Unit` is implemented around the following concepts:
- **Test**: a test is basically a fuction where you can stimulate your code and validate it using assertion
- **Test**: a test is basically a fuction where you can stimulate your code and validate it using assertions
- **Suite**: a suite is a set of Tests to be run. A Suite allow to execute setup/teardown behaviour for each Test execution (or once for all the Tests).
- **Runner**: a runner allow execution of a set of Suites and provide results

Expand Down Expand Up @@ -146,21 +149,32 @@ Helper apis to support test implementation
| Api | Description |
| ------------- | ------------- |
| CLOVE_EXEC_PATH() | Macro to easily retrive executable path as a char* |
| CLOVE_EXEC_BASE_PATH() | Macro to easily retrive executable base path a char* |
| CLOVE_EXEC_BASE_PATH() | Macro to easily retrive executable base path as a char* |

# Console Apis
Commandline options supported by the binary produced by a `CLove-Unit` test project compilation.
# Command-Line Api
A binary built with `CLove-Unit` library supports a set of command-line options when lanched like this:

> ```<executable> [options] ```
| Command line | Description |
| Option | Description |
| ------------- | ------------- |
| \<exec\> | Running executable with no args will produce a verbose console report |
| \<exec\> -i `SELECT_PATTERN` | include tests to be executed by the runner <br /> (optional argument, can be repeated more than once) |
| \<exec\> -e `SELECT_PATTERN` | exclude tests to be executed by the runner <br /> (optional argument, can be repeated more than once) |

> NOTE: If both -i and -e options are provided, the inclusion pattern always wins over the exclusion one.
The `SELECT_PATTERN` works as follow:
| \<no-option\> | Running executable with no args will execute tests producing a report in `pretty` format (default) |
| -e, --exclude \<expr\> | Exclude tests to be run/listed<br /> (can be repeated more than once)<br /> [[read here for more details](#test-inclusionexclusion)] |
| -h, --help | Display usage information |
| -i, --include \<expr\> | Include tests to be run/listed<br /> (can be repeated more than once)<br /> [[read here for more details](#test-inclusionexclusion)]|
| -l, --list-tests | List all/matching test cases in `pretty` format (default).<br />Accepts inclusion/exclusion expression |
| -o, --output \<stream\> | Specify output stream for a report. Possible choises: `stdout` (default) or `<file path>` |
| -r, --report \<format\> | Specify report format when running/listing tests. Possible choises: `pretty`, `csv`, `json` |
| -t, --run-tests | Execute all/matching test cases (same as \<no-option\> scenario).<br />Accepts inclusion/exclusion expression |
| -v, --version | Show CLove-Unit version |
| -x, --error-on-test-fail | Test run process will end with error in case of test failure. Default is to end the process succesfully |

## Test Inclusion/Exclusion
Inclusion/Exclusion options are useful to collect a specific subset of Suite/Tests and can be repeated more the once in the commandline.

> NOTE: If both inclusion and exclusion options are provided, the inclusion pattern always wins over the exclusion one.
These options allow to specify an expression that works as follow:
* Basic: `SuiteName.TestName`
* Wildcard: Only `*` is supported, and can be used to implement pattern such as "start with", "end with", "contains", "all", for both the SuiteName and TestName

Expand All @@ -175,5 +189,3 @@ So for instance the following are valids select patterns (non-exhaustive list):
| \*Suite\* | will match all tests whose Suite Name contains "Suite" |
| MySuite01.*01 | will match all tests whose Suite Name is MySuite01 and Test Name ends with "01" |
| \*.\* | will match all suites and tests |


Loading

0 comments on commit 3684d6d

Please sign in to comment.