Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Revert "saving $IFS in run() not altered for code using it - fix #89"
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Feb 26, 2015
1 parent 955309a commit 4d4b7a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 36 deletions.
4 changes: 1 addition & 3 deletions libexec/bats-exec-test
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ load() {
}

run() {
local e E T oldIFS
local e E T
[[ ! "$-" =~ e ]] || e=1
[[ ! "$-" =~ E ]] || E=1
[[ ! "$-" =~ T ]] || T=1
Expand All @@ -57,12 +57,10 @@ run() {
set +T
output="$("$@" 2>&1)"
status="$?"
oldIFS=$IFS
IFS=$'\n' lines=($output)
[ -z "$e" ] || set -e
[ -z "$E" ] || set -E
[ -z "$T" ] || set -T
IFS=$oldIFS
}

setup() {
Expand Down
12 changes: 3 additions & 9 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ fixtures bats
@test "empty test file runs zero tests" {
run bats "$FIXTURE_ROOT/empty.bats"
[ $status -eq 0 ]
[ "$output" = "1..0" ]
[ $output = "1..0" ]
}

@test "one passing test" {
run bats "$FIXTURE_ROOT/passing.bats"
[ $status -eq 0 ]
[ "${lines[0]}" = "1..1" ]
[ "${lines[1]}" = "ok 1 a passing test" ]
[ ${lines[0]} = "1..1" ]
[ ${lines[1]} = "ok 1 a passing test" ]
}

@test "summary passing tests" {
Expand Down Expand Up @@ -256,9 +256,3 @@ fixtures bats
[ "${lines[5]}" = "# (in test file $RELATIVE_FIXTURE_ROOT/single_line.bats, line 9)" ]
[ "${lines[6]}" = $'# `@test "failing" { false; }\' failed' ]
}

@test "testing IFS not modified by run" {
run bats "$FIXTURE_ROOT/loop_keep_IFS.bats"
[ $status -eq 0 ]
[ "${lines[1]}" = "ok 1 loop_func" ]
}
16 changes: 0 additions & 16 deletions test/fixtures/bats/loop_keep_IFS.bats

This file was deleted.

16 changes: 8 additions & 8 deletions test/suite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ fixtures suite
@test "running a suite with no test files" {
run bats "$FIXTURE_ROOT/empty"
[ $status -eq 0 ]
[ "$output" = "1..0" ]
[ $output = "1..0" ]
}

@test "running a suite with one test file" {
run bats "$FIXTURE_ROOT/single"
[ $status -eq 0 ]
[ "${lines[0]}" = "1..1" ]
[ "${lines[1]}" = "ok 1 a passing test" ]
[ ${lines[0]} = "1..1" ]
[ ${lines[1]} = "ok 1 a passing test" ]
}

@test "counting tests in a suite" {
run bats -c "$FIXTURE_ROOT/single"
[ $status -eq 0 ]
[ "$output" -eq 1 ]
[ $output -eq 1 ]

run bats -c "$FIXTURE_ROOT/multiple"
[ $status -eq 0 ]
[ "$output" -eq 3 ]
[ $output -eq 3 ]
}

@test "aggregated output of multiple tests in a suite" {
run bats "$FIXTURE_ROOT/multiple"
[ $status -eq 0 ]
[ "${lines[0]}" = "1..3" ]
[ ${lines[0]} = "1..3" ]
echo "$output" | grep "^ok . truth"
echo "$output" | grep "^ok . more truth"
echo "$output" | grep "^ok . quasi-truth"
Expand All @@ -38,14 +38,14 @@ fixtures suite
@test "a failing test in a suite results in an error exit code" {
FLUNK=1 run bats "$FIXTURE_ROOT/multiple"
[ $status -eq 1 ]
[ "${lines[0]}" = "1..3" ]
[ ${lines[0]} = "1..3" ]
echo "$output" | grep "^not ok . quasi-truth"
}

@test "running an ad-hoc suite by specifying multiple test files" {
run bats "$FIXTURE_ROOT/multiple/a.bats" "$FIXTURE_ROOT/multiple/b.bats"
[ $status -eq 0 ]
[ "${lines[0]}" = "1..3" ]
[ ${lines[0]} = "1..3" ]
echo "$output" | grep "^ok . truth"
echo "$output" | grep "^ok . more truth"
echo "$output" | grep "^ok . quasi-truth"
Expand Down

0 comments on commit 4d4b7a4

Please sign in to comment.