Skip to content

Conversation

@mbland
Copy link
Owner

@mbland mbland commented Feb 12, 2017

This was all done during the course of preparing an implementation of ./go new to address #142. Of particular note:

  • a tweak to .gitignore encouraging the use of $HOME/.config/git/ignore
  • the addition of @go.test_compgen to lib/testing/environment
  • the spawning of issue Extract lib/bats/function from lib/bats/assertions #156
  • the vast improvement in performance of the command-descriptions/from-file test

See the commit messages for details and timing examples.

This is in anticipation of adding a `--test` option to the forthcoming
`./go new` test file generator.
Regarding the claim that this new function is faster than the old
hand-written loops, here are representative timings for the command:

  TEST_FILTER='(directories|: tab completion$)' gos test complete get/

For hand-written loops:

  43 tests, 0 failures, 39 skipped

  real    0m7.020s
  user    0m3.352s
  sys     0m3.473s

For `@go.test_compgen`:

  43 tests, 0 failures, 39 skipped

  real    0m6.367s
  user    0m3.071s
  sys     0m3.104s

Considering the fact that most of that time was spent skipping 39 tests,
the result is pretty substantial. Even beyond that, it provided the
insight that led to filing issue #156.
The reason this test suite was so slow before was because the test cases
made direct calls to the functions under test instead of wrapping them
inside `TEST_GO_SCRIPT`. The functions would then call other functions,
then call other functions in loops, and so on, causing Bats to do a lot
of work building stack traces with every call.

A sample time before this change on my macOS MacBoook Pro:

  6 tests, 0 failures

  real    0m6.554s
  user    0m2.820s
  sys     0m3.487s

A sample time after:

  6 tests, 0 failures

  real    0m2.316s
  user    0m1.010s
  sys     0m1.204s

I expect the difference to be even more dramatic on Windows.
@mbland mbland added this to the v1.4.0 milestone Feb 12, 2017
@mbland mbland self-assigned this Feb 12, 2017
@mbland mbland merged commit 3c1aa6e into master Feb 12, 2017
@mbland mbland deleted the improvements branch February 12, 2017 21:53
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 95.256% when pulling b9152d2 on improvements into abe6a54 on master.

mbland added a commit that referenced this pull request Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants