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

Release v2.4.5 #111

Merged
merged 35 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d17e538
#102 fix macos image slide address computation that failed when launc…
fdefelici Jun 1, 2024
4bc8f5c
#102 fix github ci regression on ubuntu 22.04 where has been removed …
fdefelici Jun 1, 2024
959e119
#102 restore newline at end of file
fdefelici Jun 1, 2024
ee73804
#102 refactor, improve naming, extract __clove_string_last_indexof
fdefelici Jun 16, 2024
4de451d
#102 introduce __clove_memory_free
fdefelici Jun 16, 2024
1dc68e0
#102 leverage unix relapath behaviour to work with unexistent paths (…
fdefelici Jun 16, 2024
7ddc1aa
fix realpath call
fdefelici Jun 16, 2024
c87dac0
#102 improve realpath unix management
fdefelici Jun 16, 2024
efc31e8
#102 fix absolute path unit test for windows
fdefelici Jun 16, 2024
b4e2007
Make header library available for FetchContent
cprieto Jun 17, 2024
876a3b4
#102 improve absolute path test and overall utils tests organization
fdefelici Jun 18, 2024
f8211f8
#102 improve unix test
fdefelici Jun 18, 2024
3a9582c
#102 fix windows test
fdefelici Jun 18, 2024
99da1b3
#102 fix sanity
fdefelici Jun 18, 2024
7c68c4b
#102 improve error logging for macos image slide
fdefelici Jun 18, 2024
b7ceac0
Merge pull request #106 from fdefelici/102-sigsegv-while-running-test…
fdefelici Jun 18, 2024
3f84c8a
changed library target name to clove-unit
fdefelici Jun 19, 2024
a7d4241
#104 add guard to avoid including dev targets when using FetchContent
fdefelici Jun 19, 2024
a6cf7a1
#104 add minimum compile feature to c11 to library
fdefelici Jun 19, 2024
29b430d
#104 add minimum compile feature to c11 to library
fdefelici Jun 19, 2024
4977935
#104 improve comments
fdefelici Jun 19, 2024
2c9fe59
#104 improved readme to include documentation about cmake fetchconten…
fdefelici Jun 19, 2024
034f2af
Merge pull request #103 from cprieto/master
fdefelici Jun 19, 2024
1b69357
Merge pull request #108 from fdefelici/104-cmake-make-header-library-…
fdefelici Jun 19, 2024
55b30b5
#107 add install configuration to enable find_package
fdefelici Jun 20, 2024
3c04be9
#107 add find_package documentation
fdefelici Jun 20, 2024
7d3040d
Merge pull request #109 from fdefelici/107-cmake-make-header-library-…
fdefelici Jun 20, 2024
0e463b3
#105 converted input variables to option
fdefelici Jun 20, 2024
685a9a9
Merge pull request #110 from fdefelici/105-cmake-convert-build-flags-…
fdefelici Jun 20, 2024
536e44a
refactor cmake modules
fdefelici Jun 20, 2024
4ed32a0
prepare version 2.4.5
fdefelici Jun 20, 2024
297805e
prepare version 2.4.5
fdefelici Jun 20, 2024
7a1e3c9
update github action for nodejs obsolescence
fdefelici Jun 20, 2024
43643bf
fix naming in cmakelist
fdefelici Jun 20, 2024
c3efbbe
updated conan badge to show version
fdefelici Jun 20, 2024
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
48 changes: 29 additions & 19 deletions .github/workflows/ci_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
BUILD_DIR: ${{ github.workspace }}\build
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: List Workspace
run: dir /a ${{ github.workspace }}
- name: Compile
run: |
echo "== CMAKE VERSION =="
cmake --version
echo "== CMAKE CONFIGURE =="
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_BUILD=true
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_BUILD=ON
echo "== CMAKE BUILD =="
cmake --build ${{env.BUILD_DIR}} --config Release
- name: List Build
Expand All @@ -53,15 +53,15 @@ jobs:
BUILD_DIR: ${{ github.workspace }}/build
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: List Workspace
run: ls -la ${{ github.workspace }}
- name: Compile
run: |
echo "== CMAKE VERSION =="
cmake --version
echo "== CMAKE CONFIGURE =="
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_BUILD=true
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_BUILD=ON
echo "== CMAKE BUILD =="
cmake --build ${{env.BUILD_DIR}} --config Release
- name: List Build
Expand All @@ -73,27 +73,27 @@ jobs:
cd ${{ github.workspace }}
build_ubuntu:
name: Build ubuntu_${{matrix.compiler.c}}-${{matrix.compiler.v}}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
compiler:
- {c: gcc, cpp: g++, v: 11, strict: false}
- {c: gcc, cpp: g++, v: 12, strict: false}
- {c: gcc, cpp: g++, v: 13, strict: true}
- {c: clang, cpp: clang++, v: 13, strict: true}
- {c: clang, cpp: clang++, v: 14, strict: true}
- {c: clang, cpp: clang++, v: 15, strict: true}
- {c: clang, cpp: clang++, v: 16, strict: true}
- {c: clang, cpp: clang++, v: 17, strict: true}
- {c: gcc, cpp: g++, v: 11, strict: OFF}
- {c: gcc, cpp: g++, v: 12, strict: OFF}
- {c: gcc, cpp: g++, v: 13, strict: ON}
- {c: clang, cpp: clang++, v: 13, strict: ON}
- {c: clang, cpp: clang++, v: 14, strict: ON}
- {c: clang, cpp: clang++, v: 15, strict: ON}
- {c: clang, cpp: clang++, v: 16, strict: ON}
- {c: clang, cpp: clang++, v: 17, strict: ON}
defaults:
run:
shell: bash
env:
BUILD_DIR: ${{ github.workspace }}/build
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: List Workspace
run: ls -la ${{ github.workspace }}
- name: Install Clang (if needed)
Expand All @@ -102,20 +102,30 @@ jobs:
with:
version: "${{ matrix.compiler.v }}"
env: true # set CC / CXX variable
- name: Install GCC (if needed)
# Installing GCC-13 due to regression introduced in ubuntu 22.04 image
# https://github.com/actions/runner-images/issues/9866
if: ${{ matrix.compiler.c == 'gcc' && matrix.compiler.v == 13 }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -y
sudo apt-get install gcc-13
sudo apt-get install g++-13
- name: Set Compiler # only if CC / CXX are not already set from new installation
run: |
if [ -z "${CC}" ]; then
echo "CC=${{matrix.compiler.c}}-${{matrix.compiler.v}}" >> "$GITHUB_ENV"
echo "CXX=${{matrix.compiler.cpp}}-${{matrix.compiler.v}}" >> "$GITHUB_ENV"
else
echo CC=$CC
echo CXX=$CXX
fi
echo CC=$CC
echo CXX=$CXX
- name: Compile
run: |
echo "== CMAKE VERSION =="
cmake --version
echo "== CMAKE CONFIGURE =="
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_BUILD=true -DCLOVE_CMAKE__CPP_STRICT_WARN_AS_ERROR=${{matrix.compiler.strict}}
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_BUILD=ON -DCLOVE_CMAKE__CPP_STRICT_WARN_AS_ERROR=${{matrix.compiler.strict}}
echo "== CMAKE BUILD =="
cmake --build ${{env.BUILD_DIR}} --config Release
- name: List Build
Expand All @@ -135,15 +145,15 @@ jobs:
BUILD_DIR: ${{ github.workspace }}/build
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: List Workspace
run: ls -la ${{ github.workspace }}
- name: Compile
run: |
echo "== CMAKE VERSION =="
cmake --version
echo "== CMAKE CONFIGURE =="
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_SANITY=true
cmake -B${{env.BUILD_DIR}} -DCLOVE_CMAKE__UC_SANITY=ON
echo "== CMAKE BUILD =="
cmake --build ${{env.BUILD_DIR}} --config Release
- name: List Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
Expand Down
110 changes: 91 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,105 @@
cmake_minimum_required(VERSION 3.18)
project(CLoveUnit LANGUAGES C)
include(CTest)

#[[
add_subdirectory(tests/functs)
if (DEFINED CLOVE_CMAKE__CI_TRIGGERED)
add_subdirectory(tests/stricts/clove-c)
add_subdirectory(tests/stricts/clove-cpp)
add_subdirectory(examples/clove101)
add_subdirectory(examples/clovepp)
endif()
set(CLOVE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
list(INSERT CMAKE_MODULE_PATH 0 ${CLOVE_SOURCE_DIR}/cmake/modules)

if (DEFINED CLOVE_CMAKE__ENABLE_PERFS)
add_subdirectory(tests/perfs)
endif()
]]
include(CLoveModules)
clove_get_version(CLOVE_VERSION)

