1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 19:52:37 +01:00

bats: Don't pipe to cat for nonpretty output

Under Bash 3.2.57(1)-release and 4.4.12(1)-release on a MacBook Pro with
a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM, this shaves off
O(0.04-0.05s) from the current test suite. Very minor, but it's a
straightforward change that may provide a minor-yet-noticeable effect on
Windows.

Before this change:

  46 tests, 0 failures

  real    0m3.588s
  user    0m2.171s
  sys     0m1.046s

After this change:

  real    0m3.538s
  user    0m2.119s
  sys     0m0.941s
This commit is contained in:
Mike Bland 2017-03-16 13:40:37 -04:00
parent d4443adeb7
commit 7bcbb2f3e9
No known key found for this signature in database
GPG Key ID: 5121C73A6E07384B

View File

@ -154,13 +154,11 @@ else
command="bats-exec-suite"
fi
if [ -n "$pretty" ]; then
set -o pipefail execfail
if [ -z "$pretty" ]; then
exec "$command" $count_flag "${filenames[@]}"
else
extended_syntax_flag="-x"
formatter="bats-format-tap-stream"
else
extended_syntax_flag=""
formatter="cat"
exec "$command" $count_flag $extended_syntax_flag "${filenames[@]}" | "$formatter"
fi
set -o pipefail execfail
exec "$command" $count_flag $extended_syntax_flag "${filenames[@]}" | "$formatter"