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

Feature: User-defined dataset driven tests #43

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
53af4bd
Updated readme download links to include msvc & mingw builds
Snaipe Sep 14, 2015
a18934e
Removed unused includes in redirect.cc sample
Snaipe Sep 14, 2015
3a2fe96
Added file mocking utility
Snaipe Sep 15, 2015
d58fc15
Fixed documentation on report hook parameters
Snaipe Sep 15, 2015
af835bb
Added conditional GCC5 test for file mocking
Snaipe Sep 15, 2015
697c165
Changed the timeout type to double
Snaipe Sep 15, 2015
8688a5d
Fixed MinGW header bug where off_t/off64_t is not defined
Snaipe Sep 15, 2015
ce16e84
Added missing <string> include in redirect unit test
Snaipe Sep 15, 2015
9690963
Fixed coverage not being reported for all samples
Snaipe Sep 15, 2015
41edcfc
Trying out codecov.io
Snaipe Sep 4, 2015
3aaabf1
Restored appveyor support for coverage
Snaipe Sep 4, 2015
e704c07
Removed dependencies from coverage report
Snaipe Sep 4, 2015
d4d29f6
Added manual gcov target
Snaipe Sep 4, 2015
6faf505
Specified correct gcov params for codecov script
Snaipe Sep 4, 2015
01ead0a
Switched readme coverage status to codecov
Snaipe Sep 4, 2015
45045b3
Removed coverage on appveyor builds
Snaipe Sep 15, 2015
8e8f038
Merge switch to codecov into bleeding
Snaipe Sep 15, 2015
2a1ad13
Cleaned up CI configs
Snaipe Sep 15, 2015
548a3d6
Added coverage reports for all current tests
Snaipe Sep 15, 2015
29dcad0
Added short-circuit for cr_file_match_file
Snaipe Sep 16, 2015
8ece784
Added file_match_file tests
Snaipe Sep 16, 2015
cbb8f4b
Added asprintf unit tests
Snaipe Sep 16, 2015
a1d28f8
Refactored posix-compat.c
Snaipe Sep 16, 2015
9b083a1
Refactored most of the sources
Snaipe Sep 16, 2015
53f73ff
Added missing headers
Snaipe Sep 16, 2015
ddc68c2
Exposed pipe internals for windows fork
Snaipe Sep 16, 2015
b4fcf3d
asprintf should return a value less than 0 on error
Snaipe Sep 16, 2015
a9232f5
Added missing headers in windows build
Snaipe Sep 16, 2015
c799927
Made the invalid asprintf test conditional
Snaipe Sep 16, 2015
bf2bd1f
Merge branch 'refactor' into bleeding
Snaipe Sep 16, 2015
923d866
Updated contribution road map
Snaipe Sep 16, 2015
75b9e7d
Changed the worker waiting code to be event-driven
Snaipe Sep 17, 2015
0850658
Changed the windows worker waiting code as well
Snaipe Sep 17, 2015
e011939
Fixed OSX not registering the sigchld handler
Snaipe Sep 17, 2015
ab9763c
Fixed windows async worker termination reporting
Snaipe Sep 17, 2015
864b600
Merge branch 'features/async-io' into bleeding
Snaipe Sep 17, 2015
e5d846f
Added parameterized tests
Snaipe Sep 17, 2015
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
26 changes: 26 additions & 0 deletions .cmake/Modules/Gcov.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

if (NOT DEFINED ENV{GCOV})
find_program(GCOV_EXECUTABLE gcov)
else()
find_program(GCOV_EXECUTABLE $ENV{GCOV})
endif()

#file(GLOB_RECURSE GCNO_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.gcno")
if (WIN32)
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}\\*.gcda")
else ()
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}/*.gcda")
endif ()

#execute_process(
# COMMAND ${GCOV_EXECUTABLE} -lcp ${GCNO_FILES}
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
#)

foreach (GCDA ${GCDA_FILES})
get_filename_component(DIR ${GCDA} PATH)
execute_process(
COMMAND ${GCOV_EXECUTABLE} -lcp -o ${DIR} ${GCDA}
WORKING_DIRECTORY ${COV_PATH}
)
endforeach ()
41 changes: 22 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,34 @@ addons:
packages:
- gcc-4.9
- g++-4.9
env:
GCOV: gcov-4.9
CXX: g++-4.9

before_install:
- export GCOV="gcov-4.9"
- export LOCAL_INSTALL="$HOME"
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib
- export CFLAGS="-g -O0"
- export CXX="g++-4.9"
script:
- mkdir -p build
- cd build
- cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$HOME -DCMAKE_INSTALL_PREFIX=criterion-${TRAVIS_TAG} ..
- make
- make criterion_tests
- make test
- mkdir -p build
- cd build
- >
cmake
-Wno-dev
-DCOVERALLS=ON
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=criterion-${TRAVIS_TAG}
..
- make
- make criterion_tests
- make test

after_success:
- make coveralls
- make gcov
- bash <(curl -s https://codecov.io/bash)

after_failure:
- cat Testing/Temporary/LastTest.log samples/*.{out,err} ../samples/tests/*.{out,err}
env:
global:
secure: bzZcWjdqoTgceC40kEBucx7NuWYJPk+rxgF3UJJDXi+ijQAFYPv70p5eVsGR6rfc+XgqXCxcUFQtuL4ZVt7QEfVk1ZOJITNeHbKIeKaEYS4nX8mFf+CBeEm9bJGZ04KiQJdJu5mzzAHvXbW7roGXDGWe1Bjnk5wwA+dNUCa7H04=
- cat Testing/Temporary/LastTest.log samples/*.{out,err} ../samples/tests/*.{out,err}

before_deploy:
- make install
- tar -cvjf criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2 criterion-${TRAVIS_TAG}
- make install
- tar -cvjf criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2 criterion-${TRAVIS_TAG}

deploy:
provider: releases
Expand Down
70 changes: 44 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,50 @@ find_package(PCRE)
# List sources and headers

set(SOURCE_FILES
src/abort.c
src/abort.h
src/event.c
src/event.h
src/report.c
src/report.h
src/runner.c
src/runner.h
src/process.c
src/process.h
src/stats.c
src/stats.h
src/core/abort.c
src/core/abort.h
src/core/report.c
src/core/report.h
src/core/runner.c
src/core/runner.h
src/core/worker.c
src/core/worker.h
src/core/stats.c
src/core/stats.h
src/core/ordered-set.c
src/core/theories.c
src/compat/internal.h
src/compat/pipe.c
src/compat/pipe.h
src/compat/section.c
src/compat/section.h
src/compat/process.c
src/compat/process.h
src/compat/basename.c
src/compat/basename.h
src/compat/mockfile.c
src/compat/time.c
src/compat/time.h
src/compat/posix.h
src/io/redirect.c
src/io/event.c
src/io/event.h
src/io/asprintf.c
src/io/file.c
src/log/logging.c
src/log/tap.c
src/log/normal.c
src/options.c
src/timer.c
src/timer.h
src/i18n.c
src/i18n.h
src/ordered-set.c
src/posix-compat.c
src/theories.c
src/asprintf.c
src/file.c
src/main.c
src/entry.c
src/string/i18n.c
src/string/i18n.h
src/entry/options.c
src/entry/main.c
src/entry/entry.c
)

if (PCRE_FOUND)
set (SOURCE_FILES ${SOURCE_FILES}
src/extmatch.c
src/extmatch.h
src/string/extmatch.c
src/string/extmatch.h
)
set(HAVE_PCRE 1)
endif ()
Expand Down Expand Up @@ -170,6 +181,13 @@ install(TARGETS criterion

add_custom_target(criterion_tests)

add_custom_target(gcov
"${CMAKE_COMMAND}"
-DSOURCE_FILES="${SOURCE_FILES}"
-DCOV_PATH="${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_MODULE_PATH}/Gcov.cmake"
)

enable_testing()
add_subdirectory(samples)
add_subdirectory(test)
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ be merged.
|- .cmake/: CMake modules
|- dependencies/: dependencies for building libcriterion
|- doc/: Sphinx documentation files
|- dev/: Developer files
|- include/criterion/: Public API
|- src/: Sources for libcriterion
| `- log/: Output providers, all the output logic in general
| |- compat/: Cross-platform abstractions for platform-dependent code
| |- core/: Core mechanisms used to run the tests
| |- entry/: Entry-point related sources, and default main function
| |- io/: IO related functions, redirections
| |- log/: Output providers, all the output logic in general
| `- string/: String manipulation functions, i18n
|- po/: Translation files, i18n stuff
|- test/: Unit tests for libcriterion
`- samples/: Sample files
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![Unix Build Status](https://travis-ci.org/Snaipe/Criterion.svg?branch=bleeding)](https://travis-ci.org/Snaipe/Criterion)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/Snaipe/Criterion?svg=true&branch=bleeding)](https://ci.appveyor.com/project/Snaipe/Criterion/branch/bleeding)
[![Coverage Status](https://coveralls.io/repos/Snaipe/Criterion/badge.svg?branch=bleeding)](https://coveralls.io/r/Snaipe/Criterion?branch=bleeding)
[![Coverage Status](https://img.shields.io/codecov/c/github/Snaipe/Criterion/bleeding.svg)](https://codecov.io/github/Snaipe/Criterion?branch=bleeding)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/Snaipe/Criterion/blob/master/LICENSE)
[![Version](https://img.shields.io/github/tag/Snaipe/Criterion.svg?label=version&style=flat)](https://github.com/Snaipe/Criterion/releases)

Expand Down Expand Up @@ -41,7 +41,8 @@ the user would have with other frameworks:

* [Linux (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.0.0/criterion-v2.0.0-linux-x86_64.tar.bz2)
* [OS X (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.0.0/criterion-v2.0.0-osx-x86_64.tar.bz2)
* [Windows (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.0.0/criterion-v2.0.0-windows-x86_64.tar.bz2)
* [Windows (MSVC - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.0.0/criterion-v2.0.0-windows-msvc-x86_64.tar.bz2)
* [Windows (MinGW - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.0.0/criterion-v2.0.0-windows-mingw-x86_64.tar.bz2)

If you have a different platform, you can still [build the library from source](http://criterion.readthedocs.org/en/latest/setup.html#installation)

Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ environment:
secure: 5nuCg+faxFPeppoNNcSwVobswAVFUf8ut83vw8CX/4W2y0kZkGmwEfCUxSQWiQDU
CI_NAME: appveyor
CI_JOB_ID: $(APPVEYOR_JOB_ID)
LOCAL_INSTALL: $(APPVEYOR_BUILD_FOLDER)
GCOV_PREFIX: $(APPVEYOR_BUILD_FOLDER)
matrix:
- COMPILER: mingw
Expand All @@ -36,7 +35,6 @@ install:
cmake
-Wno-dev
-DCMAKE_INSTALL_PREFIX="criterion-%RELEASE_NAME%"
-DCMAKE_PREFIX_PATH="%LOCAL_INSTALL%"
-G "%GENERATOR%"
..

Expand Down
11 changes: 2 additions & 9 deletions doc/hooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ The flow of the test process goes as follows:
Hook Parameters
---------------

A report hook may take zero or one parameter. If a parameter is given, it
is undefined behaviour if it is not a pointer type and not of the proper pointed
type for that phase.

A report hook takes exactly one parameter.
Valid types for each phases are:

* ``struct criterion_test_set *`` for ``PRE_ALL``.
Expand All @@ -56,17 +53,13 @@ Valid types for each phases are:
* ``struct criterion_suite_stats *`` for ``POST_SUITE``.
* ``struct criterion_global_stats *`` for ``POST_ALL``.

For instance, these are valid report hook declarations for the ``PRE_TEST`` phase:
For instance, this is a valid report hook declaration for the ``PRE_TEST`` phase:

.. code-block:: c

#include <criterion/criterion.h>
#include <criterion/hooks.h>

ReportHook(PRE_TEST)() {
// not using the parameter
}

ReportHook(PRE_TEST)(struct criterion_test *test) {
// using the parameter
}
2 changes: 2 additions & 0 deletions include/criterion/criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
TEST_PROTOTYPE_(Category, Name); \
struct criterion_test_extra_data IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.kind_ = CR_TEST_NORMAL, \
.param_ = (struct criterion_test_params(*)(void)) NULL, \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
Expand Down
48 changes: 48 additions & 0 deletions include/criterion/parameterized.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef CRITERION_PARAMETERIZED_H_
# define CRITERION_PARAMETERIZED_H_

# include "criterion.h"

# ifdef __cplusplus
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
extern "C" void IDENTIFIER_(Category, Name, impl)(Param)
# else
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
void IDENTIFIER_(Category, Name, impl)(Param)
# endif

# define ParameterizedTest(...) \
CR_EXPAND(ParameterizedTest_(__VA_ARGS__, .sentinel_ = 0))

# define ParameterizedTest_(Param, Category, Name, ...) \
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name); \
struct criterion_test_extra_data IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.kind_ = CR_TEST_PARAMETERIZED, \
.param_ = IDENTIFIER_(Category, Name, param), \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
SECTION_("cr_tst") \
struct criterion_test IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
(void(*)(void)) IDENTIFIER_(Category, Name, impl), \
&IDENTIFIER_(Category, Name, extra) \
} SECTION_SUFFIX_; \
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name)

# define ParameterizedTestParameters(Category, Name) \
static struct criterion_test_params IDENTIFIER_(Category, Name, param)(void)

# ifdef __cplusplus
# define cr_make_param_array(Type, Array, Length) \
criterion_test_params(sizeof (Type), (Array), (Length))
# else
# define cr_make_param_array(Type, Array, Length) \
(struct criterion_test_params) { sizeof (Type), (void**)(Array), (Length) }
# endif

#endif /* !CRITERION_PARAMETERIZED_H_ */
Loading