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

146 Commits

Author SHA1 Message Date
Mike Bland
8c4a86d534
format-tap: Refactor summary to remove subshells
While the performance impact of these changes are in the noise under
macOS 10.12.3 on a on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and
8GB 1867MHz DDR3 RAM, eliminating these subshells makes the code more
consistent.

I did try removing `buffer` to eliminate yet more subshells, but the
flickering of the output did prove annoying, so I'm not removing it.
2017-09-30 15:12:38 -04:00
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
7bcbb2f3e9
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
2017-09-30 15:12:38 -04:00
Mike Bland
d4443adeb7
bash: Refactor expand_path
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.25s) from the current test suite.

Before the change:

  46 tests, 0 failures

  real    0m3.851s
  user    0m2.273s
  sys     0m1.166s

After the change:

  real    0m3.595s
  user    0m2.171s
  sys     0m1.048s
2017-09-30 15:12:38 -04:00
Mike Bland
daf76c27c1
bats: Convert abs_dirname to use printf -v
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.1s) from the current test suite.

Before the change:

  46 tests, 0 failures

  real    0m3.983s
  user    0m2.320s
  sys     0m1.241s

After the change:

  real    0m3.861s
  user    0m2.276s
  sys     0m1.174s
2017-09-30 15:12:38 -04:00
Mike Bland
cdc55ad7ea
bats: Refactor resolve_link, abs_dirname
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.4s) from the current test suite.

Before the change:

  46 tests, 0 failures

  real    0m4.392s
  user    0m2.489s
  sys     0m1.467s

After the change:

  real    0m3.980s
  user    0m2.312s
  sys     0m1.233s
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
3ab495fda2
preprocess: Add tests for vars, quotes in names
This is in anticipation of refactoring away the `$(eval echo
"$quoted_name")` command substitution.
2017-09-30 15:12:38 -04:00
Mike Bland
fac51df957
exec-test: Replace caller with FUNCNAME, etc.
This is part of the effort to improve performance by reducing the number
of command substitutions/subshells spawned by `bats_debug_trap`.

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 makes `bin/bats test/` go from the
following for the previous commit:

  44 tests, 0 failures

  real    0m5.293s
  user    0m2.853s
  sys     0m2.087s

to:

  real    0m4.319s
  user    0m2.559s
  sys     0m1.454s
