contrib: Added autotools skeleton

This commit is contained in:
Snaipe 2016-09-24 00:39:35 +02:00
parent 12691f094c
commit 2d6959d777
6 changed files with 84 additions and 0 deletions

View File

@ -78,6 +78,7 @@ Sample tests can be found in the [sample directory][samples].
### Misc
* [autotools skeleton for projects with criterion tests][autotools]
* [CMake find module for Criterion][find-module]
## Credits
@ -97,6 +98,7 @@ Logo made by [Paul Bouigue](http://www.cargocollective.com/pbouigue)
[sample-signal]: ./samples/signal.c
[sample-report]: ./samples/report.c
[autotools]: ./dev/autotools
[find-module]: ./dev/FindCriterion.cmake
[irc-chan]: http://webchat.freenode.net/?channels=%23criterion&uio=MTY9dHJ1ZSYyPXRydWUmOT10cnVlJjExPTE5NQ4e

14
dev/autotools/Makefile.am Normal file
View File

@ -0,0 +1,14 @@
# use the provided wrapper script to output things properly
LOG_COMPILER = $(top_srcdir)/build-aux/criterion-tap-test
# use the TAP log driver
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
check_PROGRAMS = criterion_tests
criterion_tests_SOURCES = simple.c
criterion_tests_LDFLAGS = -lcriterion
TESTS = criterion_tests
EXTRA_DIST = $(TESTS)

27
dev/autotools/README.md Normal file
View File

@ -0,0 +1,27 @@
# Autotools skeleton
This is a project skeleton that uses criterion tests with the TAP test driver.
## Running the tests
The default setup assumes that criterion is installed on your system.
```
$ ./autogen.sh
$ mkdir build && cd build
$ ../configure
$ make check
```
## License
The project skeleton is licensed under the [wtfpl](http://www.wtfpl.net). Do
whatever you want with it.
### License clause
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://www.wtfpl.net/ for more details.

17
dev/autotools/autogen.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh -e
# copy TAP driver into build-aux
automake_ver=$(automake --version | \grep -E -o '[0-9]\.[0-9]{2}')
mkdir -p build-aux
cp -f /usr/share/automake-$automake_ver/tap-driver.sh build-aux
# create criterion TAP log compiler
# this is necessary to print TAP (and only TAP) on the standard output,
# and always exit with 0 to let the TAP driver handle errors itself.
echo >build-aux/criterion-tap-test """#!/bin/sh
\$1 -Otap:- --always-succeed 2>&1 >/dev/null
"""
chmod +x build-aux/criterion-tap-test
autoreconf -vi

View File

@ -0,0 +1,15 @@
AC_INIT([Criterion Autotools Tests], [1.0], [your@email.com])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CHECK_LIB([criterion], [criterion_initialize], [], [
AC_MSG_ERROR([unable to find Criterion])
], [])
AC_PROG_AWK
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT

9
dev/autotools/simple.c Normal file
View File

@ -0,0 +1,9 @@
#include <criterion/criterion.h>
Test(misc, failing) {
cr_assert(0);
}
Test(misc, passing) {
cr_assert(1);
}