1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-09-29 20:48:27 +02:00
Commit Graph

12 Commits

Author SHA1 Message Date
Mike Bland
f5acd28612
bats-exec-suite: Count tests w/ BATS_TEST_PATTERN
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.16s) from the current test suite.

Before this change:

  46 tests, 0 failures

  real    0m3.541s
  user    0m2.125s
  sys     0m0.937s

After this change:

  real    0m3.372s
  user    0m2.031s
  sys     0m0.894s
2017-09-30 15:12:38 -04:00
Mike Bland
6beea07a0b
preprocess: Eliminate eval in subshell
This is part of the effort to improve performance by reducing the number
of command substitutions/subshells.

Under Bash 3.2.57(1)-release on a MacBook Pro with a 2.9GHz Intel Core
i5 CPU and 8GB 1867MHz DDR3 RAM, this shaves off O(0.15s) from the test
suite at the previous commit, but I anticipate this effect being
magnified on Windows platforms.
2017-09-30 15:12:38 -04:00
Mike Bland
741c414d6a
preprocess: Use printf -v in encode_name 2017-09-30 15:12:37 -04:00
Mike Bland
cf9a3b8af4
exec-test: Invoke bats-preprocess directly
Also, `bats-preprocess` now converts DOS/Windows CRLF line endings.
2017-09-30 15:12:37 -04:00
Sam Stephenson
1041e46f39 Support single-line test definitions 2013-11-17 13:04:57 -06:00
Sam Stephenson
08374f7269 Avoid expr for faster preprocessing 2013-11-17 12:34:13 -06:00
Sam Stephenson
bfa4ebcd0f Prefer let x+=1 for incrementing counters
The `((x++))` syntax is shorthand for `let x++`. According to `help let`:

    If the last ARG evaluates to 0, let returns 1; 0 is returned
    otherwise.

Thus the exit status of the expression `x=0; let x++` is 1, since the post-increment `++` operator evaluates to the value of the variable before incrementing.

In Bash 4, this non-zero exit status properly triggers `set -e`'s error trap, but in Bash 3 it does not. That's why the tests were passing on OS X (Bash 3) but not Linux (Bash 4).

We can work around the problem by choosing an incrementation expression that never evaluates to 0, such as `+=` or the pre-increment `++` operator. For consistency and clarity, I've changed to `x+=1` everywhere.

Ref. #25, #27
2013-10-28 21:01:51 -05:00
Sam Stephenson
7849374964 bats_test_info -> bats_test_begin; begin calls setup 2013-10-21 11:21:17 -05:00
Sam Stephenson
040deba950 Merge pull request #6 from mislav/echo-e-fix
fix preprocessing tests that have lines beginning with -e
2013-04-12 14:49:12 -07:00
BinaryBabel OSS
d2067db1b4 Remove redundant anchor in preprocess expression
Expr patterns are anchored to the beginning by default. Specifying
the carrot is undefined behavior and generates warnings on some versions, obscuring the
output.
2013-04-12 14:35:15 -07:00
Mislav Marohnić
7cec3d6259 fix preprocessing tests that have lines beginning with -e 2013-04-06 14:01:03 +02:00
Sam Stephenson
c850527cce Initial commit 2011-12-28 12:40:14 -06:00