-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
Fix build and test bugs in #1498 and #1479 #1504
Conversation
The commit messages should also have quite a bit of info on the details. |
4f32bc4
to
3dee7d3
Compare
P.S. One thing I am not totally not sure about, is where to put the Right now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make better usage of npm's lifetime events. Also I have questions about how run-them-all
works and the merits of it.
test/call-test.js
Outdated
it("does not throw when the call stack is empty", function (done) { | ||
if (!supportPromise) { return this.skip(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to return here. To my knowledge, this.skip()
throws a special error (SkipError
?) that mocha is expecting so execution should stop immediately. Then you can remove the eslint toggle.
MINOR: You can inline the conditional since it's only used/checked once.
@@ -167,6 +169,7 @@ describe("sinonSandbox", function () { | |||
|
|||
// eslint-disable-next-line mocha/no-identical-title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do they have identical titles? That's weird. I realize it isn't your change though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that too - I couldn't tell immediately, and decided not to tackle it now.
package.json
Outdated
"test-coverage": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ mochify-istanbul --exclude '**/+(test|node_modules)/**/*' --report text --report lcovonly --dir ./coverage ] test/", | ||
"test-cloud": "npm run test-headless -- --wd", | ||
"test-webworker": "browserify --no-commondir --full-paths -p [ mocaccino -R spec --color ] test/webworker/webworker-support-assessment.js | phantomic --web-security false", | ||
"test": "npm run test-node && npm run test-headless && npm run test-webworker", | ||
"test": "run-p test-node test-headless && run-s build test-webworker", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the output corrupted when running in parallel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could absolutely have been an issue, but the startup time of the phantom stuff actually makes it sequential by chance. You are probably right that it doesn't make sense to save 1.5 seconds in risk of having garbled output. I usually parellize tasks when having interactive/watched builds, where I don't really care all that much.
package.json
Outdated
"lint": "eslint .", | ||
"precommit": "lint-staged", | ||
"prepublish": "rimraf pkg && ./build.js", | ||
"build": "rimraf pkg && ./build.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use prebuild
for the cleanup.
package.json
Outdated
@@ -16,14 +16,15 @@ | |||
"scripts": { | |||
"test-node": "mocha --recursive -R dot test/", | |||
"test-dev": "npm run test-node -- --watch -R min", | |||
"test-headless": "mochify --recursive -R dot --grep WebWorker --invert test/", | |||
"test-headless": "mochify --recursive -R dot --grep WebWorker --invert --plugin [proxyquire-universal] test/", | |||
"test-coverage": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ mochify-istanbul --exclude '**/+(test|node_modules)/**/*' --report text --report lcovonly --dir ./coverage ] test/", | |||
"test-cloud": "npm run test-headless -- --wd", | |||
"test-webworker": "browserify --no-commondir --full-paths -p [ mocaccino -R spec --color ] test/webworker/webworker-support-assessment.js | phantomic --web-security false", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of changing the externals, why don't you make build
a requirement for test-webworker
?
pretest-webworker: 'npm run build',
This change would theoretically allow you to revert every instance where you used run-s
(travis.yml
and package.json
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't aware that adding pre
was a general pattern outside of the standard lifecycle methods (publish, install, ...). You learn something every day 😄 Good improvement!
Having it as a dependency solves the grievances I had otherwise.
package.json
Outdated
@@ -16,14 +16,15 @@ | |||
"scripts": { | |||
"test-node": "mocha --recursive -R dot test/", | |||
"test-dev": "npm run test-node -- --watch -R min", | |||
"test-headless": "mochify --recursive -R dot --grep WebWorker --invert test/", | |||
"test-headless": "mochify --recursive -R dot --grep WebWorker --invert --plugin [proxyquire-universal] test/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing is off (different) from all the others below.
This looks great! I don't have anything to add other than what was already pointed out by @fearphage |
Thanks for the review, @fearphage. Good tips on the lifecycle events. Regarding the merits of Typically: The parallel stuff is more of a side-note. I can remove it, no problem, but I think it has some (minor) merit, just because we can't work much with readability when being restricted to oneliners. |
I'm not against it. Just making sure it's worthwhile. If it simplifies things, then I'm all for it. Questions:
|
@fearphage This is an example run where to scripts simply do
Doing So yes, you can tell what failed from the output ( |
Got a strange error about `require.resolve` not being a function. This has probably to do with the browserify transform only working on the top-most scope (a theory - not vetted). By moving the require statement up this seems to have been fixed.
This commit reintroduces the proxyquire-universal changes that caused some issues (see sinonjs#1498 and commit cbf1128). What is different is that it removes proxyquire from the build step. This should never have been there, and was probably introduced to make proxyquire calls in the tests work with browsers. The problem was that the tests are not using the built sinon file, so the config changes would only be utilized for the built file. By adding the proxquire-universal plugin to the NPM script "test-headless" it would only take place for these tests and the cloud tests (which are reusing the headless config). This commit, along with the previous, fixes sinonjs#1498.
Sounds legit to me. 👍 |
e429322
to
47111df
Compare
The WebWorker test in PR sinonjs#1479 seems to fail for some mysterious reason with a synchronous XHR requests. The reason was most probably the importScript('../../pkg/sinon.js') call in the webworker file was referencing a build file that wasn't built. By now explicitly building this file as part of the test run this error has now disappeared locally, and probably will disappear on CircleCI as well. fixes the build in sinonjs#1479
47111df
to
521a0f7
Compare
As I have addressed all the issues, I'll merge this. |
Well done! |
Btw, this should pave the way for releasing 3.0; not sure if it hinges on #1502 |
Purpose
Should fix the errors we are seeing in #1498, introduced by a proxyquire config bug, as well as a case of a missing file causing trouble for the builds in #1479.
Background (Problem in detail) - optional
See the discussion in #1498 and #1479.
How to verify - mandatory
npm install
npm test
npm run test-cloud
Those steps cover #1498.
To test that #1479 failed before, but not after, do this for on
master
and on this branch:rm -r pkg
npm test