# Configure Project
project(
CLoveUnit
VERSION ${CLOVE_VERSION}
DESCRIPTION "Single-header Unit Testing framework for C (interoperable with C++) with test autodiscovery feature"
HOMEPAGE_URL "https://github.com/fdefelici/clove-unit"
LANGUAGES C
)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Eventually CMAKE_INSTALL_PREFIX can be overridden by the user to change base installation path for the package
clove_join_paths(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" clove-unit ${PROJECT_VERSION})

# Library Target definition and configuration
add_library(clove-unit INTERFACE)
add_library(clove-unit::clove-unit ALIAS clove-unit)

target_include_directories(
clove-unit INTERFACE
$<BUILD_INTERFACE:${CLOVE_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_features(clove-unit INTERFACE c_std_11)

# Install command stuffs for enabling find_package usage
install(
TARGETS clove-unit
EXPORT clove-unit-targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

if (CLOVE_CMAKE__UC_BUILD)
write_basic_package_version_file(
clove-unit-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

configure_package_config_file(
${CLOVE_SOURCE_DIR}/cmake/in/clove-unit-config.cmake.in
clove-unit-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
)

install(
FILES ${CLOVE_SOURCE_DIR}/clove-unit.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
FILES
${PROJECT_BINARY_DIR}/clove-unit-config.cmake
${PROJECT_BINARY_DIR}/clove-unit-config-version.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
)

install(
EXPORT clove-unit-targets
#NAMESPACE clove-unit::
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
)

export(PACKAGE clove-unit)


#[[
In case this is the root project add dev targets (Development mode).
To avoid targets pollution when using FetchContent were only the target library is required
Note: PROJECT_IS_TOP_LEVEL cmake variable exists in version 3.21+
]]
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
include(CTest)

option(CLOVE_CMAKE__UC_BUILD "enable build use case" OFF)
option(CLOVE_CMAKE__UC_SANITY "enable sanity check use case" OFF)
option(CLOVE_CMAKE__UC_PERFS "enable performance test use case" OFF)
option(CLOVE_CMAKE__CPP_STRICT_WARN_AS_ERROR "threat compilation warning as error" OFF)

if (CLOVE_CMAKE__UC_BUILD)
add_subdirectory(tests/functs)
add_subdirectory(tests/stricts/clove-c)
add_subdirectory(tests/stricts/clove-cpp)
add_subdirectory(examples/clove101)
add_subdirectory(examples/clovepp)
endif()
endif()

if (CLOVE_CMAKE__UC_SANITY)
if (CLOVE_CMAKE__UC_SANITY)
add_subdirectory(tests/stricts/clove-sanity)
endif()
endif()

if (CLOVE_CMAKE__UC_PERFS)
if (CLOVE_CMAKE__UC_PERFS)
add_subdirectory(tests/perfs)
endif()

endif()
95 changes: 86 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CLove-Unit &middot; [![version](https://img.shields.io/github/v/release/fdefelici/clove-unit?label=latest&sort=semver)](./clove-unit.h) [![workflow](https://img.shields.io/github/actions/workflow/status/fdefelici/clove-unit/ci_action.yml)](https://github.com/fdefelici/clove-unit/actions/workflows/ci_action.yml) [![conan](https://img.shields.io/badge/conan-available-blueviolet)](https://conan.io/center/recipes/clove-unit) [![Discord channel](https://img.shields.io/discord/1167864219190964255?logo=discord&logoColor=violet)](https://discord.gg/Mjx4YRQfFt)
# CLove-Unit &middot; [![version](https://img.shields.io/github/v/release/fdefelici/clove-unit?label=latest&sort=semver)](./clove-unit.h) [![workflow](https://img.shields.io/github/actions/workflow/status/fdefelici/clove-unit/ci_action.yml)](https://github.com/fdefelici/clove-unit/actions/workflows/ci_action.yml) [![conan](https://img.shields.io/conan/v/clove-unit)](https://conan.io/center/recipes/clove-unit) [![Discord channel](https://img.shields.io/discord/1167864219190964255?logo=discord&logoColor=violet)](https://discord.gg/Mjx4YRQfFt)

`CLove-Unit` is a single-header unit testing library designed for C (compatible with C++).

Expand All @@ -19,7 +19,7 @@ Consider also supporting `CLove-Unit` development becoming a [**sponsor**](https

* [Features](#features)
* [IDE Extensions](#ide-extensions)
* [Supported Package Managers](#supported-package-managers)
* [How to Integrate](#how-to-integrate)
* [How It Works](#how-it-works)
* [Getting Started](#getting-started)
* [Programming API](#programming-api)
Expand Down Expand Up @@ -48,11 +48,88 @@ For those who prefer a UI oriented test executor, `CLove-Unit` is supported on t

Have a look and enjoy ;-)

## Supported Package Managers
## How to Integrate

`CLove-Unit` is also available on the following Package Managers:
`CLove-Unit` can be imported in your project in the following ways:
- Sourcing the header file
- Using a Package Manager
- Using CMake

* [Conan](https://conan.io/center/recipes/clove-unit)
### Sourcing the Header file
Being an header-only library, you can just download [clove-unit.h](./clove-unit.h) file and include it in your project.

```c
#include "clove-unit.h"
```

Then remember to properly configure your compiler include paths.

### Using a Package Manager
`CLove-Unit` is currently available on the following Package Managers:

* [Conan](https://conan.io): read [here](https://conan.io/center/recipes/clove-unit) for details on how to import it.

### Using CMake
In case you still need dependency management, but you want to avoid Package Manager configuration complexity, you can use standard mechansim provided by `CMake` such as [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html), [add_subdirectory](https://cmake.org/cmake/help/latest/command/add_subdirectory.html) and [find_package](https://cmake.org/cmake/help/latest/command/find_package.html).

> NOTE: CMake library is named `clove-unit`

Here a few examples:

* **FetchContent**

```cmake
cmake_minimum_required(VERSION 3.18)
project(TestProject C)

Include(FetchContent)
FetchContent_Declare(
clove-unit
GIT_REPOSITORY https://github.com/fdefelici/clove-unit.git
GIT_TAG master # or eventually any branch, tag or commit sha
)
FetchContent_MakeAvailable(clove-unit)

add_executable(tests <YOUR_TEST_FILES>)
target_link_libraries(tests clove-unit)
```

* **add_subdirectory**

First download `CLove-Unit` repository and then point properly to it like this:

```cmake
cmake_minimum_required(VERSION 3.18)
project(TestProject C)

add_subdirectory(<PATH_TO_CLOVE_UNIT_REPOSITORY>)

add_executable(tests <YOUR_TEST_FILES>)
target_link_libraries(tests clove-unit)
```

* **find_package**

First download `CLove-Unit` repository and then run cmake install command on it.

Package will be installed in at following path: `<CMAKE_INSTALL_PREFIX>/clove-unit/<CLOVE_VERSION>`

Eventually you may want to customize [CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) variable to override cmake default installation path for packages.


Then use the package as follow:
```cmake
cmake_minimum_required(VERSION 3.18)
project(TestProject C)

find_package(clove-unit REQUIRED PATHS <INSTALLATION_PATH>)

# or more strict
# find_package(clove-unit <CLOVE_VERSION> EXACT REQUIRED PATHS <INSTALLATION_PATH>)

add_executable(tests <YOUR_TEST_FILES>)
target_link_libraries(tests clove-unit)
```

## How It Works

Expand Down Expand Up @@ -236,10 +313,10 @@ Assertions that can be used within a `CLOVE_TEST` definition.

Helper APIs to support test implementation.

| API | Description |
|--------------------------|------------------------------------------------------------|
| `CLOVE_EXEC_PATH()` | Macro to easily retrieve executable path as a `char*` |
| `CLOVE_EXEC_BASE_PATH()` | Macro to easily retrieve executable base path as a `char*` |
| API | Description |
|--------------------------|---------------------------------------------------------------------------|
| `CLOVE_EXEC_PATH()` | Macro to easily retrieve executable absolute path as a `const char*` |
| `CLOVE_EXEC_BASE_PATH()` | Macro to easily retrieve executable absolute base path as a `const char*` |

## Command-Line API

Expand Down
Loading