From 9c8425d00536cfb27cbf1faf00be7a6bf0f0a262 Mon Sep 17 00:00:00 2001 From: Adam Jacob Date: Wed, 22 May 2013 21:20:39 -0400 Subject: [PATCH 1/2] Supporting DOS line endings in BATS tests --- libexec/bats-exec-test | 2 +- test/bats.bats | 5 +++++ test/fixtures/bats/dos_line.bats | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/bats/dos_line.bats diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 2c70426..7613eac 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -127,7 +127,7 @@ BATS_OUT="${BATS_TMPNAME}.out" bats_preprocess_source() { BATS_TEST_SOURCE="${BATS_TMPNAME}.src" - bats-preprocess < "$BATS_TEST_FILENAME" > "$BATS_TEST_SOURCE" + cat "$BATS_TEST_FILENAME" | tr -d '\r' | bats-preprocess > "$BATS_TEST_SOURCE" trap bats_cleanup_preprocessed_source err exit trap "bats_cleanup_preprocessed_source; exit 1" int } diff --git a/test/bats.bats b/test/bats.bats index ba53ee7..2ac5905 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -103,3 +103,8 @@ fixtures bats [ $status -eq 0 ] [ "${lines[1]}" = "ok 1 dash-e on beginning of line" ] } + +@test "dos line endings are stripped before testing" { + run bats "$FIXTURE_ROOT/dos_line.bats" + [ $status -eq 0 ] +} diff --git a/test/fixtures/bats/dos_line.bats b/test/fixtures/bats/dos_line.bats new file mode 100644 index 0000000..b5f65c6 --- /dev/null +++ b/test/fixtures/bats/dos_line.bats @@ -0,0 +1,3 @@ +@test "foo" { + echo "foo" +} From af9794634fe035b445256e9ff0fa63db35935a51 Mon Sep 17 00:00:00 2001 From: Adam Jacob Date: Thu, 23 May 2013 00:52:08 -0400 Subject: [PATCH 2/2] Using shell redirection rather than cat --- libexec/bats-exec-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index 7613eac..f427dcb 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -127,7 +127,7 @@ BATS_OUT="${BATS_TMPNAME}.out" bats_preprocess_source() { BATS_TEST_SOURCE="${BATS_TMPNAME}.src" - cat "$BATS_TEST_FILENAME" | tr -d '\r' | bats-preprocess > "$BATS_TEST_SOURCE" + tr -d '\r' < "$BATS_TEST_FILENAME" | bats-preprocess > "$BATS_TEST_SOURCE" trap bats_cleanup_preprocessed_source err exit trap "bats_cleanup_preprocessed_source; exit 1" int }