Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

refack
Copy link
Contributor

@refack refack commented May 4, 2017

Currently this uncovers a regression in fs.fchmodSync(fd, mode_sync);
No solution yet...

Fixes:#12803

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

fs,libuv,test

@refack refack added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label May 4, 2017
@refack refack self-assigned this May 4, 2017
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label May 4, 2017
@vsemozhetbyt
Copy link
Contributor

Refs: #12803

@refack refack added fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. labels May 4, 2017
@@ -139,5 +140,11 @@ if (fs.lchmod) {


process.on('exit', function() {
try {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Good idea!

Copy link
Contributor Author

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

@refack
Copy link
Contributor Author

refack commented May 4, 2017

/cc @nodejs/fs
CI: https://ci.nodejs.org/job/node-test-commit/9644/

@vsemozhetbyt
Copy link
Contributor

@refack
Copy link
Contributor Author

refack commented May 4, 2017

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented May 4, 2017

@refack
Copy link
Contributor Author

refack commented May 5, 2017

'use strict';
const common = require('../common');
if (common.isWindows) {
// Windows only: Test fchmod on files with `attrib -a -i`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete)

@vsemozhetbyt
Copy link
Contributor

See about known_issues.status file here.

@@ -0,0 +1,34 @@
'use strict';
const common = require('../common');
if (common.isWindows) {
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt May 5, 2017

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.

Copy link
Contributor Author

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...

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}`);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@refack
Copy link
Contributor Author

refack commented May 5, 2017

@refack
Copy link
Contributor Author

refack commented May 5, 2017

const {execSync} = require('child_process');
const fs = require('fs');

ok(common.isWindows, "reset of test only for windows")
Copy link
Contributor

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

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");
Copy link
Contributor

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

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");
Copy link
Contributor

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

fs.writeFileSync(file1, "ga ga");
fs.writeFileSync(file2, "waq waq");
// to flush some buffers
console.log('written')
Copy link
Contributor

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

@refack refack force-pushed the 12803-chmod-edge branch from e2cdcf0 to c07479e Compare May 5, 2017 13:36
@refack
Copy link
Contributor Author

refack commented May 5, 2017

@vsemozhetbyt de-linted.

P.S. how do you run the lint locally, I couldn't find a good command?

@sam-github
Copy link
Contributor

@refack make lint?

@refack
Copy link
Contributor Author

refack commented May 5, 2017

@refack make lint?

works so bad on Windows 😭

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented May 5, 2017

@refack
For all:

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

@refack
Copy link
Contributor Author

refack commented May 5, 2017

@refack
Copy link
Contributor Author

refack commented May 5, 2017

@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

364	parallel/test-fs-chmod	
duration_ms	
0.204
severity	
fail
stack	
written
written some more
fs.js:934
  binding.stat(pathModule._makeLong(path));
          ^

Error: ENOENT: no such file or directory, stat '/Users/iojs/node-tmp/tmp.1/1494002742913duck.js'
    at Object.fs.statSync (fs.js:934:11)
    at fs.chmod.common.mustCall (/Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1010/test/parallel/test-fs-chmod.js:94:18)
    at /Users/iojs/build/workspace/node-test-commit-osx/nodes/osx1010/test/common/index.js:460:15
    at FSReqWrap.oncomplete (fs.js:135:15)

@refack refack force-pushed the 12803-chmod-edge branch from c07479e to c4ce793 Compare May 13, 2017 02:58
@refack
Copy link
Contributor Author

refack commented May 13, 2017

@refack
Copy link
Contributor Author

refack commented May 13, 2017

@refack
Copy link
Contributor Author

refack commented May 13, 2017

@refack refack force-pushed the 12803-chmod-edge branch 3 times, most recently from 6de5aa1 to 1576078 Compare May 13, 2017 20:14
@refack
Copy link
Contributor Author

refack commented May 13, 2017

Latest CI: https://ci.nodejs.org/job/node-test-commit/9870/
Found an issue on macOS, but couldn't distill it into a known-issue test

@refack
Copy link
Contributor Author

refack commented May 15, 2017

@Trott @vsemozhetbyt PTAL
Current test uncovers two issues

  1. Windows distilled into test-fs-fchmod-12835.js
  2. An issue on macOS with short fileWriteSync test, fs: fix chmod mask testing on windows #12835 (comment)

@refack refack added macos Issues and PRs related to the macOS platform / OSX. and removed help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels May 15, 2017
@vsemozhetbyt
Copy link
Contributor

@refack I feel murky on this issue, so I dare not make any definitive review(

@Trott
Copy link
Member

Trott commented May 16, 2017

@nodejs/testing PTAL

@@ -139,5 +153,7 @@ if (fs.lchmod) {


process.on('exit', function() {
fs.chmodSync(file1, mode_sync);
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

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.

@refack
Copy link
Contributor Author

refack commented May 16, 2017

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');
Copy link
Contributor

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.

Copy link
Contributor Author

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

@refack refack force-pushed the 12803-chmod-edge branch from 1576078 to 938b8c1 Compare May 16, 2017 19:29
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
@refack refack force-pushed the 12803-chmod-edge branch from 938b8c1 to 52e3483 Compare May 19, 2017 19:40
@refack refack added the blocked PRs that are blocked by other issues or PRs. label May 20, 2017
@refack
Copy link
Contributor Author

refack commented May 20, 2017

Blocking until we fix common.refreshTmpDir on Windows

@refack refack removed the blocked PRs that are blocked by other issues or PRs. label Aug 20, 2017
@BridgeAR
Copy link
Member

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');
Copy link
Member

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?^^

Copy link
Contributor

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.

@BridgeAR
Copy link
Member

@refack this needs a rebase

@BridgeAR
Copy link
Member

Closing due to long inactivity. @refack please reopen if you want to further pursue this.

@BridgeAR BridgeAR closed this Nov 22, 2017
@refack refack removed their assignment Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. macos Issues and PRs related to the macOS platform / OSX. test Issues and PRs related to the tests.
Projects
None yet
8 participants