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: add cwd ENOENT known issue test #12343

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions test/known_issues/test-cwd-enoent-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
// Refs: https://github.com/nodejs/node/pull/12022
// If the cwd is deleted, Node cannot run files because the module system
// relies on uv_cwd(). The -e and -p flags still work though.
const common = require('../common');
const assert = require('assert');

if (common.isSunOS || common.isWindows || common.isAix) {
// The current working directory cannot be removed on these platforms.
// Change this to common.skip() when this is no longer a known issue test.
assert.fail('cannot rmdir current working directory');
return;
}

const cp = require('child_process');
const fs = require('fs');

if (process.argv[2] === 'child') {
// Do nothing.
} else {
common.refreshTmpDir();
const dir = fs.mkdtempSync(common.tmpDir + '/');
process.chdir(dir);
fs.rmdirSync(dir);
Copy link
Member

Choose a reason for hiding this comment

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

Will this work on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will probably have to skip on Windows like the other cwd enoent test does.

assert.throws(process.cwd,
/^Error: ENOENT: no such file or directory, uv_cwd$/);

const r = cp.spawnSync(process.execPath, [__filename, 'child']);

assert.strictEqual(r.status, 0);
assert.strictEqual(r.signal, null);
assert.strictEqual(r.stdout.toString().trim(), '');
assert.strictEqual(r.stderr.toString().trim(), '');
}