Skip to content
Open
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
30 changes: 15 additions & 15 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ version: "{build}"

environment:
matrix:
- ARCHITECTURE: x64
MSVC_VER: 14
- ARCHITECTURE: x86
MSVC_VER: 14
- ARCHITECTURE: x64
MSVC_VER: 12
- ARCHITECTURE: x86
MSVC_VER: 12
- ARCHITECTURE: x86
MSVC_VER: 11
- ARCHITECTURE: x86
MSVC_VER: 10
- ARCHITECTURE: x86
MSVC_VER: 9
- ARCHITECTURE: x64
MSVC_VER: 14
- ARCHITECTURE: x86
MSVC_VER: 14
- ARCHITECTURE: x64
MSVC_VER: 12
- ARCHITECTURE: x86
MSVC_VER: 12
- ARCHITECTURE: x86
MSVC_VER: 11
- ARCHITECTURE: x86
MSVC_VER: 10
- ARCHITECTURE: x86
MSVC_VER: 9

branches:
except:
Expand All @@ -29,6 +29,6 @@ install:
before_build:
- call "C:\Program Files (x86)\Microsoft Visual Studio %MSVC_VER%.0\VC\vcvarsall.bat" %ARCHITECTURE%

build_script: cl.exe /W4 /WX /Feexample munit.c example.c
build_script: cl.exe /W4 /WX /Feexample /I .\ munit.c example.c

test_script: example.exe --color always
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
/example
/*.exe
/*.dll
build/
lib/
bin/
.DS_Store
67 changes: 67 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.7...3.18)

if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

project("munit" VERSION 0.2.0
DESCRIPTION "µnit Testing Library for C"
LANGUAGES C
)

# Options
option(BUILD_SHARED_LIBS "Build shared library" ON)
option(BUILD_STATIC_LIBS "Build static library" ON)
option(BUILD_EXAMPLE "Build example program" OFF)

if(NOT(${BUILD_SHARED_LIBS} OR ${BUILD_STATIC_LIBS}))
message(FATAL_ERROR "Error: At least one of the static library and the shared library must be built.")
endif()

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
configure_file(munit.pc.in ${CMAKE_SOURCE_DIR}/lib/pkgconfig/munit.pc @ONLY)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -Wpedantic")
set(CMAKE_BUILD_TYPE Release)

add_library(munit_mod MODULE)
target_sources(munit_mod PRIVATE munit.c)
target_include_directories(munit_mod PRIVATE ./)

if(${BUILD_SHARED_LIBS})
add_library(munit SHARED $<TARGET_OBJECTS:munit_mod>)
target_include_directories(munit PUBLIC ./)
set_target_properties(munit PROPERTIES OUTPUT_NAME "munit")
endif()

if(${BUILD_STATIC_LIBS})
add_library(munit_static STATIC $<TARGET_OBJECTS:munit_mod>)
target_include_directories(munit_static PUBLIC ./)
set_target_properties(munit_static PROPERTIES OUTPUT_NAME "munit")
install(TARGETS munit_static ARCHIVE)
endif()

if(${BUILD_EXAMPLE})
add_executable(munit_example)
target_sources(munit_example PRIVATE example.c)
if(${BUILD_STATIC_LIBS})
target_link_libraries(munit_example munit_static)
else()
target_link_libraries(munit_example munit)
endif()
endif()

# Installation
install(FILES ${CMAKE_SOURCE_DIR}/lib/pkgconfig/munit.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
install(FILES munit.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)

if(${BUILD_SHARED_LIBS})
install(TARGETS munit LIBRARY)
endif()

if(${BUILD_STATIC_LIBS})
install(TARGETS munit_static LIBRARY)
endif()
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ ifneq ($(CC),pgcc)
endif
endif

example$(EXTENSION): munit.h munit.c example.c
$(CC) $(CFLAGS) -o $@ munit.c example.c
example$(EXTENSION):
$(CC) $(CFLAGS) -o $@ -I ./ munit.c example.c

test:
$(TEST_ENV) ./example$(EXTENSION)
Expand Down
58 changes: 33 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# µnit

µnit is a small but full-featured unit testing framework for C. It has
no dependencies (beyond libc), is permissively licensed (MIT), and is
easy to include into any project.
µnit is a small but full-featured unit testing framework for C. It has no dependencies (beyond libc), is permissively licensed (MIT), and is easy to include into any project.

For more information, see
[the µnit web site](https://nemequ.github.io/munit).
For more information, see [the µnit web site](https://nemequ.github.io/munit).

[![Build status](https://travis-ci.org/nemequ/munit.svg?branch=master)](https://travis-ci.org/nemequ/munit)
[![Windows build status](https://ci.appveyor.com/api/projects/status/db515g5ifcwjohq7/branch/master?svg=true)](https://ci.appveyor.com/project/quixdb/munit/branch/master)
Expand All @@ -14,24 +11,20 @@ For more information, see

Features µnit currently includes include:

* Handy assertion macros which make for nice error messages.
* Reproducible cross-platform random number generation, including
support for supplying a seed via CLI.
* Timing of both wall-clock and CPU time.
* Parameterized tests.
* Nested test suites.
* Flexible CLI.
* Forking
([except on Windows](https://github.com/nemequ/munit/issues/2)).
* Hiding output of successful tests.
- Handy assertion macros which make for nice error messages.
- Reproducible cross-platform random number generation, including support for supplying a seed via CLI.
- Timing of both wall-clock and CPU time.
- Parameterized tests.
- Nested test suites.
- Flexible CLI.
- Forking ([except on Windows](https://github.com/nemequ/munit/issues/2)).
- Hiding output of successful tests.

Features µnit does not currently include, but some day may include
(a.k.a., if you file a PR…), include:
Features µnit does not currently include, but some day may include (a.k.a., if you file a PR…), include:

* [TAP](http://testanything.org/) support; feel free to discuss in
[issue #1](https://github.com/nemequ/munit/issues/1)
- [TAP](http://testanything.org/) support; feel free to discuss in [issue #1](https://github.com/nemequ/munit/issues/1)

### Include into your project with meson
### Integrate µnit into your project with meson

In your `subprojects` folder put a `munit.wrap` file containing:

Expand All @@ -42,13 +35,28 @@ url=https://github.com/nemequ/munit/
revision=head
```

Then you can use a subproject fallback when you include munit as a
dependency to your project: `dependency('munit', fallback: ['munit', 'munit_dep'])`
Then you can use a subproject fallback when you include munit as a dependency to your project: `dependency('munit', fallback: ['munit', 'munit_dep'])`

### Integrate µnit into your project with CMake

You can include µnit as a git submodule and this will expose a `munit` target which can be linked to in your project. Assuming your project is located at `$PROJECT_ROOT`, first add µnit as a submodule:

```
cd $PROJECT_ROOT
mkdir extern && cd extern
> git submodule add https://github.com/nemequ/munit
```

Then, in your `CMakeLists.txt` file (again, assumed to be located in `$PROJECT_ROOT`), add the following line:

```
add_subdirectory(${CMAKE_SOURCE_DIR}/extern/munit)
```

and this will expose the `munit` and `munit_static` targets, which can be linked against in your project with `target_link_libraries`. These targets also have the relevant header file embedded within them.

## Documentation

See [the µnit web site](https://nemequ.github.io/munit).

Additionally, there is a heavily-commented
[example.c](https://github.com/nemequ/munit/blob/master/example.c) in
the repository.
Additionally, there is a heavily-commented [example.c](https://github.com/nemequ/munit/blob/master/example.c) in the repository.
5 changes: 2 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
project('munit', 'c')
project('munit', 'c', default_options : ['c_std=c99'])

conf_data = configuration_data()
conf_data.set('version', '0.2.0')

add_project_arguments('-std=c99', language : 'c')

cc = meson.get_compiler('c')

root_include = include_directories('.')

munit = library('munit',
['munit.c'],
include_directories: root_include,
install: meson.is_subproject())

if meson.is_subproject()
Expand Down
9 changes: 9 additions & 0 deletions munit.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib
includedir=${prefix}/include

Name: munit
Description: µnit Testing Library for C
Version: 0.4.1
Libs: -L${libdir} -lmunit
Cflags: -I${includedir}