-
Couldn't load subscription status.
- Fork 450
Initial code and test for duplicate test name warning. #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial code and test for duplicate test name warning. #9
Conversation
|
By way of review, I've pushed a new branch, dup-warning-#9, whereby I've rebased this branch onto Each individual commit message explains the rationale for each change. The final message shows that using a @BvBerkum Let me know if you have any questions or concerns, or how you'd like to proceed. Feel free to cherry-pick my commits onto your branch, or just copy the code. I still hope to merge #8 first, though it's not strictly necessary. cc: @btamayo |
|
OK, #8 has been merged, and I've rebased dup-warning-#9 upon it. The conflict in this branch is just where #8 and this PR both added a new test case to the end of |
|
Afterwards, I began thinking a bit more about the performance impact. I really just picked up this issue to refamiliarize myself with the BATS core code. Also having recently tried the optimized branch, I've been trying to get a bit more conscious about the resource footprint. E.g. I use a bats dry-run in my GIT pre-commit to verify the test cases parse OK. And on a modern macbook or cloud server its easy to forget what a little shell scripting can cost.. Anyway. I will return to the code during the week or next weekend probably, and look at your fixes @mbland. And try see about any performance hit in addition. |
|
@BvBerkum Have you the bandwidth to bang on this this weekend? Don't want to rush you, but I'd like to keep the momentum towards v1.0.0 going. Also, to the point about performance: I didn't start thinking about it until I had several hundred test cases for mbland/go-script-bash that were taking about an hour to run on Windows—then I thought about it a lot. ;-) Certainly the optimization techniques I applied to Bats would be overkill in most scripts, but for a test framework that executes Hence my obsession with performance in this context, in pursuit of the larger goal of "making the right thing the easy thing." |
|
I only found to time to mull it over a bit, but you're right, I'm too easily distracted by details. I'm talking about parsing 50 files with 300 tests or so. Rebasing on mbland-optimized shouldn't be a problem. I'll get to it one of these days. |
|
No worries, but two quick points:
|
Moving the first test case in between the two duplicate test cases caused a test failure, revealing the need to add `sort` in between `grep` and `uniq -d`.
Extracted this function to encapsulate the operation prior to future refactoring. It also fits better with the surrounding code style, whereby small functions provide documentation, even for single-line commands.
This achieves the same effect without launching a new process for the `test` command. Also, using a multi-line `if` statement and keeping the line length to under 80 columns helps with readability.
The `case` statement was a little difficult to read, and as it turns out, using `$FIXTURE_ROOT/duplicate-tests.bats` enables us to make an exact string comparison. Also added some `printf` statements to see more clearly what the results were when a test assertion fails.
The big thing I did in bats-core#8 was to eliminate as many subshells, pipelines, and subprocesses as possible. Even though we normally rely write scripts because of these features, in a framework like Bats, they add up quickly and can have a big performance impact—especially on Windows, especially when running virtualized. Conseqently, replacing the previous `grep` pipeline with a `while` loop causes the suite to run ~9% faster on macOS, and ~19% faster on Windows (running under VMWare). The following times were collected by running `time bin/bats test` on a: MacBook Pro Processor: 2.9 GHz Intel Core i5 RAM: 8 GB 1867 MHz DDR3 Bash 4.4.12(1)-release running on macOS 10.12.6 ----------------------------------------------- Before this change: 47 tests, 0 failures real 0m4.703s user 0m2.712s sys 0m1.570s After this change: 47 tests, 0 failures real 0m4.312s user 0m2.369s sys 0m1.166s Git for Windows Bash 4.4.12(1)-release running on Windows 10 under VMWare Fusion 8.5.8 ------------------------------------------------------------------ Before this change: 47 tests, 0 failures real 0m19.832s user 0m4.170s sys 0m8.893s After this change: 47 tests, 0 failures real 0m16.675s user 0m3.463s sys 0m7.297s
|
Hello @BvBerkum - if you've got the bandwidth to rebase @mbland's changes on to this branch please do so :) Otherwise either @mbland or I will create a new PR for these commits some time next week so we can move towards https://github.com/bats-core/bats-core/milestone/1 :) |
5f96384 to
fc41eb7
Compare
|
There you are. I'd hate to be the hold-up since I see the issues piling up again. I'll keep out an eye for anything else to do, if I can follow what the current focus is. I'm happy with my fork and it has been easy to integrate recent upstream changes, but hopefully Bats can get some new releases out and we can get everything together and not end up with Bats dialects or insufficiently specified versions. |
|
On top of @mbland's version, a few more tiny savings can be achieved if the inner while loop is removed. Like a couple of tens of milliseconds. |
|
@tterranigma I think that removing the inner while loop relies on spaces not being present in the test names. Apologies if I'm incorrect, I think for that change we'd have to add a test case with "gizmo test" and "gizmo test 2" to verify. My thinking: As for this change: LGTM, /cc @mbland |
|
@sublimino By the time the inner loop is hit, the test names are already converted to function names with dashes and underscores. The Bash variable substitutions a few lines above just capture these function names that are passed as an rfugment to bats_test_function. I think the conditional "hack" to replace the loop will work each time in this case. |
|
@tterranigma my mistake then, sorry! |
|
@mbland In retrospect it looks to me like the feature has significantly progressed from my initial features/duplicate-test-warning. I'm sorry for the confusion and time, please close the PR or advice. tia. |
|
@BvBerkum Sorry to leave you hanging; things were crazy in April. You should be able to merge dup-warning-#9 into your branch, then merge the current If you'd rather I do it, I can do it too. |
|
@mbland done |
Looked at and implemented an initial solution for the first unassigned issue in [sstephenson/bats#196]