From 7bcbb2f3e9babf5ab1683c189cdafbed665e6ea9 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Thu, 16 Mar 2017 13:40:37 -0400 Subject: [PATCH] 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 --- libexec/bats | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libexec/bats b/libexec/bats index 5cd95c6..7dc0c14 100755 --- a/libexec/bats +++ b/libexec/bats @@ -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"