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: refresh the tmpdir before using #7327

Closed
wants to merge 1 commit into from
Closed

Conversation

Trott
Copy link
Member

@Trott Trott commented Jun 16, 2016

Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

test fs

Description of change

Test fails if tmp dir does not exist when the test is run. Add common.refreshTmpDir() so that doesn't happen.

@Trott Trott added fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests. labels Jun 16, 2016
@cjihrig
Copy link
Contributor

cjihrig commented Jun 16, 2016

LGTM

3 similar comments
@jbergstroem
Copy link
Member

LGTM

@santigimeno
Copy link
Member

LGTM

@mscdex
Copy link
Contributor

mscdex commented Jun 16, 2016

LGTM

@Trott
Copy link
Member Author

Trott commented Jun 17, 2016

@addaleax
Copy link
Member

CI has some unrelated failures, LGTM.

@santigimeno
Copy link
Member

When applying this change, I've observed that sometimes this test fails on OS X if the common.tmpDir already contained a file before running the test. If that's the case, the first event received is the one related to the removal of the file by common.refreshTmpDir(), even though the call to fs.watch is performed afterwards. Here's a simplified test case that shows the issue. It fails in my OS X box but passes in my Debian Jessie 64.

'use strict';

const common = require('../common');
const fs = require('fs');
const path = require('path');
const assert = require('assert');

common.refreshTmpDir();
const x = path.join(common.tmpDir, 'x.txt');

const fd1 = fs.openSync(x, 'w+');
fs.closeSync(fd1);

common.refreshTmpDir();

const a = path.join(common.tmpDir, 'a.txt');

const watcher1 = fs.watch(
  common.tmpDir,
  (event, filename) => {
    if (filename)
      assert.equal(filename, 'a.txt');
    watcher1.close();
  }
);

const fd = fs.openSync(a, 'w+');
fs.closeSync(fd);

process.on('exit', () => {
  fs.unlink(a);
});

I don't know if it's bug or a limitation with FSEvents. WDYT?

@jasnell
Copy link
Member

jasnell commented Jun 20, 2016

@bnoordhuis @saghul ...

@Trott
Copy link
Member Author

Trott commented Jun 21, 2016

@santigimeno I think that is an issue specific to FSEvents. I'm going to create a separate workaround for that in a subsequent PR. Let me know if this isn't OK to land as-is. (I mean, not having the refreshTmpDir() call is a bug either way, so this ought to at least be an improvement.)

@santigimeno
Copy link
Member

I'm ok with landing this as long as it doesn't cause problems with the CI, otherwise maybe waiting for the workaround is the better choice.

@Trott
Copy link
Member Author

Trott commented Jun 21, 2016

Workaround is stranger than I thought. Some unpredictable and/or non-intuitive stuff going on. Bummer.

Trott added a commit to Trott/io.js that referenced this pull request Jun 22, 2016
Test fails if tmp dir does not exist when the test is run. Add
common.refreshTmpDir() so that doesn't happen.

PR-URL: nodejs#7327
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Brian White <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@Trott
Copy link
Member Author

Trott commented Jun 22, 2016

Landed in cdcfeb7

@Trott Trott closed this Jun 22, 2016
Fishrock123 pushed a commit that referenced this pull request Jun 27, 2016
Test fails if tmp dir does not exist when the test is run. Add
common.refreshTmpDir() so that doesn't happen.

PR-URL: #7327
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Brian White <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@Fishrock123 Fishrock123 mentioned this pull request Jun 27, 2016
Fishrock123 pushed a commit that referenced this pull request Jul 5, 2016
Test fails if tmp dir does not exist when the test is run. Add
common.refreshTmpDir() so that doesn't happen.

PR-URL: #7327
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Brian White <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@Fishrock123 Fishrock123 mentioned this pull request Jul 5, 2016
@MylesBorins
Copy link
Contributor

@Trott this doesn't land cleanly. Totally up for a backport though

@Trott
Copy link
Member Author

Trott commented Jul 12, 2016

@thealphanerd The file this PR modifies was added in a semver-major PR, so it shouldn't land on LTS.

@Trott Trott deleted the kqueue branch January 13, 2022 22:43
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. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants