-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Retry long path tests on Linux under real tmp dir #3929
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,32 +3,44 @@ var common = require('../common'); | |
var fs = require('fs'); | ||
var path = require('path'); | ||
var assert = require('assert'); | ||
var os = require('os'); | ||
|
||
var successes = 0; | ||
// when it fails test again under real OS tmp dir on Linux when it is | ||
// readable/writable to avoid failing tests on ecryptfs filesystems: | ||
// https://github.com/nodejs/node/issues/2255 | ||
// it follows advice in comments to: | ||
// https://github.com/nodejs/node/pull/3925 | ||
try { | ||
common.refreshTmpDir(); | ||
testFsLongPath(common.tmpDir); | ||
common.refreshTmpDir(); | ||
} catch (e) { | ||
if (os.type() == 'Linux') { | ||
fs.accessSync(os.tmpdir(), fs.R_OK | fs.W_OK); | ||
var tmpDir = path.join(os.tmpdir(), | ||
'node-' + process.version + '-test-' + (Math.random() * 1e6 | 0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use a template string to shorten this |
||
fs.mkdirSync(tmpDir); | ||
testFsLongPath(tmpDir); | ||
fs.rmdirSync(tmpDir); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
|
||
// make a path that will be at least 260 chars long. | ||
var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1); | ||
var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); | ||
var fullPath = path.resolve(fileName); | ||
function testFsLongPath(tmpDir) { | ||
|
||
common.refreshTmpDir(); | ||
// make a path that will be at least 260 chars long. | ||
var fileNameLen = Math.max(260 - tmpDir.length - 1, 1); | ||
var fileName = path.join(tmpDir, new Array(fileNameLen + 1).join('x')); | ||
var fullPath = path.resolve(fileName); | ||
|
||
console.log({ | ||
filenameLength: fileName.length, | ||
fullPathLength: fullPath.length | ||
}); | ||
|
||
fs.writeFile(fullPath, 'ok', function(err) { | ||
if (err) throw err; | ||
successes++; | ||
|
||
fs.stat(fullPath, function(err, stats) { | ||
if (err) throw err; | ||
successes++; | ||
console.log({ | ||
filenameLength: fileName.length, | ||
fullPathLength: fullPath.length | ||
}); | ||
}); | ||
|
||
process.on('exit', function() { | ||
fs.writeFileSync(fullPath, 'ok'); | ||
fs.statSync(fullPath); | ||
fs.unlinkSync(fullPath); | ||
assert.equal(2, successes); | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
perhaps use
process.platform == 'linux'
instead?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.
@jbergstroem Yes, it would be the same. This code already uses the
os
module for other things so it seemed to make sense to use the normalized name for the comparison but it could testprocess.platform
oros.platform()
just as well asos.type()
. I can change it if that's what's holding the PR #3936 back.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.
process.platform
is a little more idiomatic, at least w.r.t. to the test suite.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.
@bnoordhuis @jbergstroem Done. It's using process.platform now. See: 2f5ca5d