From f21438f8078401c81a20321855e5b868ae8df154 Mon Sep 17 00:00:00 2001 From: brarcher Date: Sun, 13 Sep 2015 21:55:50 +0000 Subject: [PATCH] use filterdiff tool if available to strip timestamps from example The diff tool will emit a timestamp along with the diff. This timestamps prevents build output from being consistent between builds. If the filterdiff tool is detected, use it to strip the timestamp and allow for reproducible build output. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1224 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- AUTHORS | 1 + NEWS | 4 ++++ configure.ac | 9 +++++++++ doc/Makefile.am | 27 ++++++++++++++++++--------- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0ad12a2a..27789876 100644 --- a/AUTHORS +++ b/AUTHORS @@ -55,6 +55,7 @@ Contributors: Sebastian Dröge (Kill running tests if SIGTERM or SIGINT are caught in test runner) Matt Clarkson (Fix CMake checks using time.h for MinGW and MSVC) Mario Sanchez Prada (configure.ac cleanup) + Tobias Frost (strip timestamps from examples to enable reproducible builds) Anybody who has contributed code to Check or Check's build system is considered an author. Send patches to this file to diff --git a/NEWS b/NEWS index 1762cc82..e69ac155 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,10 @@ In Development: * Add LGPL header to files where it was missing; update FSF address in LGPL headers Bug #110 +* Strip timestamps from examples using filterdiff if available. This + allow build output to be reproducible. + Bug #112 + Sun Aug 2, 2015: Released Check 0.10.0 based on r1217 (2015-08-02 19:21:14 +0000) diff --git a/configure.ac b/configure.ac index 2b72f3a5..27b5009c 100644 --- a/configure.ac +++ b/configure.ac @@ -181,6 +181,15 @@ if test "$TEX" = "false"; then # anyway. AC_MSG_WARN(tex not installed: cannot rebuild HTML documentation.) fi +AC_CHECK_PROGS(FILTERDIFF, filterdiff, false) +if test "$FILTERDIFF" = "false"; then + # Make it [somewhat] clear to maintainers that filterdiff is missing. + # This is not an error, but will prevent builds from being + # reproducible. + AC_MSG_WARN(filterdiff not installed; build will not be reproducible.) +fi + +AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"]) # Checks for pthread implementation. ACX_PTHREAD diff --git a/doc/Makefile.am b/doc/Makefile.am index 1a58ffa0..27109720 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -26,6 +26,15 @@ eg_root = $(top_srcdir)/doc/example eg_src = $(eg_root)/src eg_tests = $(eg_root)/tests +# If the filterdiff tool is available, use it to filter timestamps +# from diff files. Otherwise, the timestamps change between builds +# and the built output will not be reproducible +if USE_FILTERDIFF + filter_timestapms = | filterdiff --remove-timestamps +else + filter_timestapms = +endif + ## now a rule for each diff. the redundancy here can probably be ## parameterized, but I don't know how. if you know, please tell us! @@ -33,47 +42,47 @@ eg_tests = $(eg_root)/tests # think that means there is an error money.1-2.h.diff: $(eg_src)/money.1.h $(eg_src)/money.2.h cd $(eg_root); \ - diff -U 100 src/money.1.h src/money.2.h > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 src/money.1.h src/money.2.h ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; money.1-3.c.diff: $(eg_src)/money.1.c $(eg_src)/money.3.c cd $(eg_root); \ - diff -U 100 src/money.1.c src/money.3.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 src/money.1.c src/money.3.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; money.3-4.c.diff: $(eg_src)/money.3.c $(eg_src)/money.4.c cd $(eg_root); \ - diff -U 100 src/money.3.c src/money.4.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 src/money.3.c src/money.4.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; money.4-5.c.diff: $(eg_src)/money.4.c $(eg_src)/money.5.c cd $(eg_root); \ - diff -U 100 src/money.4.c src/money.5.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 src/money.4.c src/money.5.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; money.5-6.c.diff: $(eg_src)/money.5.c $(eg_src)/money.6.c cd $(eg_root); \ - diff -U 100 src/money.5.c src/money.6.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 src/money.5.c src/money.6.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; check_money.1-2.c.diff: $(eg_tests)/check_money.1.c $(eg_tests)/check_money.2.c cd $(eg_root); \ - diff -U 100 tests/check_money.1.c tests/check_money.2.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 tests/check_money.1.c tests/check_money.2.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; check_money.2-3.c.diff: $(eg_tests)/check_money.2.c $(eg_tests)/check_money.3.c cd $(eg_root); \ - diff -U 100 tests/check_money.2.c tests/check_money.3.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 tests/check_money.2.c tests/check_money.3.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; check_money.3-6.c.diff: $(eg_tests)/check_money.3.c $(eg_tests)/check_money.6.c cd $(eg_root); \ - diff -U 100 tests/check_money.3.c tests/check_money.6.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 tests/check_money.3.c tests/check_money.6.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; check_money.6-7.c.diff: $(eg_tests)/check_money.6.c $(eg_tests)/check_money.7.c cd $(eg_root); \ - diff -U 100 tests/check_money.6.c tests/check_money.7.c > @abs_builddir@/$@ || test $$? -eq 1; \ + diff -U 100 tests/check_money.6.c tests/check_money.7.c ${filter_timestapms} > @abs_builddir@/$@ || test $$? -eq 1; \ cd -; # explicitly list every file in the example.