>From a40176fe7b5f3a6706469922dde0fca422f1a6e4 Mon Sep 17 00:00:00 2001 From: Mario Domenech Goulart Date: Thu, 6 Mar 2014 22:59:20 -0300 Subject: [PATCH] Drop requirement on external program dos2unix for tests Add a quick&dirty scheme program (tests/dos2unix.scm) to replace the external program dos2unix which is not always available on Windows systems. As a bonus, by using a scheme program we indirectly introduce new tests (e.g., binary I/O). --- distribution/manifest | 1 + tests/dos2unix.scm | 30 ++++++++++++++++++++++++++++++ tests/runtests.sh | 8 ++------ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 tests/dos2unix.scm diff --git a/distribution/manifest b/distribution/manifest index 791389e..78deb99 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -96,6 +96,7 @@ build-version.scm build-version.c buildid buildtag.h +tests/dos2unix.scm tests/thread-list.scm tests/data-structures-tests.scm tests/environment-tests.scm diff --git a/tests/dos2unix.scm b/tests/dos2unix.scm new file mode 100644 index 0000000..8bbe532 --- /dev/null +++ b/tests/dos2unix.scm @@ -0,0 +1,30 @@ +;; Cheap replacement for dos2unix + +(use data-structures extras files utils) + +(define (dos->unix file) + (let ((lines (with-input-from-file file read-lines #:binary))) + (with-output-to-file file + (lambda () + (display (string-intersperse lines "\n"))) + #:binary))) + +(define (usage #!optional exit-code) + (let ((port (if (and exit-code (not (zero? exit-code))) + (current-error-port) + (current-output-port))) + (this (pathname-strip-directory (program-name)))) + (fprintf port "Usage: ~a \n" this) + (when exit-code + (exit exit-code)))) + +(let ((args (command-line-arguments))) + (when (null? args) + (usage 1)) + + (when (or (member "-h" args) + (member "-help" args) + (member "--help" args)) + (usage 0)) + + (dos->unix (car args))) diff --git a/tests/runtests.sh b/tests/runtests.sh index a1bac7a..db2dc14 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -82,9 +82,7 @@ $compile typematch-tests.scm -specialize -w ./a.out $compile scrutiny-tests.scm -A -scrutinize -ignore-repository -types $TYPESDB 2>scrutiny.out -verbose -if test -n "$MSYSTEM"; then - dos2unix scrutiny.out -fi +$interpret -s dos2unix.scm scrutiny.out # this is sensitive to gensym-names, so make it optional if test \! -f scrutiny.expected; then @@ -95,9 +93,7 @@ diff $DIFF_OPTS scrutiny.expected scrutiny.out $compile scrutiny-tests-2.scm -A -scrutinize -analyze-only -ignore-repository -types $TYPESDB 2>scrutiny-2.out -verbose -if test -n "$MSYSTEM"; then - dos2unix scrutiny-2.out -fi +$interpret -s dos2unix.scm scrutiny-2.out # this is sensitive to gensym-names, so make it optional if test \! -f scrutiny-2.expected; then -- 1.7.10.4