From 3869b864d30f00c94be4d17bffb011d6a7e1a2c3 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 5 Aug 2015 06:58:27 +0200 Subject: [PATCH 01/28] =?UTF-8?q?Bump=20version:=201.3.0=20=E2=86=92=201.3?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- CMakeLists.txt | 2 +- appveyor.yml | 2 +- doc/conf.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 654fcff..a3c3c42 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.3.0 +current_version = 1.3.1 commit = True [bumpversion:file:CMakeLists.txt] diff --git a/CMakeLists.txt b/CMakeLists.txt index da1994c..c6a1332 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(Criterion C) enable_testing() add_subdirectory(samples) -set(PROJECT_VERSION "1.3.0") +set(PROJECT_VERSION "1.3.1") set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale) set(GettextTranslate_ALL) set(GettextTranslate_GMO_BINARY) diff --git a/appveyor.yml b/appveyor.yml index ae1ca2b..8f1b935 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.3.0_b{build}-{branch} +version: 1.3.1_b{build}-{branch} os: Windows Server 2012 diff --git a/doc/conf.py b/doc/conf.py index 661351c..5636116 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -39,7 +39,7 @@ copyright = u'2015, Franklin "Snaipe" Mathieu' # built documents. # # The short X.Y version. -version = '1.3.0' +version = '1.3.1' # The full version, including alpha/beta/rc tags. release = version From 74467b7be8e20d00089bed862f3f943e4e97cf01 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 5 Aug 2015 09:45:54 +0200 Subject: [PATCH 02/28] Made -no-undefined windows only (fixes OSX compilation) --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6a1332..0d55509 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,10 @@ set(MODULE_DIR "${CMAKE_SOURCE_DIR}/.cmake/Modules") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined") + +if (WIN32) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined") +endif() # Setup coveralls From 371ffd54202f7403df758768eab03c36bcd20454 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 5 Aug 2015 10:08:41 +0200 Subject: [PATCH 03/28] Added another expansion round for DECL_SECTION_LIMITS, fixes OSX compilation --- include/criterion/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/criterion/common.h b/include/criterion/common.h index e5ebfd2..3a8d3a8 100644 --- a/include/criterion/common.h +++ b/include/criterion/common.h @@ -47,7 +47,8 @@ # define SECTION_START(Name) g_ ## Name ## _section_start # define SECTION_END(Name) g_ ## Name ## _section_end -# define DECL_SECTION_LIMITS(Type, Name) \ +# define DECL_SECTION_LIMITS(Type, Name) DECL_SECTION_LIMITS_(Type, Name) +# define DECL_SECTION_LIMITS_(Type, Name) \ extern Type SECTION_START_(Name) SECTION_START_SUFFIX(#Name); \ extern Type SECTION_END_(Name) SECTION_END_SUFFIX(#Name) From 8019f88ba5a6783b716d2f33fa2321bc019d9711 Mon Sep 17 00:00:00 2001 From: offa Date: Wed, 5 Aug 2015 13:24:57 +0200 Subject: [PATCH 04/28] Travis yml formated. --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 010eab6..dc05cba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,11 @@ before_install: - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib - export CFLAGS="-g -O0" script: -- mkdir -p build && cd $_ && cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$HOME .. && make && make test +- mkdir -p build +- cd $_ +- cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$HOME .. +- make +- make test after_success: - make coveralls after_failure: From e63221cb76f042b812806abaa1e69cd97246eb80 Mon Sep 17 00:00:00 2001 From: offa Date: Wed, 5 Aug 2015 13:26:13 +0200 Subject: [PATCH 05/28] Travis fix. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dc05cba..0d37183 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_install: - export CFLAGS="-g -O0" script: - mkdir -p build -- cd $_ +- cd build - cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$HOME .. - make - make test From de0a0857c701eeedd308408a68b93af9dc77e957 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 5 Aug 2015 13:13:25 +0200 Subject: [PATCH 06/28] Fixed gettext translations not being registered & updated french translation --- CMakeLists.txt | 4 ++-- po/Makevars | 4 ++-- po/fr.po | 60 +++++++++++++++++++++++++++++------------------- src/log/normal.c | 54 +++++++++++++++++++++++-------------------- 4 files changed, 69 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d55509..5b8ad20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ add_subdirectory(samples) set(PROJECT_VERSION "1.3.1") set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale) -set(GettextTranslate_ALL) -set(GettextTranslate_GMO_BINARY) +set(GettextTranslate_ALL 1) +set(GettextTranslate_GMO_BINARY 1) set(MODULE_DIR "${CMAKE_SOURCE_DIR}/.cmake/Modules") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR}) diff --git a/po/Makevars b/po/Makevars index 036417c..81da661 100644 --- a/po/Makevars +++ b/po/Makevars @@ -8,7 +8,7 @@ subdir = po top_builddir = .. # These options get passed to xgettext. -XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=N_s:1,2 --keyword=_s:1,2 # This is the copyright holder that gets inserted into the header of the # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding @@ -41,7 +41,7 @@ PACKAGE_GNU = no # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. -MSGID_BUGS_ADDRESS = +MSGID_BUGS_ADDRESS = franklinmathieu+criterion@gmail.com # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. diff --git a/po/fr.po b/po/fr.po index 7727e40..af25ab8 100644 --- a/po/fr.po +++ b/po/fr.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: criterion 1.0.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-28 22:17+0200\n" +"Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n" +"POT-Creation-Date: 2015-08-05 11:37+0200\n" "PO-Revision-Date: 2015-04-03 17:58+0200\n" "Last-Translator: \n" "Language-Team: French\n" @@ -18,58 +18,54 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: src/log/normal.c:38 +#: src/log/normal.c:51 #, c-format msgid "Criterion v%s\n" msgstr "Criterion v%s\n" -#: src/log/normal.c:42 -#, c-format -msgid "%1$s::%2$s\n" -msgstr "%1$s::%2$s\n" - -#: src/log/normal.c:47 src/log/normal.c:121 +#: src/log/normal.c:52 #, c-format msgid " %s\n" msgstr " %s\n" -#: src/log/normal.c:76 +#: src/log/normal.c:55 src/log/normal.c:57 +#, c-format +msgid "%1$s::%2$s\n" +msgstr "%1$s::%2$s\n" + +#: src/log/normal.c:56 +#, fuzzy, c-format +msgid "%1$s::%2$s: (%3$3.2fs)\n" +msgstr "%1$s::%2$s: (%3$3.2fs)\n" + +#: src/log/normal.c:58 #, c-format msgid "%1$s::%2$s: Test is disabled\n" msgstr "%1$s::%2$s: Le test est désactivé\n" -#: src/log/normal.c:77 +#: src/log/normal.c:59 #, c-format msgid "%1$s::%2$s: Suite is disabled\n" msgstr "%1$s::%2$s: La suite est désactivée\n" -#: src/log/normal.c:94 -#, c-format -msgid "" -"%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s" -"%9$lu%10$s | Crashing: %11$s%12$lu%13$s %14$s\n" -msgstr "" -"%1$sSynthèse: Testés: %2$s%3$lu%4$s | Validés: %5$s%6$lu%7$s | Échoués: %8$s" -"%9$lu%10$s | Plantages: %11$s%12$lu%13$s %14$s\n" - -#: src/log/normal.c:115 +#: src/log/normal.c:60 #, c-format msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n" msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: Échec d'assertion: %7$s\n" -#: src/log/normal.c:128 +#: src/log/normal.c:61 #, c-format msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n" msgstr "" "%1$s%2$s%3$s:%4$s%5$u%6$s: Un signal inattendu a été reçu après cette " "ligne!\n" -#: src/log/normal.c:132 +#: src/log/normal.c:62 #, c-format msgid "%1$s::%2$s: CRASH!\n" msgstr "%1$s::%2$s: PLANTAGE!\n" -#: src/log/normal.c:139 +#: src/log/normal.c:63 #, fuzzy, c-format msgid "" "%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown." @@ -77,3 +73,19 @@ msgid "" msgstr "" "%1$sAttention! Le test `%2$s::%3$s` a planté pendant son initialisation ou " "sa finalisation.%4$s\n" + +#: src/log/normal.c:64 +#, c-format +msgid "Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n" +msgid_plural "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n" +msgstr[0] "Lancement de %1$s%2$lu%3$s test dans %4$s%5$s%6$s:\n" +msgstr[1] "Lancement de %1$s%2$lu%3$s tests dans %4$s%5$s%6$s:\n" + +#: src/log/normal.c:66 +#, c-format +msgid "" +"%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s" +"%9$lu%10$s | Crashing: %11$s%12$lu%13$s %14$s\n" +msgstr "" +"%1$sSynthèse: Testés: %2$s%3$lu%4$s | Validés: %5$s%6$lu%7$s | Échoués: %8$s" +"%9$lu%10$s | Plantages: %11$s%12$lu%13$s %14$s\n" diff --git a/src/log/normal.c b/src/log/normal.c index ff83888..c82bcbd 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -44,26 +44,30 @@ typedef const char *const msg_t; -static msg_t msg_pre_all = "Criterion v%s\n"; -static msg_t msg_desc = " %s\n"; +// Used to mark string for gettext +# define N_(Str) Str +# define N_s(Str, Pl) {Str, Pl} + +static msg_t msg_pre_all = N_("Criterion v%s\n"); +static msg_t msg_desc = N_(" %s\n"); #ifdef ENABLE_NLS -static msg_t msg_pre_init = "%1$s::%2$s\n"; -static msg_t msg_post_test_timed = "%1$s::%2$s: (%3$3.2fs)\n"; -static msg_t msg_post_test = "%1$s::%2$s\n"; -static msg_t msg_post_suite_test = "%1$s::%2$s: Test is disabled\n"; -static msg_t msg_post_suite_suite = "%1$s::%2$s: Suite is disabled\n"; -static msg_t msg_assert_fail = "%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n"; -static msg_t msg_test_crash_line = "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"; -static msg_t msg_test_crash = "%1$s::%2$s: CRASH!\n"; -static msg_t msg_test_other_crash = "%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown.%4$s\n"; -static msg_t msg_pre_suite = "Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n"; -static msg_t msg_pre_suite_pl = "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n"; -static msg_t msg_post_all = "%1$sSynthesis: Tested: %2$s%3$lu%4$s " - "| Passing: %5$s%6$lu%7$s " - "| Failing: %8$s%9$lu%10$s " - "| Crashing: %11$s%12$lu%13$s " - "%14$s\n"; +static msg_t msg_pre_init = N_("%1$s::%2$s\n"); +static msg_t msg_post_test_timed = N_("%1$s::%2$s: (%3$3.2fs)\n"); +static msg_t msg_post_test = N_("%1$s::%2$s\n"); +static msg_t msg_post_suite_test = N_("%1$s::%2$s: Test is disabled\n"); +static msg_t msg_post_suite_suite = N_("%1$s::%2$s: Suite is disabled\n"); +static msg_t msg_assert_fail = N_("%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n"); +static msg_t msg_test_crash_line = N_("%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"); +static msg_t msg_test_crash = N_("%1$s::%2$s: CRASH!\n"); +static msg_t msg_test_other_crash = N_("%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown.%4$s\n"); +static msg_t msg_pre_suite[] = N_s("Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n", + "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n"); +static msg_t msg_post_all = N_("%1$sSynthesis: Tested: %2$s%3$lu%4$s " + "| Passing: %5$s%6$lu%7$s " + "| Failing: %8$s%9$lu%10$s " + "| Crashing: %11$s%12$lu%13$s " + "%14$s\n"); #else static msg_t msg_pre_init = "%s::%s\n"; static msg_t msg_post_test_timed = "%s::%s: (%3.2fs)\n"; @@ -74,13 +78,13 @@ static msg_t msg_assert_fail = "%s%s%s:%s%d%s: Assertion failed: %s\n"; static msg_t msg_test_crash_line = "%s%s%s:%s%u%s: Unexpected signal caught below this line!\n"; static msg_t msg_test_crash = "%s::%s: CRASH!\n"; static msg_t msg_test_other_crash = "%sWarning! The test `%s::%s` crashed during its setup or teardown.%s\n"; -static msg_t msg_pre_suite = "Running %s%lu%s test from %s%s%s:\n"; -static msg_t msg_pre_suite_pl = "Running %s%lu%s tests from %s%s%s:\n"; +static msg_t msg_pre_suite[] = { "Running %s%lu%s test from %s%s%s:\n", + "Running %s%lu%s tests from %s%s%s:\n" }; static msg_t msg_post_all = "%sSynthesis: Tested: %s%lu%s " - "| Passing: %s%lu%s " - "| Failing: %s%lu%s " - "| Crashing: %s%lu%s " - "%s\n"; + "| Passing: %s%lu%s " + "| Failing: %s%lu%s " + "| Crashing: %s%lu%s " + "%s\n"; #endif void normal_log_pre_all(UNUSED struct criterion_test_set *set) { @@ -194,7 +198,7 @@ void normal_log_other_crash(UNUSED struct criterion_test_stats *stats) { void normal_log_pre_suite(struct criterion_suite_set *set) { criterion_pinfo(CRITERION_PREFIX_EQUALS, - _s(msg_pre_suite, msg_pre_suite_pl, set->tests->size), + _s(msg_pre_suite[0], msg_pre_suite[1], set->tests->size), FG_BLUE, (unsigned long) set->tests->size, RESET, FG_GOLD, set->suite.name, RESET); } From 4d60e8ad91899a21f89492b44cd4633819b3430e Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 5 Aug 2015 17:20:59 +0200 Subject: [PATCH 07/28] Added missing license headers --- include/criterion/criterion.h | 23 +++++++++++++++++++++++ src/extmatch.c | 23 +++++++++++++++++++++++ src/extmatch.h | 23 +++++++++++++++++++++++ src/posix-compat.c | 23 +++++++++++++++++++++++ src/posix-compat.h | 23 +++++++++++++++++++++++ 5 files changed, 115 insertions(+) diff --git a/include/criterion/criterion.h b/include/criterion/criterion.h index 50c85b2..c26ad26 100644 --- a/include/criterion/criterion.h +++ b/include/criterion/criterion.h @@ -1,3 +1,26 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2015 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ #ifndef CRITERION_H_ # define CRITERION_H_ diff --git a/src/extmatch.c b/src/extmatch.c index 205a148..604d418 100644 --- a/src/extmatch.c +++ b/src/extmatch.c @@ -1,3 +1,26 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2015 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ #include #include #include diff --git a/src/extmatch.h b/src/extmatch.h index d65eeb1..8fe4974 100644 --- a/src/extmatch.h +++ b/src/extmatch.h @@ -1,3 +1,26 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2015 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ #ifndef EXTMATCH_H_ # define EXTMATCH_H_ diff --git a/src/posix-compat.c b/src/posix-compat.c index 72afb91..2056baa 100644 --- a/src/posix-compat.c +++ b/src/posix-compat.c @@ -1,3 +1,26 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2015 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ #include #include "posix-compat.h" #include "process.h" diff --git a/src/posix-compat.h b/src/posix-compat.h index 0ee7a57..e4b8d5e 100644 --- a/src/posix-compat.h +++ b/src/posix-compat.h @@ -1,3 +1,26 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2015 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ #ifndef POSIX_COMPAT_H_ # define POSIX_COMPAT_H_ From d47fc482571917e262082132529e06a072df613a Mon Sep 17 00:00:00 2001 From: Snaipe Date: Fri, 7 Aug 2015 13:56:12 +0200 Subject: [PATCH 08/28] Added osx CI job --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0d37183..8f237a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ language: c +os: +- linux +- osx compiler: - gcc sudo: false From eba6c030e3293c70dc7b0c8924ce8a609e3f1c9f Mon Sep 17 00:00:00 2001 From: Snaipe Date: Fri, 7 Aug 2015 14:15:43 +0200 Subject: [PATCH 09/28] Removed packages from travis config as they are either already installed or unused --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f237a1..c6d393f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,6 @@ os: compiler: - gcc sudo: false -addons: - apt: - packages: - - check - - gettext - - cmake before_install: - export LOCAL_INSTALL="$HOME" - ".ci/install-libcsptr.sh" From 799f46a3e38bbfa28fb0bc47ef73b63fa40c421f Mon Sep 17 00:00:00 2001 From: Snaipe Date: Fri, 7 Aug 2015 19:49:04 -0700 Subject: [PATCH 10/28] [Issue #30] Added special accessors for section limits on OS X --- src/posix-compat.c | 27 +++++++++++++++++++++++++++ src/posix-compat.h | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/src/posix-compat.c b/src/posix-compat.c index 2056baa..037a0aa 100644 --- a/src/posix-compat.c +++ b/src/posix-compat.c @@ -360,3 +360,30 @@ void *get_win_section_end(const char *section) { return NULL; } #endif + +#ifdef __APPLE__ +# include +# include + +# define BASE_IMAGE_INDEX 0 + +static inline void *get_real_address(void *addr) { + if (!addr) + return NULL; + + // We need to slide the section address to get a valid pointer + // because ASLR will shift the image by a random offset + return addr + _dyld_get_image_vmaddr_slide(BASE_IMAGE_INDEX); +} + +void *get_osx_section_start(const char *section) { + unsigned long secsize; + return get_real_address(getsectdata("__DATA", section, &secsize)); +} + +void *get_osx_section_end(const char *section) { + unsigned long secsize; + char *section_start = getsectdata("__DATA", section, &secsize); + return get_real_address(section_start) + secsize; +} +#endif diff --git a/src/posix-compat.h b/src/posix-compat.h index e4b8d5e..82da12c 100644 --- a/src/posix-compat.h +++ b/src/posix-compat.h @@ -81,6 +81,11 @@ void *get_win_section_start(const char *section); void *get_win_section_end(const char *section); # define GET_SECTION_START(Name) get_win_section_start(#Name) # define GET_SECTION_END(Name) get_win_section_end(#Name) +# elif defined(__APPLE__) +void *get_osx_section_start(const char *section); +void *get_osx_section_end(const char *section); +# define GET_SECTION_START(Name) get_osx_section_start(#Name) +# define GET_SECTION_END(Name) get_osx_section_end(#Name) # else # define GET_SECTION_START(Name) SECTION_START(Name) # define GET_SECTION_END(Name) SECTION_END(Name) From efb2587da50a6e577a1139d0431058d276900674 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Fri, 7 Aug 2015 21:40:00 -0700 Subject: [PATCH 11/28] Added macro expansion round before stringification for GET_SECTION_START/STOP. This fixes report hooks not working for Windows and OSX --- src/posix-compat.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/posix-compat.h b/src/posix-compat.h index 82da12c..fa4f87d 100644 --- a/src/posix-compat.h +++ b/src/posix-compat.h @@ -79,13 +79,17 @@ bool is_current_process(s_proc_handle *proc); # ifdef VANILLA_WIN32 void *get_win_section_start(const char *section); void *get_win_section_end(const char *section); -# define GET_SECTION_START(Name) get_win_section_start(#Name) -# define GET_SECTION_END(Name) get_win_section_end(#Name) +# define CR_STRINGIFY_(Param) #Param +# define CR_STRINGIFY(Param) CR_STRINGIFY_(Param) +# define GET_SECTION_START(Name) get_win_section_start(CR_STRINGIFY(Name)) +# define GET_SECTION_END(Name) get_win_section_end(CR_STRINGIFY(Name)) # elif defined(__APPLE__) void *get_osx_section_start(const char *section); void *get_osx_section_end(const char *section); -# define GET_SECTION_START(Name) get_osx_section_start(#Name) -# define GET_SECTION_END(Name) get_osx_section_end(#Name) +# define CR_STRINGIFY_(Param) #Param +# define CR_STRINGIFY(Param) CR_STRINGIFY_(Param) +# define GET_SECTION_START(Name) get_osx_section_start(CR_STRINGIFY(Name)) +# define GET_SECTION_END(Name) get_osx_section_end(CR_STRINGIFY(Name)) # else # define GET_SECTION_START(Name) SECTION_START(Name) # define GET_SECTION_END(Name) SECTION_END(Name) From 5550801a2edaa71c785d866f67a80db8ba4df106 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 19 Aug 2015 23:30:42 +0200 Subject: [PATCH 12/28] Added automatic release to tagged travis builds --- .travis.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6d393f..eabcb44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_install: script: - mkdir -p build - cd build -- cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$HOME .. +- cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$HOME -DCMAKE_INSTALL_PREFIX=criterion-${TRAVIS_TAG} .. - make - make test after_success: @@ -23,3 +23,17 @@ after_failure: env: global: secure: bzZcWjdqoTgceC40kEBucx7NuWYJPk+rxgF3UJJDXi+ijQAFYPv70p5eVsGR6rfc+XgqXCxcUFQtuL4ZVt7QEfVk1ZOJITNeHbKIeKaEYS4nX8mFf+CBeEm9bJGZ04KiQJdJu5mzzAHvXbW7roGXDGWe1Bjnk5wwA+dNUCa7H04= + +before_deploy: +- make install +- tar -cvjf criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2 criterion-${TRAVIS_TAG} + +deploy: + provider: releases + skip_cleanup: true + api_key: + secure: d3l2Ohb2FF3tSXku1d0ASR5dntdnQ48Jyc39IEloDBxFXCselCkYruUQv6p0TA3P+Dmrz4wS7/AFlBMMsQ3XfGFVIOnITiTaGWg5fEpIf7zYsDf0zECPE0MOHMGqJMn3/SrSKdtEA4N84Q4JS7Ou+ewG65mxUDO5Ce60OoEG5JA= + file: criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2 + on: + repo: Snaipe/Criterion + tags: true From d052330c21d2daccbad0bb5eff1357bc364a8bb6 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 19 Aug 2015 17:48:08 -0700 Subject: [PATCH 13/28] Force usage of get_win_section_{start,stop} on cygwin --- src/posix-compat.c | 2 +- src/posix-compat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posix-compat.c b/src/posix-compat.c index 037a0aa..4cb7a28 100644 --- a/src/posix-compat.c +++ b/src/posix-compat.c @@ -327,7 +327,7 @@ bool is_current_process(s_proc_handle *proc) { #endif } -#ifdef VANILLA_WIN32 +#ifdef _WIN32 void *get_win_section_start(const char *section) { PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER) GetModuleHandle(NULL); PIMAGE_NT_HEADERS ntHeader = ntHeader = (PIMAGE_NT_HEADERS) ((DWORD)(dosHeader) + (dosHeader->e_lfanew)); diff --git a/src/posix-compat.h b/src/posix-compat.h index fa4f87d..84a5aef 100644 --- a/src/posix-compat.h +++ b/src/posix-compat.h @@ -76,7 +76,7 @@ void wait_process(s_proc_handle *handle, int *status); s_proc_handle *get_current_process(); bool is_current_process(s_proc_handle *proc); -# ifdef VANILLA_WIN32 +# ifdef _WIN32 void *get_win_section_start(const char *section); void *get_win_section_end(const char *section); # define CR_STRINGIFY_(Param) #Param From a6a6c4c79f492ccfb845692448f32b3977d6089f Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 19 Aug 2015 17:48:41 -0700 Subject: [PATCH 14/28] Fixed crashes on invalid report hooks --- src/report.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/report.c b/src/report.c index 8f8bf39..64a6861 100644 --- a/src/report.c +++ b/src/report.c @@ -33,13 +33,15 @@ #include "config.h" #include "posix-compat.h" +static inline void nothing() {} + #define IMPL_CALL_REPORT_HOOKS(Kind) \ IMPL_SECTION_LIMITS(f_report_hook, HOOK_SECTION(Kind)); \ void call_report_hooks_##Kind(void *data) { \ for (f_report_hook *hook = GET_SECTION_START(HOOK_SECTION(Kind)); \ hook < (f_report_hook*) GET_SECTION_END(HOOK_SECTION(Kind)); \ ++hook) { \ - (*hook)(data); \ + (*hook ?: nothing)(data); \ } \ } From 49e94f5b88b1e9933fd094b947054006ef0e7049 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 03:12:00 +0200 Subject: [PATCH 15/28] Added appveyor deployment --- appveyor.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 8f1b935..75cb592 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,7 @@ install: - 'set LOCAL_INSTALL=%APPVEYOR_BUILD_FOLDER%' - 'bash -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 Date: Thu, 20 Aug 2015 05:45:55 +0200 Subject: [PATCH 16/28] Removed FreeBSD downloads until we get a FreeBSD CI service --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ac6f1e7..7c547c4 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ the user would have with other frameworks: * [Linux (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v1.3.0/criterion-1.3.0-linux-x86_64.tar.bz2) * [OS X (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v1.3.0/criterion-1.3.0-osx-x86_64.tar.bz2) -* [FreeBSD (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v1.3.0/criterion-1.3.0-freebsd-x86_64.tar.bz2) * [Windows (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v1.3.0/criterion-1.3.0-windows-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) From 9fd4dc3dd5c74dc1a470186eac1d783c88a58e07 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 05:52:52 +0200 Subject: [PATCH 17/28] Cleaned up appveyor build config --- appveyor.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 75cb592..11aede3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,13 +23,18 @@ configuration: Release install: - 'set GCOV_PREFIX=%APPVEYOR_BUILD_FOLDER%' - 'set LOCAL_INSTALL=%APPVEYOR_BUILD_FOLDER%' - - 'bash -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 Date: Thu, 20 Aug 2015 06:14:29 +0200 Subject: [PATCH 18/28] Cleaned up environment variables and added coveralls service name --- .cmake/Modules/CoverallsGenerateGcov.cmake | 13 +++++++++++-- appveyor.yml | 14 +++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.cmake/Modules/CoverallsGenerateGcov.cmake b/.cmake/Modules/CoverallsGenerateGcov.cmake index 429b695..b923f6e 100644 --- a/.cmake/Modules/CoverallsGenerateGcov.cmake +++ b/.cmake/Modules/CoverallsGenerateGcov.cmake @@ -268,8 +268,17 @@ foreach (GCOV_FILE ${ALL_GCOV_FILES}) endforeach() # TODO: Enable setting these -set(JSON_SERVICE_NAME "travis-ci") -set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID}) +if (NOT DEFINED ENV{CI_NAME}) + set(JSON_SERVICE_NAME "travis-ci") +else () + set(JSON_SERVICE_NAME $ENV{CI_NAME}) +endif() + +if (NOT DEFINED ENV{CI_JOB_ID}) + set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID}) +else () + set(JSON_SERVICE_JOB_ID $ENV{CI_JOB_ID}) +endif() set(JSON_REPO_TOKEN $ENV{COVERALLS_REPO_TOKEN}) set(JSON_TEMPLATE diff --git a/appveyor.yml b/appveyor.yml index 11aede3..666279c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,6 +9,10 @@ init: environment: COVERALLS_REPO_TOKEN: secure: 5nuCg+faxFPeppoNNcSwVobswAVFUf8ut83vw8CX/4W2y0kZkGmwEfCUxSQWiQDU + CI_NAME: appveyor + CI_JOB_ID: $(APPVEYOR_JOB_ID) + LOCAL_INSTALL: $(APPVEYOR_BUILD_FOLDER) + GCOV_PREFIX: $(APPVEYOR_BUILD_FOLDER) clone_depth: 5 @@ -21,10 +25,14 @@ platform: configuration: Release install: - - 'set GCOV_PREFIX=%APPVEYOR_BUILD_FOLDER%' - - 'set LOCAL_INSTALL=%APPVEYOR_BUILD_FOLDER%' + # Hack to make git think it is on the tip of the repo branch + - 'git checkout %APPVEYOR_REPO_BRANCH%' + - 'git reset --hard %APPVEYOR_REPO_COMMIT%' + # Install libcsptr - 'bash -lc "cd $APPVEYOR_BUILD_FOLDER; .ci/install-libcsptr.sh -G \"MSYS Makefiles\"; true"' + # We need to manually make since the above command somehow crashes - 'cd dependencies/libcsptr/build && make && make install && cd ../../../' + # Configure project - 'mkdir build && cd build' - 'cmake -DCMAKE_INSTALL_PREFIX=criterion-%APPVEYOR_REPO_TAG_NAME% -DCMAKE_PREFIX_PATH="%LOCAL_INSTALL%" -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles" ..' @@ -33,7 +41,7 @@ build_script: after_build: - 'make install' - - 'bash -lc "cd $APPVEYOR_BUILD_FOLDER; tar -cvjf criterion-${APPVEYOR_REPO_TAG_NAME}-windows-${PLATFORM}.tar.bz2 -C build criterion-${APPVEYOR_REPO_TAG_NAME}"' + - 'bash -lc "cd $APPVEYOR_BUILD_FOLDER; tar -cvjf criterion-${APPVEYOR_REPO_BRANCH}-windows-${PLATFORM}.tar.bz2 -C build criterion-${APPVEYOR_REPO_TAG_NAME}"' test_script: - 'make test || bash -lc "cat $APPVEYOR_BUILD_FOLDER/build/Testing/Temporary/LastTest.log"' From 5f8fcbc56b79895dd4c1f4f190b1f1dace0357c8 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 06:30:23 +0200 Subject: [PATCH 19/28] Changed ugly git reset --hard to git checkout -B --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 666279c..ab04df5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,8 +26,7 @@ configuration: Release install: # Hack to make git think it is on the tip of the repo branch - - 'git checkout %APPVEYOR_REPO_BRANCH%' - - 'git reset --hard %APPVEYOR_REPO_COMMIT%' + - 'git checkout -B %APPVEYOR_REPO_BRANCH%' # Install libcsptr - 'bash -lc "cd $APPVEYOR_BUILD_FOLDER; .ci/install-libcsptr.sh -G \"MSYS Makefiles\"; true"' # We need to manually make since the above command somehow crashes From 60e84a48fed8f65e39ca75de7c5b26b6f6d77073 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 06:37:01 +0200 Subject: [PATCH 20/28] Switched appveyor platform to x86_64 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ab04df5..1f74e15 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,7 +20,7 @@ matrix: fast_finish: true # set this flag to immediately finish build once one of the jobs fails. platform: - - x86 + - x86_64 configuration: Release From 9db9b5776a4f794a9381856158f26a14bdb4a43e Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 07:20:29 +0200 Subject: [PATCH 21/28] Added output comparison tests to prevent regressions --- .gitignore | 1 + .travis.yml | 2 +- samples/CMakeLists.txt | 10 ++++++++++ samples/asserts.err.expected | 6 ++++++ samples/asserts.out.expected | 0 samples/description.err.expected | 3 +++ samples/description.out.expected | 0 samples/fixtures.err.expected | 1 + samples/fixtures.out.expected | 2 ++ samples/long-messages.err.expected | 6 ++++++ samples/long-messages.out.expected | 0 samples/more-suites.err.expected | 1 + samples/more-suites.out.expected | 0 samples/other-crashes.err.expected | 3 +++ samples/other-crashes.out.expected | 0 samples/report.err.expected | 3 +++ samples/report.out.expected | 5 +++++ samples/signal.err.expected | 4 ++++ samples/signal.out.expected | 0 samples/simple.err.expected | 3 +++ samples/simple.out.expected | 0 samples/suites.err.expected | 1 + samples/suites.out.expected | 0 samples/tests/run_test.sh | 17 +++++++++++++++++ 24 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 samples/asserts.err.expected create mode 100644 samples/asserts.out.expected create mode 100644 samples/description.err.expected create mode 100644 samples/description.out.expected create mode 100644 samples/fixtures.err.expected create mode 100644 samples/fixtures.out.expected create mode 100644 samples/long-messages.err.expected create mode 100644 samples/long-messages.out.expected create mode 100644 samples/more-suites.err.expected create mode 100644 samples/more-suites.out.expected create mode 100644 samples/other-crashes.err.expected create mode 100644 samples/other-crashes.out.expected create mode 100644 samples/report.err.expected create mode 100644 samples/report.out.expected create mode 100644 samples/signal.err.expected create mode 100644 samples/signal.out.expected create mode 100644 samples/simple.err.expected create mode 100644 samples/simple.out.expected create mode 100644 samples/suites.err.expected create mode 100644 samples/suites.out.expected create mode 100644 samples/tests/run_test.sh diff --git a/.gitignore b/.gitignore index 48d1edb..8dd4a19 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ !*.rst !samples/tests/*.sh !*.po +!samples/*.expected !LICENSE !HEADER diff --git a/.travis.yml b/.travis.yml index eabcb44..4df2cb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ script: after_success: - make coveralls after_failure: -- cat Testing/Temporary/LastTest.log +- cat Testing/Temporary/LastTest.log samples/*.{out,err} ../samples/tests/*.{out,err} env: global: secure: bzZcWjdqoTgceC40kEBucx7NuWYJPk+rxgF3UJJDXi+ijQAFYPv70p5eVsGR6rfc+XgqXCxcUFQtuL4ZVt7QEfVk1ZOJITNeHbKIeKaEYS4nX8mFf+CBeEm9bJGZ04KiQJdJu5mzzAHvXbW7roGXDGWe1Bjnk5wwA+dNUCa7H04= diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 206c049..49456a8 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -34,6 +34,11 @@ foreach(sample ${SAMPLES}) set_property(TEST ${sample} PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ) + + add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh ./${sample} "${CMAKE_CURRENT_LIST_DIR}") + set_property(TEST ${sample}_compare PROPERTY + ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" + ) endforeach() foreach(script ${SCRIPTS}) @@ -41,4 +46,9 @@ foreach(script ${SCRIPTS}) set_property(TEST ${script} PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ) + + add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh ${CMAKE_CURRENT_LIST_DIR}/tests/${script}.sh "${CMAKE_CURRENT_LIST_DIR}") + set_property(TEST ${script}_compare PROPERTY + ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" + ) endforeach() diff --git a/samples/asserts.err.expected b/samples/asserts.err.expected new file mode 100644 index 0000000..edb004b --- /dev/null +++ b/samples/asserts.err.expected @@ -0,0 +1,6 @@ +[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:11: Assertion failed: assert is fatal, expect isn't +[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:12: Assertion failed: This assert runs +[FAIL] asserts::base: (0,00s) +[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:20: Assertion failed: The conditions for this test were not met. +[FAIL] asserts::old_school: (0,00s) +[====] Synthesis: Tested: 6 | Passing: 4 | Failing: 2 | Crashing: 0  diff --git a/samples/asserts.out.expected b/samples/asserts.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/description.err.expected b/samples/description.err.expected new file mode 100644 index 0000000..b5209d0 --- /dev/null +++ b/samples/description.err.expected @@ -0,0 +1,3 @@ +[----] /home/snaipe/workspace/c/criterion/samples/description.c:4: Assertion failed: 0 +[FAIL] misc::failing: (0,00s) +[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/description.out.expected b/samples/description.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/fixtures.err.expected b/samples/fixtures.err.expected new file mode 100644 index 0000000..a34f221 --- /dev/null +++ b/samples/fixtures.err.expected @@ -0,0 +1 @@ +[====] Synthesis: Tested: 1 | Passing: 1 | Failing: 0 | Crashing: 0  diff --git a/samples/fixtures.out.expected b/samples/fixtures.out.expected new file mode 100644 index 0000000..a74afed --- /dev/null +++ b/samples/fixtures.out.expected @@ -0,0 +1,2 @@ +Runs before the test +Runs after the test diff --git a/samples/long-messages.err.expected b/samples/long-messages.err.expected new file mode 100644 index 0000000..2fb7513 --- /dev/null +++ b/samples/long-messages.err.expected @@ -0,0 +1,6 @@ +[----] /home/snaipe/workspace/c/criterion/samples/long-messages.c:4: Assertion failed: This is +[----] A long message +[----] Spawning multiple lines. +[----] Formatting is respected. +[FAIL] sample::long_msg: (0,00s) +[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/long-messages.out.expected b/samples/long-messages.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/more-suites.err.expected b/samples/more-suites.err.expected new file mode 100644 index 0000000..09eb50f --- /dev/null +++ b/samples/more-suites.err.expected @@ -0,0 +1 @@ +[====] Synthesis: Tested: 2 | Passing: 2 | Failing: 0 | Crashing: 0  diff --git a/samples/more-suites.out.expected b/samples/more-suites.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/other-crashes.err.expected b/samples/other-crashes.err.expected new file mode 100644 index 0000000..41d3cb8 --- /dev/null +++ b/samples/other-crashes.err.expected @@ -0,0 +1,3 @@ +[----] Warning! The test `misc::setup_crash` crashed during its setup or teardown. +[----] Warning! The test `misc::teardown_crash` crashed during its setup or teardown. +[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 1  diff --git a/samples/other-crashes.out.expected b/samples/other-crashes.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/report.err.expected b/samples/report.err.expected new file mode 100644 index 0000000..e1ca348 --- /dev/null +++ b/samples/report.err.expected @@ -0,0 +1,3 @@ +[----] /home/snaipe/workspace/c/criterion/samples/report.c:5: Assertion failed: 0 +[FAIL] sample::test: (0,00s) +[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/report.out.expected b/samples/report.out.expected new file mode 100644 index 0000000..20217bd --- /dev/null +++ b/samples/report.out.expected @@ -0,0 +1,5 @@ +criterion_init +criterion_init +testing test in category sample +Asserts: [1 passed, 1 failed, 2 total] +criterion_fini diff --git a/samples/signal.err.expected b/samples/signal.err.expected new file mode 100644 index 0000000..5fe1a9b --- /dev/null +++ b/samples/signal.err.expected @@ -0,0 +1,4 @@ +[----] /home/snaipe/workspace/c/criterion/samples/signal.c:16: Unexpected signal caught below this line! +[FAIL] simple::uncaught: CRASH! +[FAIL] simple::wrong_signal: (0,00s) +[====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1  diff --git a/samples/signal.out.expected b/samples/signal.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/simple.err.expected b/samples/simple.err.expected new file mode 100644 index 0000000..8227be5 --- /dev/null +++ b/samples/simple.err.expected @@ -0,0 +1,3 @@ +[----] /home/snaipe/workspace/c/criterion/samples/simple.c:4: Assertion failed: 0 +[FAIL] misc::failing: (0,00s) +[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0  diff --git a/samples/simple.out.expected b/samples/simple.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/suites.err.expected b/samples/suites.err.expected new file mode 100644 index 0000000..09eb50f --- /dev/null +++ b/samples/suites.err.expected @@ -0,0 +1 @@ +[====] Synthesis: Tested: 2 | Passing: 2 | Failing: 0 | Crashing: 0  diff --git a/samples/suites.out.expected b/samples/suites.out.expected new file mode 100644 index 0000000..e69de29 diff --git a/samples/tests/run_test.sh b/samples/tests/run_test.sh new file mode 100644 index 0000000..88e5d94 --- /dev/null +++ b/samples/tests/run_test.sh @@ -0,0 +1,17 @@ +#!/bin/sh -e + +if [ -f $1.in ]; then + sh -c "$1" > $1.out 2> $1.err < $1.in +else + sh -c "$1" > $1.out 2> $1.err +fi + +if [ -f $2/$1.out.expected ] && [ "$(md5sum $1.out | cut -d' ' -f1)" != "$(md5sum $2/$1.out.expected | cut -d' ' -f1)" ]; then + diff $1.out $2/$1.out.expected + exit 255 +fi + +if [ -f $2/$1.err.expected ] && [ "$(md5sum $1.err | cut -d' ' -f1)" != "$(md5sum $2/$1.err.expected | cut -d' ' -f1)" ]; then + diff $1.err $2/$1.err.expected + exit 255 +fi From b4fc22e7e4b2439c06441c270fc842143eda317c Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 07:58:38 +0200 Subject: [PATCH 22/28] Added -S switch to display the base name of source files --- include/criterion/options.h | 1 + src/log/normal.c | 6 ++++-- src/log/tap.c | 6 ++++-- src/main.c | 7 ++++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/criterion/options.h b/include/criterion/options.h index 3e2dee6..31b90d2 100644 --- a/include/criterion/options.h +++ b/include/criterion/options.h @@ -35,6 +35,7 @@ struct criterion_options { bool use_ascii; bool fail_fast; const char *pattern; + bool short_filename; }; extern struct criterion_options criterion_options; diff --git a/src/log/normal.c b/src/log/normal.c index c82bcbd..3db14d9 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -164,9 +164,10 @@ void normal_log_assert(struct criterion_assert_stats *stats) { char *line = strtok_r(dup, "\n", &saveptr); #endif + bool sf = criterion_options.short_filename; criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_assert_fail), - FG_BOLD, stats->file, RESET, + FG_BOLD, sf ? basename(stats->file) : stats->file, RESET, FG_RED, stats->line, RESET, line); @@ -181,9 +182,10 @@ void normal_log_assert(struct criterion_assert_stats *stats) { } void normal_log_test_crash(struct criterion_test_stats *stats) { + bool sf = criterion_options.short_filename; criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_test_crash_line), - FG_BOLD, stats->file, RESET, + FG_BOLD, sf ? basename(stats->file) : stats->file, RESET, FG_RED, stats->progress, RESET); criterion_pimportant(CRITERION_PREFIX_FAIL, _(msg_test_crash), stats->test->category, diff --git a/src/log/tap.c b/src/log/tap.c index e8a9d97..fec23e1 100644 --- a/src/log/tap.c +++ b/src/log/tap.c @@ -89,8 +89,9 @@ void tap_log_post_test(struct criterion_test_stats *stats) { char *saveptr = NULL; char *line = strtok_r(dup, "\n", &saveptr); #endif + bool sf = criterion_options.short_filename; criterion_important(" %s:%u: Assertion failed: %s\n", - asrt->file, + sf ? basename(asrt->file) : asrt->file, asrt->line, line); #ifdef VANILLA_WIN32 @@ -105,10 +106,11 @@ void tap_log_post_test(struct criterion_test_stats *stats) { } void tap_log_test_crash(struct criterion_test_stats *stats) { + bool sf = criterion_options.short_filename; criterion_important("not ok - %s::%s unexpected signal after %s:%u\n", stats->test->category, stats->test->name, - stats->file, + sf ? basename(stats->file) : stats->file, stats->progress); } diff --git a/src/main.c b/src/main.c index 0402d71..1faa4a3 100644 --- a/src/main.c +++ b/src/main.c @@ -57,6 +57,8 @@ " -f or --fail-fast: exit after the first failure\n" \ " --ascii: don't use fancy unicode symbols " \ "or colors in the output\n" \ + " -S or --short-filename: only display the base " \ + "name of the source file on a failure\n" \ PATTERN_USAGE \ " --tap: enables TAP formatting\n" \ " --always-succeed: always exit with 0\n" \ @@ -124,6 +126,7 @@ int main(int argc, char *argv[]) { {"list", no_argument, 0, 'l'}, {"ascii", no_argument, 0, 'k'}, {"fail-fast", no_argument, 0, 'f'}, + {"short-filename", no_argument, 0, 'S'}, #ifdef HAVE_PCRE {"pattern", required_argument, 0, 'p'}, #endif @@ -146,6 +149,7 @@ int main(int argc, char *argv[]) { opt->fail_fast = !strcmp("1", getenv("CRITERION_FAIL_FAST") ?: "0"); opt->use_ascii = use_ascii; opt->logging_threshold = atoi(getenv("CRITERION_VERBOSITY_LEVEL") ?: "2"); + opt->short_filename = !strcmp("1", getenv("CRITERION_SHORT_FILENAME") ?: "0"); #ifdef HAVE_PCRE opt->pattern = getenv("CRITERION_TEST_PATTERN"); #endif @@ -155,13 +159,14 @@ int main(int argc, char *argv[]) { bool do_list_tests = false; bool do_print_version = false; bool do_print_usage = false; - for (int c; (c = getopt_long(argc, argv, "hvlf", opts, NULL)) != -1;) { + for (int c; (c = getopt_long(argc, argv, "hvlfS", opts, NULL)) != -1;) { switch (c) { case 'b': criterion_options.logging_threshold = atoi(optarg ?: "1"); break; case 'y': criterion_options.always_succeed = true; break; case 'z': criterion_options.no_early_exit = true; break; case 'k': criterion_options.use_ascii = true; break; case 'f': criterion_options.fail_fast = true; break; + case 'S': criterion_options.short_filename = true; break; #ifdef HAVE_PCRE case 'p': criterion_options.pattern = optarg; break; #endif From 880c75746f6d5d0f97bf6d0a48bfcfbfb047f18f Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 08:33:22 +0200 Subject: [PATCH 23/28] Fixed comparison tests depending on absolute paths --- samples/CMakeLists.txt | 6 ++++-- samples/asserts.err.expected | 6 +++--- samples/description.err.expected | 2 +- samples/long-messages.err.expected | 2 +- samples/report.err.expected | 2 +- samples/signal.err.expected | 2 +- samples/simple.err.expected | 2 +- samples/tests/run_test.sh | 21 ++++++++++++++------- 8 files changed, 26 insertions(+), 17 deletions(-) mode change 100644 => 100755 samples/tests/run_test.sh diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 49456a8..d6b3fe4 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -35,9 +35,10 @@ foreach(sample ${SAMPLES}) ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ) - add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh ./${sample} "${CMAKE_CURRENT_LIST_DIR}") + add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . . ${sample}) set_property(TEST ${sample}_compare PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" + ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ) endforeach() @@ -47,8 +48,9 @@ foreach(script ${SCRIPTS}) ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ) - add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh ${CMAKE_CURRENT_LIST_DIR}/tests/${script}.sh "${CMAKE_CURRENT_LIST_DIR}") + add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . "${CMAKE_CURRENT_LIST_DIR}" tests/${sample}) set_property(TEST ${script}_compare PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" + ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ) endforeach() diff --git a/samples/asserts.err.expected b/samples/asserts.err.expected index edb004b..4ad5e0f 100644 --- a/samples/asserts.err.expected +++ b/samples/asserts.err.expected @@ -1,6 +1,6 @@ -[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:11: Assertion failed: assert is fatal, expect isn't -[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:12: Assertion failed: This assert runs +[----] asserts.c:11: Assertion failed: assert is fatal, expect isn't +[----] asserts.c:12: Assertion failed: This assert runs [FAIL] asserts::base: (0,00s) -[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:20: Assertion failed: The conditions for this test were not met. +[----] asserts.c:20: Assertion failed: The conditions for this test were not met. [FAIL] asserts::old_school: (0,00s) [====] Synthesis: Tested: 6 | Passing: 4 | Failing: 2 | Crashing: 0  diff --git a/samples/description.err.expected b/samples/description.err.expected index b5209d0..33ee4a1 100644 --- a/samples/description.err.expected +++ b/samples/description.err.expected @@ -1,3 +1,3 @@ -[----] /home/snaipe/workspace/c/criterion/samples/description.c:4: Assertion failed: 0 +[----] description.c:4: Assertion failed: 0 [FAIL] misc::failing: (0,00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/long-messages.err.expected b/samples/long-messages.err.expected index 2fb7513..2507fbc 100644 --- a/samples/long-messages.err.expected +++ b/samples/long-messages.err.expected @@ -1,4 +1,4 @@ -[----] /home/snaipe/workspace/c/criterion/samples/long-messages.c:4: Assertion failed: This is +[----] long-messages.c:4: Assertion failed: This is [----] A long message [----] Spawning multiple lines. [----] Formatting is respected. diff --git a/samples/report.err.expected b/samples/report.err.expected index e1ca348..e7b9a78 100644 --- a/samples/report.err.expected +++ b/samples/report.err.expected @@ -1,3 +1,3 @@ -[----] /home/snaipe/workspace/c/criterion/samples/report.c:5: Assertion failed: 0 +[----] report.c:5: Assertion failed: 0 [FAIL] sample::test: (0,00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/signal.err.expected b/samples/signal.err.expected index 5fe1a9b..b0d4c59 100644 --- a/samples/signal.err.expected +++ b/samples/signal.err.expected @@ -1,4 +1,4 @@ -[----] /home/snaipe/workspace/c/criterion/samples/signal.c:16: Unexpected signal caught below this line! +[----] signal.c:16: Unexpected signal caught below this line! [FAIL] simple::uncaught: CRASH! [FAIL] simple::wrong_signal: (0,00s) [====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1  diff --git a/samples/simple.err.expected b/samples/simple.err.expected index 8227be5..2131286 100644 --- a/samples/simple.err.expected +++ b/samples/simple.err.expected @@ -1,3 +1,3 @@ -[----] /home/snaipe/workspace/c/criterion/samples/simple.c:4: Assertion failed: 0 +[----] simple.c:4: Assertion failed: 0 [FAIL] misc::failing: (0,00s) [====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0  diff --git a/samples/tests/run_test.sh b/samples/tests/run_test.sh old mode 100644 new mode 100755 index 88e5d94..501da79 --- a/samples/tests/run_test.sh +++ b/samples/tests/run_test.sh @@ -1,17 +1,24 @@ #!/bin/sh -e -if [ -f $1.in ]; then - sh -c "$1" > $1.out 2> $1.err < $1.in +cmp_dir=$1; shift +out_dir=$1; shift +bin_dir=$1; shift + +mkdir -p $out_dir + +if [ -f $cmp_dir/$1.in ]; then + sh -c "$bin_dir/$*" > $out_dir/$1.out 2> $out_dir/$1.err < $cmp_dir/$1.in else - sh -c "$1" > $1.out 2> $1.err + mkdir -p $(dirname $out_dir/$1) + sh -c "$bin_dir/$*" > $out_dir/$1.out 2> $out_dir/$1.err fi -if [ -f $2/$1.out.expected ] && [ "$(md5sum $1.out | cut -d' ' -f1)" != "$(md5sum $2/$1.out.expected | cut -d' ' -f1)" ]; then - diff $1.out $2/$1.out.expected +if [ -f $cmp_dir/$1.out.expected ] && [ "$(md5sum $out_dir/$1.out | cut -d' ' -f1)" != "$(md5sum $cmp_dir/$1.out.expected | cut -d' ' -f1)" ]; then + diff $out_dir/$1.out $cmp_dir/$1.out.expected exit 255 fi -if [ -f $2/$1.err.expected ] && [ "$(md5sum $1.err | cut -d' ' -f1)" != "$(md5sum $2/$1.err.expected | cut -d' ' -f1)" ]; then - diff $1.err $2/$1.err.expected +if [ -f $cmp_dir/$1.err.expected ] && [ "$(md5sum $out_dir/$1.err | cut -d' ' -f1)" != "$(md5sum $cmp_dir/$1.err.expected | cut -d' ' -f1)" ]; then + diff $out_dir/$1.err $cmp_dir/$1.err.expected exit 255 fi From 0d85790a9d13ee14904c0d50cb5177741647bfae Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 17:45:28 +0200 Subject: [PATCH 24/28] Fixed locale use to be en_US.utf8 in expected test output --- samples/CMakeLists.txt | 2 ++ samples/asserts.err.expected | 4 ++-- samples/description.err.expected | 2 +- samples/long-messages.err.expected | 2 +- samples/report.err.expected | 2 +- samples/signal.err.expected | 2 +- samples/simple.err.expected | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index d6b3fe4..4f928b2 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -37,6 +37,7 @@ foreach(sample ${SAMPLES}) add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . . ${sample}) set_property(TEST ${sample}_compare PROPERTY + ENVIRONMENT "LC_ALL=en_US.utf8" ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ) @@ -50,6 +51,7 @@ foreach(script ${SCRIPTS}) add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . "${CMAKE_CURRENT_LIST_DIR}" tests/${sample}) set_property(TEST ${script}_compare PROPERTY + ENVIRONMENT "LC_ALL=en_US.utf8" ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ) diff --git a/samples/asserts.err.expected b/samples/asserts.err.expected index 4ad5e0f..644a440 100644 --- a/samples/asserts.err.expected +++ b/samples/asserts.err.expected @@ -1,6 +1,6 @@ [----] asserts.c:11: Assertion failed: assert is fatal, expect isn't [----] asserts.c:12: Assertion failed: This assert runs -[FAIL] asserts::base: (0,00s) +[FAIL] asserts::base: (0.00s) [----] asserts.c:20: Assertion failed: The conditions for this test were not met. -[FAIL] asserts::old_school: (0,00s) +[FAIL] asserts::old_school: (0.00s) [====] Synthesis: Tested: 6 | Passing: 4 | Failing: 2 | Crashing: 0  diff --git a/samples/description.err.expected b/samples/description.err.expected index 33ee4a1..64ffe21 100644 --- a/samples/description.err.expected +++ b/samples/description.err.expected @@ -1,3 +1,3 @@ [----] description.c:4: Assertion failed: 0 -[FAIL] misc::failing: (0,00s) +[FAIL] misc::failing: (0.00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/long-messages.err.expected b/samples/long-messages.err.expected index 2507fbc..9658ae5 100644 --- a/samples/long-messages.err.expected +++ b/samples/long-messages.err.expected @@ -2,5 +2,5 @@ [----] A long message [----] Spawning multiple lines. [----] Formatting is respected. -[FAIL] sample::long_msg: (0,00s) +[FAIL] sample::long_msg: (0.00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/report.err.expected b/samples/report.err.expected index e7b9a78..5b8f140 100644 --- a/samples/report.err.expected +++ b/samples/report.err.expected @@ -1,3 +1,3 @@ [----] report.c:5: Assertion failed: 0 -[FAIL] sample::test: (0,00s) +[FAIL] sample::test: (0.00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/signal.err.expected b/samples/signal.err.expected index b0d4c59..8bc2b30 100644 --- a/samples/signal.err.expected +++ b/samples/signal.err.expected @@ -1,4 +1,4 @@ [----] signal.c:16: Unexpected signal caught below this line! [FAIL] simple::uncaught: CRASH! -[FAIL] simple::wrong_signal: (0,00s) +[FAIL] simple::wrong_signal: (0.00s) [====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1  diff --git a/samples/simple.err.expected b/samples/simple.err.expected index 2131286..ef375ca 100644 --- a/samples/simple.err.expected +++ b/samples/simple.err.expected @@ -1,3 +1,3 @@ [----] simple.c:4: Assertion failed: 0 -[FAIL] misc::failing: (0,00s) +[FAIL] misc::failing: (0.00s) [====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0  From 0520a367233e1485b7e6710ccf4ccb42fdf97871 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 18:04:29 +0200 Subject: [PATCH 25/28] Implemented basename for compatibility with OS X and Windows --- src/log/normal.c | 4 ++-- src/log/tap.c | 4 ++-- src/posix-compat.c | 8 ++++++++ src/posix-compat.h | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/log/normal.c b/src/log/normal.c index 3db14d9..565e763 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -167,7 +167,7 @@ void normal_log_assert(struct criterion_assert_stats *stats) { bool sf = criterion_options.short_filename; criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_assert_fail), - FG_BOLD, sf ? basename(stats->file) : stats->file, RESET, + FG_BOLD, sf ? basename_compat(stats->file) : stats->file, RESET, FG_RED, stats->line, RESET, line); @@ -185,7 +185,7 @@ void normal_log_test_crash(struct criterion_test_stats *stats) { bool sf = criterion_options.short_filename; criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_test_crash_line), - FG_BOLD, sf ? basename(stats->file) : stats->file, RESET, + FG_BOLD, sf ? basename_compat(stats->file) : stats->file, RESET, FG_RED, stats->progress, RESET); criterion_pimportant(CRITERION_PREFIX_FAIL, _(msg_test_crash), stats->test->category, diff --git a/src/log/tap.c b/src/log/tap.c index fec23e1..23898f4 100644 --- a/src/log/tap.c +++ b/src/log/tap.c @@ -91,7 +91,7 @@ void tap_log_post_test(struct criterion_test_stats *stats) { #endif bool sf = criterion_options.short_filename; criterion_important(" %s:%u: Assertion failed: %s\n", - sf ? basename(asrt->file) : asrt->file, + sf ? basename_compat(asrt->file) : asrt->file, asrt->line, line); #ifdef VANILLA_WIN32 @@ -110,7 +110,7 @@ void tap_log_test_crash(struct criterion_test_stats *stats) { criterion_important("not ok - %s::%s unexpected signal after %s:%u\n", stats->test->category, stats->test->name, - sf ? basename(stats->file) : stats->file, + sf ? basename_compat(stats->file) : stats->file, stats->progress); } diff --git a/src/posix-compat.c b/src/posix-compat.c index 4cb7a28..376cd27 100644 --- a/src/posix-compat.c +++ b/src/posix-compat.c @@ -387,3 +387,11 @@ void *get_osx_section_end(const char *section) { return get_real_address(section_start) + secsize; } #endif + +const char *basename_compat(const char *str) { + const char *start = str; + for (const char *c = str; *c; ++c) + if ((*c == '/' || *c == '\\') && c[1]) + start = c + 1; + return start; +} diff --git a/src/posix-compat.h b/src/posix-compat.h index 84a5aef..9f938db 100644 --- a/src/posix-compat.h +++ b/src/posix-compat.h @@ -95,4 +95,6 @@ void *get_osx_section_end(const char *section); # define GET_SECTION_END(Name) SECTION_END(Name) # endif +const char *basename_compat(const char *str); + #endif /* !POSIX_COMPAT_H_ */ From ad1338e7688033c99b6e89804f4ac01abb3fa633 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 18:16:04 +0200 Subject: [PATCH 26/28] Fixed line endings before comparing outputs --- samples/tests/run_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/tests/run_test.sh b/samples/tests/run_test.sh index 501da79..8d81472 100755 --- a/samples/tests/run_test.sh +++ b/samples/tests/run_test.sh @@ -13,6 +13,8 @@ else sh -c "$bin_dir/$*" > $out_dir/$1.out 2> $out_dir/$1.err fi +dos2unix $out_dir/$1.err $out_dir/$1.out + if [ -f $cmp_dir/$1.out.expected ] && [ "$(md5sum $out_dir/$1.out | cut -d' ' -f1)" != "$(md5sum $cmp_dir/$1.out.expected | cut -d' ' -f1)" ]; then diff $out_dir/$1.out $cmp_dir/$1.out.expected exit 255 From b7528a95421c25662261a2f22e6c093ae167642d Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 19:56:23 +0200 Subject: [PATCH 27/28] Fixed duplicated output when writing in PRE_ALL report hook with a redirected output --- samples/report.out.expected | 1 - src/runner.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/report.out.expected b/samples/report.out.expected index 20217bd..d560277 100644 --- a/samples/report.out.expected +++ b/samples/report.out.expected @@ -1,5 +1,4 @@ criterion_init -criterion_init testing test in category sample Asserts: [1 passed, 1 failed, 2 total] criterion_fini diff --git a/src/runner.c b/src/runner.c index a35a57c..c28da67 100644 --- a/src/runner.c +++ b/src/runner.c @@ -296,6 +296,8 @@ static int criterion_run_all_tests_impl(void) { report(PRE_ALL, set); log(pre_all, set); + fflush(NULL); // flush everything before forking + smart struct criterion_global_stats *stats = stats_init(); map_tests(set, stats, run_test); From e37b6b55a3e69fc75dece8fcc0fd9e689889841b Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 20:39:28 +0200 Subject: [PATCH 28/28] Documented new -S switch --- doc/env.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/env.rst b/doc/env.rst index 1db5788..745ff9b 100644 --- a/doc/env.rst +++ b/doc/env.rst @@ -18,6 +18,7 @@ Command line arguments * ``--no-early-exit``: The test workers shall not prematurely exit when done and will properly return from the main, cleaning up their process space. This is useful when tracking memory leaks with ``valgrind --tool=memcheck``. +* ``-S or --short-filename``: The filenames are displayed in their short form. * ``--always-succeed``: The process shall exit with a status of ``0``. * ``--tap``: Enables the TAP (Test Anything Protocol) output format. * ``--verbose[=level]``: Makes the output verbose. When provided with an integer, @@ -59,6 +60,7 @@ Environment variables are alternatives to command line switches when set to 1. * ``CRITERION_ENABLE_TAP``: Same as ``--tap``. * ``CRITERION_FAIL_FAST``: Same as ``--fail-fast``. * ``CRITERION_USE_ASCII``: Same as ``--ascii``. +* ``CRITERION_SHORT_FILENAME``: Same as ``--short-filename``. * ``CRITERION_VERBOSITY_LEVEL``: Same as ``--verbose``. Sets the verbosity level to its value. * ``CRITERION_TEST_PATTERN``: Same as ``--pattern``. Sets the test pattern