-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
test: create temp dir in common.js #1877
Conversation
// Create tmpDir if it does not exist | ||
if (! fs.existsSync(exports.tmpDir)) { | ||
fs.mkdirSync(exports.tmpDir); | ||
} |
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.
This will print a deprecation warning. Should probably use fs.acessSync
.
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.
Or just try { fs.mkdirSync(exports.tmpDir) } catch (ex) {}
?
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.
Hmmm...that will require a try
/catch
block which might have a more substantial affect on performance. Will try it anyway and see...
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.
Well technically fs.mkdirSync()
could still throw too, for example if permissions are wrong somehow. I doubt it there would be a measurable impact for tests, but even if there was, there's always moving it to a separate function I suppose to limit the scope of the deopt...
New commit pushed to use |
@@ -20,6 +20,13 @@ if (process.env.TEST_THREAD_ID) { | |||
} | |||
exports.tmpDir = path.join(exports.testDir, exports.tmpDirName); | |||
|
|||
// Create tmpDir if it does not exist | |||
try { | |||
fs.accessSync(exports.tmpDir); |
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 not just try { fs.mkdirSync(exports.tmpDir); }
? You don't need the accessSync()
call at all then. And mkdirSync()
being in the catch
block is wrong because it can still throw.
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.
My thinking was that if there is no temp directory and creating the temp directory failed, I wanted the CLI to blow up. I should change it to what you have and catch EEXIST and rethrow other errors, or something like that...
See: #1876 (comment) |
Pushed a new commit with POC attempt number 2. Features/concerns:
|
Move creation of temporary directories for tests out of the Python harness and into common.js. This allows all tests to be run reliably outside of the Python wrapper.
Just pushed a minor commit that tweaks the proposed |
@@ -12,6 +12,61 @@ exports.tmpDirName = 'tmp'; | |||
exports.PORT = +process.env.NODE_COMMON_PORT || 12346; | |||
exports.isWindows = process.platform === 'win32'; | |||
|
|||
var rimrafSync = function(p) { |
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.
can you change these to simple named functions please, assigning to variables is not idiomatic for this file
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.
OK, new commit pushed with the function declarations changed to conform with the prevailing idiom already in the file!
Function declarations converted to idiomatic style for common.js
https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/783/ this lgtm, anyone else want to signoff? |
LGTM |
fs.rmdirSync(p); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') | ||
return; |
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.
Anyway we are ignoring this error code. Should we really need this check?
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.
Are you talking about the check in line 43?
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.
Yes. That is kind of no-op in this context. Don't you think?
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.
Yes, I agree. I modeled it on https://github.com/isaacs/rimraf/blob/db4936530293eae3372ffe757fad2f378b1261c5/rimraf.js#L317-L318. I wonder if it's a hot path in that context. Anyway, I'll take it out and push another commit.
I pushed a new commit based on observation by @thefourtheye. Can someone push this through Jenkins CI again to confirm that it doesn't trigger an edge case on a particular OS or anything? (I'm assuming I can't trigger Jenkins myself.) |
Should I worry about the win2008r2 test failures? Or is that something that sort of just happens sometimes? |
They appear unrelated. |
So, given that two lines got deleted, once Jenkins finishes re-running, do we need to get a couple of LGTM's from the right folks again? /cc @Fishrock123 @rvagg (Does it need to re-run to see if the win2008r2 issues are just gremlins?) I'd love to get this in so I can pile some other stuff on top of it in other PRs before heading out to reportedly low-connectivity Walker Creek Ranch... |
Move creation of temporary directories for tests out of the Python harness and into common.js. This allows all tests to be run reliably outside of the Python wrapper. PR-URL: #1877 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Landed @ a6b8ee1, squashed into a single commit. didn't realise there were 3 until I started the process so I did the squash myself but in future @Trott maybe you could try and keep the PR to a single commit unless you're doing complex work across different concerns. It's sometimes handy to have multiple commits for review but they need to be squashed before landing so I tend to just Thanks for the contribution and I look forward to seeing the additional improvements you have here! |
Thanks @rvagg. I wasn't sure if I should squash everything every time or do one big squash after a couple of LGTMs so that people could follow along with the evolution of the changes if they wanted to. I had been doing both depending on what felt right for the particular situation. I'll try to make a point to always just squash squash squash (unless there's a super-compelling reason not to). |
For tests run outside the python harness (for example to
see console.error() messages for debugging), common.js
should create the testing temp directory if it does not
exist.
ref: #1876
This change does not seem to result in a significant performance hit as far as I can tell, but I welcome better benchmarks than my "run
time make test-parallel
" methodology.