From 911367e6d5757c7ce4d28b8474a03d946dc1a32d Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Wed, 28 Dec 2011 17:12:37 -0600 Subject: [PATCH] Add $lines array --- libexec/bats-exec | 1 + test/bats.bats | 7 +++++++ test/fixtures/one_passing.bats | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 test/fixtures/one_passing.bats diff --git a/libexec/bats-exec b/libexec/bats-exec index d062732..913120b 100755 --- a/libexec/bats-exec +++ b/libexec/bats-exec @@ -24,6 +24,7 @@ run() { [[ ! "$-" =~ e ]] || e=1 set +e output="$("$@" 2>&1)" + IFS=$'\n' lines=($output) status="$?" [ -z "$e" ] || set -e } diff --git a/test/bats.bats b/test/bats.bats index bcab33f..c168279 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -19,3 +19,10 @@ FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures" [[ $status -eq 0 ]] [[ $output = "1..0" ]] } + +@test "one passing test" { + run bats "$FIXTURE_ROOT/one_passing.bats" + [[ $status -eq 0 ]] + [[ ${lines[0]} = "1..1" ]] + [[ ${lines[1]} = "ok 1 a passing test" ]] +} diff --git a/test/fixtures/one_passing.bats b/test/fixtures/one_passing.bats new file mode 100644 index 0000000..e8182ce --- /dev/null +++ b/test/fixtures/one_passing.bats @@ -0,0 +1,3 @@ +@test "a passing test" { + true +}