mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 11:42:33 +01:00
Merge pull request #2 from Marthym/feature/run-dont-include-stderr
Feature/run dont include stderr
This commit is contained in:
commit
1e2303424a
|
@ -55,10 +55,18 @@ run() {
|
||||||
set +e
|
set +e
|
||||||
set +E
|
set +E
|
||||||
set +T
|
set +T
|
||||||
output="$("$@" 2>&1)"
|
|
||||||
status="$?"
|
eval "$({ t_sdterr=$({ t_stdout=$("$@"); t_ret=$?; } 2>&1; declare -p t_stdout >&2; declare -pi t_ret >&2); declare -p t_sdterr; } 2>&1)"
|
||||||
|
|
||||||
|
status=$t_ret
|
||||||
|
output="${t_stdout}${t_sdterr}"
|
||||||
|
stdout=$t_stdout
|
||||||
|
stderr=$t_sdterr
|
||||||
|
|
||||||
oldIFS=$IFS
|
oldIFS=$IFS
|
||||||
IFS=$'\n' lines=($output)
|
IFS=$'\n' lines=($output)
|
||||||
|
IFS=$'\n' stdlines=($t_stdout)
|
||||||
|
IFS=$'\n' errlines=($t_sdterr)
|
||||||
[ -z "$e" ] || set -e
|
[ -z "$e" ] || set -e
|
||||||
[ -z "$E" ] || set -E
|
[ -z "$E" ] || set -E
|
||||||
[ -z "$T" ] || set -T
|
[ -z "$T" ] || set -T
|
||||||
|
|
|
@ -262,3 +262,8 @@ fixtures bats
|
||||||
[ $status -eq 0 ]
|
[ $status -eq 0 ]
|
||||||
[ "${lines[1]}" = "ok 1 loop_func" ]
|
[ "${lines[1]}" = "ok 1 loop_func" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "testing stdout and stderr are separated" {
|
||||||
|
run bats "$FIXTURE_ROOT/stdout_stderr_separate.bats"
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
}
|
14
test/fixtures/bats/stdout_stderr_separate.bats
vendored
Normal file
14
test/fixtures/bats/stdout_stderr_separate.bats
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# see issue #89
|
||||||
|
echo_std_err() {
|
||||||
|
echo "std output"
|
||||||
|
(>&2 echo "err output")
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "std err" {
|
||||||
|
run echo_std_err
|
||||||
|
[ $status -eq 0 ]
|
||||||
|
[ "${stdout}" = "std output" ]
|
||||||
|
[ "${stderr}" = "err output" ]
|
||||||
|
[ "${output}" = "std outputerr output" ]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user