Skip to content
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

implement --no-only flag functionality #572

Merged
merged 1 commit into from Jan 26, 2022

Conversation

jocrah
Copy link
Contributor

@jocrah jocrah commented Jan 22, 2022

Summary

This pr implements the functionality stated in #569.

How it works

By passing a --no-only flag while running tape tests (eg. tape **/*test.js --no-only), any test.only unintentionally left in any of the tests causes an error to be thrown to make tests fail.

This behaviour can alternatively be achieved by setting the environmental variable NODE_TAPE_NO_ONLY_TEST to true.

Co-authored-by: Joshua Ocrah <ocrahjoshua@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Copy link
Collaborator

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since test files can be run with either tape test.js or node test.js, my hope would be that the env var would apply to both cases.

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
test/no_only.js Outdated Show resolved Hide resolved
@jocrah jocrah force-pushed the ft-add-no-only-flag branch 4 times, most recently from 89e5e9b to 3dbd17a Compare January 23, 2022 20:43
index.js Outdated Show resolved Hide resolved
readme.markdown Outdated Show resolved Hide resolved
readme.markdown Show resolved Hide resolved
readme.markdown Show resolved Hide resolved
readme.markdown Outdated Show resolved Hide resolved
test/no_only.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to improve this by passing an option explicitly into tape.run, but because of the way the lazy loader works, i'm not sure how well that'd work.

@jocrah
Copy link
Contributor Author

jocrah commented Jan 24, 2022

I tried to improve this by passing an option explicitly into tape.run, but because of the way the lazy loader works, i'm not sure how well that'd work.

o okay yea understood, also been trying to debug the exit code being 8 for the node version 0.10, read around it and got to know some earlier versions of node used it for uncaught exceptions but not sure what can be done yet at our end

@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2022

ah right, forgot about that. i'll take a quick look locally.

@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2022

I see that 0.10 and 0.8 both have different kinds of failures, including some exit codes of 127. io.js v3.0-v3.2 seem to have similar failures. I'd prefer not to start making these fail, so let's look more into them.

I've rebased on top of a commit that fixes the 16.9/16.10 failures.

@jocrah
Copy link
Contributor Author

jocrah commented Jan 24, 2022

I see that 0.10 and 0.8 both have different kinds of failures, including some exit codes of 127. io.js v3.0-v3.2 seem to have similar failures. I'd prefer not to start making these fail, so let's look more into them.

okay got it, thanks. Earlier today, tried 0.8 locally and did not get the tests introduced in this pr failing (I guess could depend on the specific patch version).

Please do you mean some other tests failed also with the 127 exit code or these same tests?

@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2022

At this point (and we can check once CI is completed) i think all the remaining failures are:

  • 0.6 (and i think 0.9), which always fail
  • node 0.8, 0.10, 3.0, 3.1, and 3.2, failing on test/no_only.js

The latter is my concern.

@jocrah
Copy link
Contributor Author

jocrah commented Jan 24, 2022

so after trying locally, I see the iojs 3.0, 3.1 and 3.2 failures are related to some stack-buffer overflow error related to nodejs/node#2581, and fixed i think for latter versions?

@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2022

hmm, meaning what, that this one test file is triggering a bug, but no other test files have triggered it before?

@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2022

hmm, oddly enough locally v3.3 fails, but it passes in CI.

@ljharb
Copy link
Collaborator

ljharb commented Jan 25, 2022

hmm, when i run the test file by itself, it fails consistently for me locally, but when i run the full suite, it passes. That's concerning.

@ljharb
Copy link
Collaborator

ljharb commented Jan 25, 2022

ok, figured that last one out; when specifying env, the PATH has to be explicitly passed down.

@ljharb ljharb force-pushed the ft-add-no-only-flag branch 2 times, most recently from adc1f22 to eaaef47 Compare January 25, 2022 03:32
@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2022

Codecov Report

Merging #572 (2fb5a66) into master (8594f3b) will increase coverage by 0.32%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #572      +/-   ##
==========================================
+ Coverage   96.03%   96.36%   +0.32%     
==========================================
  Files           4        4              
  Lines         631      632       +1     
  Branches      147      148       +1     
==========================================
+ Hits          606      609       +3     
+ Misses         25       23       -2     
Impacted Files Coverage Δ
index.js 98.11% <100.00%> (+0.01%) ⬆️
lib/test.js 95.42% <0.00%> (+0.28%) ⬆️
lib/results.js 100.00% <0.00%> (+0.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8594f3b...2fb5a66. Read the comment docs.

test/no_only.js Outdated Show resolved Hide resolved
@jocrah
Copy link
Contributor Author

jocrah commented Jan 25, 2022

hmm, meaning what, that this one test file is triggering a bug, but no other test files have triggered it before?

yea quite interesting. Looking at the already existing tests, I don't think we've had the use-case of testing the stderr output of any thrown error for those particular node versions (3.0,3.1 and so on)

Locally ( on the master branch), I added a tape test file that had multiple only tests to trigger the existing error we have where there is supposed to be just one only test.

I then tried to run a similar tap test (using the child process spawn) on the tape file using iojs 3.2, it still had the stack error instead of the expected error

@ljharb
Copy link
Collaborator

ljharb commented Jan 25, 2022

When I use iojs v3.2, and I run tape --no-only test-b.js, i get an exit code of 1 and the expected output - is the bug just around spawn?

@jocrah
Copy link
Contributor Author

jocrah commented Jan 25, 2022

o okay interesting, yea most likely something around that.

@ljharb
Copy link
Collaborator

ljharb commented Jan 25, 2022

I've switched from spawn to exec; that seems like it'll fix it :-)

@jocrah
Copy link
Contributor Author

jocrah commented Jan 25, 2022

okay seen, nice!

@jocrah
Copy link
Contributor Author

jocrah commented Jan 25, 2022

then I think the main thing left will be the differences in error exit code now. Checking the iojs 3.2 build, I see failure is now related to an exit code of 134instead of the expected 1

@ljharb
Copy link
Collaborator

ljharb commented Jan 25, 2022

yeah, i locally changed the ok to a match, and i see it's the exact node bug you linked.

@ljharb
Copy link
Collaborator

ljharb commented Jan 25, 2022

I went ahead and TODOd the tests for node 0.8, 0.10, and 3.0-3.2.

@jocrah
Copy link
Contributor Author

jocrah commented Jan 25, 2022

okay cool, this was fun 😄, thanks for the review and insights @ljharb

@ljharb ljharb merged commit 2fb5a66 into tape-testing:master Jan 26, 2022
@jocrah jocrah deleted the ft-add-no-only-flag branch January 26, 2022 10:26
ljharb added a commit that referenced this pull request Jan 26, 2022
Co-authored-by: Joshua Ocrah <ocrahjoshua@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
ljharb added a commit that referenced this pull request Jan 26, 2022
 - [New] add `--no-only` flag/`NODE_TAPE_NO_ONLY_TEST` (#572)
 - [New] `t.match`/`t.doesNotMatch: fail the test instead of throw on wrong input types.
 - [Fix] `bin/tape`: delay requires until needed
 - [Robustness] use cached `.test`
 - [readme] hard wraps bad, soft wraps good
 - [readme] port changes from v5
 - [meta] fix `prelint` so it does not fail outside of a git repo
 - [meta] better `eccheck` command
 - [meta] Exclude `fs` from browser bundles (#565)
 - [actions] reuse common workflows
 - [actions] update codecov uploader
 - [Deps] update `object-inspect`, `resolve`, `glob`, `is-regex`, `string.prototype.trim`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `safe-publish-latest`, `array.prototype.flatmap`
 - [Tests] handle a broken error `cause` in node 16.9/16.10
 - [Tests] handle carriage returns in stack traces on Windows
ljharb added a commit that referenced this pull request Jan 26, 2022
v4.15.0

 - [New] add `--no-only` flag/`NODE_TAPE_NO_ONLY_TEST` (#572)
 - [New] `t.match`/`t.doesNotMatch: fail the test instead of throw on wrong input types.
 - [Fix] `bin/tape`: delay requires until needed
 - [Robustness] use cached `.test`
 - [readme] hard wraps bad, soft wraps good
 - [readme] port changes from v5
 - [meta] fix `prelint` so it does not fail outside of a git repo
 - [meta] better `eccheck` command
 - [meta] Exclude `fs` from browser bundles (#565)
 - [actions] reuse common workflows
 - [actions] update codecov uploader
 - [Deps] update `object-inspect`, `resolve`, `glob`, `is-regex`, `string.prototype.trim`
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `safe-publish-latest`, `array.prototype.flatmap`
 - [Tests] handle a broken error `cause` in node 16.9/16.10
 - [Tests] handle carriage returns in stack traces on Windows
ljharb added a commit that referenced this pull request Jan 26, 2022
 - [New] add `--no-only` flag/`NODE_TAPE_NO_ONLY_TEST` (#572)
 - [meta] fix `prelint` so it does not fail outside of a git repo
 - [Dev Deps] update `eslint`
 - [Tests] handle a broken error `cause` in node 16.9/16.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants