test: do not write fixture in test-require-symlink#15067
test: do not write fixture in test-require-symlink#15067Trott wants to merge 1 commit intonodejs:masterfrom
Conversation
There was a problem hiding this comment.
This could be dirName or tmpDirTarget.
There was a problem hiding this comment.
This could be dirName or tmpDirTarget.
There was a problem hiding this comment.
This could be dirName or tmpDirTarget.
There was a problem hiding this comment.
Wouldn't you rather execSync('cp -Rf Src Trg') / for windows execSync('xcopy /E /Y Src Trg')?
There was a problem hiding this comment.
I prefer the more verbose way here because:
- there's no difference between Windows and POSIX test code that way
- it does not depend on even the most mundane external dependency.
execSync always feels like a code smell to me, although it's almost certainly not going to cause problems here.
I admit my reasons are not super-compelling but I'm also not sure the counter-arguments are super-compelling either. I'll certainly change it if this is a blocking objection. :-)
There was a problem hiding this comment.
I'm not too thrilled about this (I know it was like this before). I rather have an emperical test:
const symLinkTest = path.join(common.tmpDir, 'symLinkTest .js');
try {
fs.symlinkSync(__filename, symLinkTest);
} catch (e) {
assert.strictEqual(e.code, 'EPERM');
common.skip('insufficient privileges');
}There was a problem hiding this comment.
Sure, done! (I changed the assert to an if ... throw.)
There was a problem hiding this comment.
Does this need to be tested upfront as opposed to wrapping the actual symlink calls in the test in a try-catch block?
There was a problem hiding this comment.
Hmmm...maybe even better: It looks like there's a common.canCreateSymlink() used in two files. I can use it here.
fea8367 to
b49c223
Compare
|
Ping @Trott |
4383a34 to
3f1c2de
Compare
There was a problem hiding this comment.
Does this need to be tested upfront as opposed to wrapping the actual symlink calls in the test in a try-catch block?
6443815 to
59f37e4
Compare
|
@refack Is this OK by you as is, or do you object? If you want changes, can you clarify what changes you'd like to see? |
|
|
New CI (so this could land as soon as): https://ci.nodejs.org/job/node-test-pull-request/10092/ |
|
This failed CI across the board: |
|
Hmmm...passing for me locally. But obviously not in CI.... will take a look... |
|
Odd. When I log in to a CI machine where it's failing and run the test from the CLI there, it works fine. |
|
|
|
@refack Tried both |
|
I added some logging of the error in CI and it seems like |
|
Ah! Looks like symlinking with a full path messes things up because of a symlink higher up in the path. The tmp directories in test are symlinked to I'll fix the test to use relative paths for symlinking all within the tmp dir. |
|
OK, hopefully that fixes it... |
|
Cleaned up the test but missed cleaning up the fixture which still refers to the full path of the tmp directory... |
test-require-symlink modifies the fixture directory by adding a symlink. Copy the fixture to the test tmpdir instead of modifying the fixture directory. This also uses a more empirical test for checking for the ability to make symlinks on Windows.
|
OK, results look much better that time, but a few infra-related issues, some of which are now fixed, so one more time... |
|
@Trott the CI seems fine (the linter is failing often... I do not know why but maybe a eslint update might help - or does someone know where the errors might come from?). Is this ready to land? |
test-require-symlink modifies the fixture directory by adding a symlink. Copy the fixture to the test tmpdir instead of modifying the fixture directory. This also uses a more empirical test for checking for the ability to make symlinks on Windows. PR-URL: nodejs#15067 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Landed in 6f34076 |
test-require-symlink modifies the fixture directory by adding a symlink. Copy the fixture to the test tmpdir instead of modifying the fixture directory. This also uses a more empirical test for checking for the ability to make symlinks on Windows. PR-URL: #15067 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
test-require-symlink modifies the fixture directory by adding a symlink. Copy the fixture to the test tmpdir instead of modifying the fixture directory. This also uses a more empirical test for checking for the ability to make symlinks on Windows. PR-URL: nodejs/node#15067 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
test-require-symlink modifies the fixture directory by adding a symlink. Copy the fixture to the test tmpdir instead of modifying the fixture directory. This also uses a more empirical test for checking for the ability to make symlinks on Windows. PR-URL: nodejs/node#15067 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported |
test-require-symlink modifies the fixture directory by adding a symlink.
Copy the fixture to the test tmpdir instead of modifying the fixture
directory.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test module