2017-09-30 15:12:38 -04:00
Mike Bland
e613b31a1c
exec-test: Replace || { } with if [[ ]]; then
Somehow this is ever-so-slightly faster.
2017-09-30 15:12:37 -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
Mike Bland
d294689bdd
exec-test: Use printf -v in bats_extract_line
Also replaces `sed` invocation with a `while` loop, saving a subprocess.
2017-09-30 15:12:37 -04:00
Mike Bland
698fa766a3
exec-test: Replace type -t with command -F
Also eliminates a subshell.
2017-09-30 15:12:37 -04:00
Mike Bland
3bc03796e9
exec-test: Use printf -v in bats_strip_string 2017-09-30 15:12:37 -04:00
Mike Bland
eaa151fb69
exec-test: Use printf -v in bats_trim_filename 2017-09-30 15:12:37 -04:00
Mike Bland
39440c5782
exec-test: Replace dirname call with %/* 2017-09-30 15:12:37 -04:00
Mike Bland
93d3cec96f
exec-test: Use printf -v in bats_frame_* functions
This is part of the effort to improve performance by reducing the number
of command substitutions/subshells spawned by `bats_debug_trap`.

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 makes `bin/bats test/` go from:

  44 tests, 0 failures

  real    0m7.565s
  user    0m3.664s
  sys     0m3.368s

to:

  real    0m6.449s
  user    0m3.290s
  sys     0m2.665s
2017-09-30 15:12:37 -04:00
Mike Bland
a3396cbc89
exec-test: Refactor bats_frame_* functions
Preserves existing behavior. Next step will be to take the target
variable name as the second argument.
2017-09-30 15:12:36 -04:00
Mike Bland
55bf719772 Merge pull request #10 from bats-core/ci-configs
Add Appveyor configuration, update Travis CI configuration, fix macOS bug
2017-09-30 15:11:53 -04:00
Mike Bland
0f6dde530e
exec-test: Work around Bash 3.2.57 ERR trap bug
When running under Bash 3.2.57(1)-release on macOS, the following tests
would fail because `BATS_ERROR_STACK_TRACE` would be empty, and hence no
information about the actual error would get printed:

- one failing test
- failing test with significant status
- failing test file outside of BATS_CWD

This is because each of these cases use `FIXTURE_ROOT/failing.bats`, and
the `ERR` trap would not fire for its `eval "( exit ${STATUS:-1} )"`
line. Changing it to `exit ${STATUS:-1}` produced the same effect, and
changing it to `return ${STATUS:-1}` would cause the output to point to
the previous line, which executes `true`.

However, the correct status would be reported to the `EXIT` trap, so now
we call `bats_error_trap` at the very beginning of `bats_teardown_trap`.

All the existing tests now pass under Bash 3.2.57(1)-release, Bash
4.2.25(1)-release (the version from the default Ubuntu 12.04.5/Precise
image on Travis CI), and Bash 4.4.12(1)-release.
2017-09-30 14:58:10 -04:00
Mike Bland
918714dd4d
test/bats: Add statements to debug Travis macOS
The following build is demonstrating failures I can't reproduce on my
own macOS system:

  https://travis-ci.org/bats-core/bats-core/jobs/281719290
2017-09-30 14:51:45 -04:00
Mike Bland
d310b25911
.travis.yml: Enable macOS builds
Also sets the `language` to `bash`.
2017-09-30 14:42:21 -04:00
Mike Bland
bbac787615
.travis.yml: Prefix test command with time
As with the update to .appveyor.yml in the previous commit, this enables
us to get an idea of the performance impact of a change.
2017-09-30 14:42:10 -04:00
Mike Bland
5e752ee914
.appveyor.yml: Prefix test command with time
This enables us to get an idea of the performance impact of a change.
2017-09-30 14:42:01 -04:00
Mike Bland
d9ee4168ed
Add .appveyor.yml
This follows the example from https://www.appveyor.com/docs/lang/ruby/
except that it doesn't need `install` or `before_test` steps.
2017-09-30 14:41:52 -04:00
Bianca Tamayo
aaf62cd9d8 Merge pull request #6 from peteruhnak/patch-1
Minor fix in the installation snippet
2017-09-25 21:12:47 -07:00
Peter Uhnak
3a6efc03cf Minor fix in the install command 2017-09-25 10:07:42 +02:00
Bianca Tamayo
c85f340f1e Added IRC channel info 2017-09-24 11:01:48 -07:00
Bianca Tamayo
8ca0685b85 Updating paths #5
FullSemver: 0.4.1+9
Branch: master
2017-09-24 10:26:25 -07:00
Bianca Tamayo
e3b37da3a4 Added Travis CI Badge to master branch README 2017-09-24 10:04:14 -07:00
Bianca Tamayo
b72cd3545b Updated repo name in README 2017-09-20 15:28:45 -07:00
Bianca Tamayo
d0f06d1f0d Added description & info about this repo in README 2017-09-19 14:55:18 -07:00
Sam Stephenson
03608115df Adopt Contributor Covenant 1.4 2016-02-19 12:28:02 -06:00
Mislav Marohnić
955309ab94 Merge pull request #90 from Sylvain303/master
saving $IFS in run() not altered for code using it
2015-02-26 11:04:38 +13:00
Sylvain
5fe46a0893 pull #90 quote every string compare
test are all successful.
2015-01-30 13:08:27 +01:00
Sylvain
1735a4fcd2 saving $IFS in run() not altered for code using it
IFS was modified by run() becoming '\n' and so relying to its bash default
was failing tests.

Also some wrong tests corrected because was relying on this behavior to pass.

Fix #89
2015-01-29 20:51:49 +01:00
Sam Stephenson
3b33a5ac6a Merge pull request #76 from jwerle/patch-1
Update package.json
2014-10-16 09:44:15 -05:00
Joseph Werle
eb120d944e Update package.json 2014-10-15 16:05:16 -04:00
Sam Stephenson
7b032e4b23 Bats 0.4.0 2014-08-13 09:59:22 -05:00
Sam Stephenson
d6d185ad5b Update copyright year 2014-08-13 09:58:34 -05:00
Sam Stephenson
d628bd7251 Merge pull request #68 from duggan/test-summaries
Test summaries
2014-08-13 08:48:28 -05:00
Henrique Moody
3be82466a7 Add skipped count tests in the summary
This also update the behaviour of the summary, now it only display the
number of failures, and skipped tests also, if the numbers are greater
than zero.
2014-08-13 14:32:35 +01:00
Sam Stephenson
2c6fed1838 Print the outermost, not innermost, failed command
The outermost command—i.e. the line that failed inside the test case function itself—is more likely to be meaningful at a glance than the innermost command, which might be e.g. the implementation of a helper assertion.
2014-08-12 17:28:03 -05:00
Sam Stephenson
a715fff30a Print filenames relative to the working directory 2014-08-12 16:56:52 -05:00
Sam Stephenson
716d2d62ed Print the failing status code, if it's significant 2014-08-12 16:45:51 -05:00
Sam Stephenson
81be444b3b bats_frame_filename normalizes test filenames 2014-08-12 15:14:16 -05:00
Sam Stephenson
ec6fbc10f1 Split print_failed_command from print_stack_trace 2014-08-12 15:04:18 -05:00
Sam Stephenson
c010220e7a Merge remote-tracking branch 'ahippo/print-failed-command' into print-failed-command
Conflicts:
	libexec/bats-exec-test
2014-08-12 12:19:00 -05:00
Sam Stephenson
f193ddbe4e Refactor the stack trace-capturing debug trap 2014-08-12 10:31:22 -05:00