-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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, fs: fix chmod mask testing on windows #12835
Conversation
Refs: #12803 |
test/parallel/test-fs-chmod.js
Outdated
@@ -139,5 +140,11 @@ if (fs.lchmod) { | |||
|
|||
|
|||
process.on('exit', function() { | |||
try { |
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 this added because the files being operated on are in the fixtures
dir? IMO, the test should be refactored to use the tmp dir instead so that we don't need to do this. Tests shouldn't modify files in fixtures. Then it can check mode on file creation too, I suppose.
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. Good idea!
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.
If I copy the files to common.tmpDir
it doesn't repro
/cc @nodejs/fs |
'use strict'; | ||
const common = require('../common'); | ||
if (common.isWindows) { | ||
// Windows only: Test fchmod on files with `attrib -a -i` |
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.
Obsolete)
See about |
@@ -0,0 +1,34 @@ | |||
'use strict'; | |||
const common = require('../common'); | |||
if (common.isWindows) { |
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 is not necessary if known_issues.status
is properly updated, if I get this right.
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'll need to set it to be excluded for every platform but windows.
This way seems less noisy...
test/parallel/test-fs-chmod.js
Outdated
const fixture2 = path.join(common.fixturesDir, 'a1.js'); | ||
const file1 = path.join(common.tmpDir, 'a.js'); | ||
const file2 = path.join(common.tmpDir, 'a1.js'); | ||
execSync(`copy ${fixture1} ${file1}`); |
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.
/bin/sh: copy: command not found
in Linux CI.
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.
fixed
const {execSync} = require('child_process'); | ||
const fs = require('fs'); | ||
|
||
ok(common.isWindows, "reset of test only for windows") |
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.
Linter:
11:22 error Strings must use singlequote quotes
11:55 error Missing semicolon semi
test/parallel/test-fs-chmod.js
Outdated
const file2 = path.join(common.fixturesDir, 'a1.js'); | ||
const file1 = path.join(common.tmpDir, Date.now() + 'duck.js'); | ||
const file2 = path.join(common.tmpDir, Date.now() + 'goose.js'); | ||
fs.writeFileSync(file1, "ga ga"); |
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.
Linter: 78:25 error Strings must use singlequote quotes
test/parallel/test-fs-chmod.js
Outdated
const file1 = path.join(common.tmpDir, Date.now() + 'duck.js'); | ||
const file2 = path.join(common.tmpDir, Date.now() + 'goose.js'); | ||
fs.writeFileSync(file1, "ga ga"); | ||
fs.writeFileSync(file2, "waq waq"); |
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.
Linter: 79:25 error Strings must use singlequote quotes
test/parallel/test-fs-chmod.js
Outdated
fs.writeFileSync(file1, "ga ga"); | ||
fs.writeFileSync(file2, "waq waq"); | ||
// to flush some buffers | ||
console.log('written') |
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.
Linter: 81:23 error Missing semicolon semi
@vsemozhetbyt de-linted. P.S. how do you run the lint locally, I couldn't find a good command? |
@refack |
works so bad on Windows 😭 |
@refack node tools/eslint/bin/eslint.js --rulesdir tools/eslint-rules/ --ext=.js,.md benchmark doc lib test tools or just: eslint --rulesdir tools/eslint-rules/ --ext=.js,.md benchmark doc lib test tools For a file: eslint --rulesdir tools/eslint-rules/ path/to/a/file.js
eslint --rulesdir tools/eslint-rules/ path/to/a/file.md |
@nodejs/platform-macos if this a real bug? Snippet from test (last line is 94)const file1 = path.join(common.tmpDir, Date.now() + 'duck.js');
const file2 = path.join(common.tmpDir, Date.now() + 'goose.js');
fs.writeFileSync(file1, 'ga ga');
fs.writeFileSync(file2, 'waq waq');
// to flush some buffers
console.log('written');
console.log('written some more');
if (common.isWindows) {
execSync(`attrib -a -h -i -r -s ${file1}`);
execSync(`attrib -a -h -i -r -s ${file2}`);
} else {
execSync(`touch ${file1}`);
execSync(`touch ${file2}`);
}
fs.chmod(file1, mode_async.toString(8), common.mustCall((err) => {
assert.ifError(err);
console.log(fs.statSync(file1).mode); Output
|
Failing on freeBSD: https://ci.nodejs.org/job/node-stress-single-test/1213/nodes=freebsd10-64/ |
Try to fail on macOS: https://ci.nodejs.org/job/node-stress-single-test/1215/nodes=osx1010/ |
6de5aa1
to
1576078
Compare
Latest CI: https://ci.nodejs.org/job/node-test-commit/9870/ |
@Trott @vsemozhetbyt PTAL
|
@refack I feel murky on this issue, so I dare not make any definitive review( |
@nodejs/testing PTAL |
@@ -139,5 +153,7 @@ if (fs.lchmod) { | |||
|
|||
|
|||
process.on('exit', function() { | |||
fs.chmodSync(file1, mode_sync); |
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 the chmod
in the exit
handler?
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.
If the file stays RO, common.refreshTmpDir
fails
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 certain about that? If so, it must be Windows-only behavior.
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 certain about that? If so, it must be Windows-only behavior.
Yes, common.refreshTmpDir
fails in a few cases on Windows
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, well in that case, either surrounding it with if (common.isWindows)
and/or providing a comment explaining why it's there might help prevent someone like me from coming along and obliviously removing it in six months. :-D
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.
So let's wait with this. I want to fix common.refreshTmpDir
on windows.
New CI:https://ci.nodejs.org/job/node-test-commit/9914/ (hopefully we got the flakes out of the way) |
const {execSync} = require('child_process'); | ||
const fs = require('fs'); | ||
|
||
ok(common.isWindows, 'reset of test only for windows'); |
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.
We generally use common.skip
to skip tests.
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.
Since this is a known-issue
it's supposed to fail.
So it's either this line or exclude this test for all platforms but Windows in known_issues.status
Otherwise we get:
refael@refaelux:/mnt/d/code/node-cur$ python tools/test.py known_issues
=== release test-fs-fchmod-12835 [negative] ===
Path: known_issues/test-fs-fchmod-12835
1..0 # Skipped: undefined
Command: out/Release/node /mnt/d/code/node-cur/test/known_issues/test-fs-fchmod-12835.js
[00:11|% 100|+ 13|- 1]: Done
Currently this uncovers a regression in `fs.fchmodSync(fd, mode_sync);` No solution yet... Also as issue on macOS in test-fs-chmod:94 fail to access file1 Fixes:nodejs#12803
Blocking until we fix |
Ping @refack |
@@ -24,9 +24,11 @@ const common = require('../common'); | |||
const assert = require('assert'); | |||
const path = require('path'); | |||
const fs = require('fs'); | |||
const {execSync} = require('child_process'); |
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 linter not complaining about this without extra whitespace?^^
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.
It seems the rule was landed later than the last CI here.
@refack this needs a rebase |
Closing due to long inactivity. @refack please reopen if you want to further pursue this. |
Currently this uncovers a regression in
fs.fchmodSync(fd, mode_sync);
No solution yet...
Fixes:#12803
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
fs,libuv,test