Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit a05f973

Browse files
committed
test: Misc Windows unit test fixes
Fixes #5071, #5073. * Normalize capitalization of drive letter * Fix `exit()` typo in failure path * Ignore symlink tests (Windows) if not elevated The `test_relative_input_cwd()` test was failing on Windows when `skipSymlinks` was `true`. So we won't run it if `skipSymlinks` is `true`. When it failed, the unhandled error caused Node to die before having a chance to clean up, which resulted in two files missing in subsequent unit tests: * `test/fixtures/nested-index/one/hello.js` * `test/fixtures/nested-index/one/index.js` We should probably find a way to isolate this test from the other test (`simple/test-module-loading`) that was failing when this test poluted the disk state.
1 parent 14a8fb8 commit a05f973

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

lib/path.js

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ if (isWindows) {
176176
tail = result[3],
177177
trailingSlash = /[\\\/]$/.test(tail);
178178

179+
// If device is a drive letter, we'll normalize to lower case.
180+
if (device && device.charAt(1) === ':') {
181+
device = device[0].toLowerCase() + device.substr(1);
182+
}
183+
179184
// Normalize the tail path
180185
tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
181186
return !!p;

test/simple/test-fs-realpath.js

+4
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ function test_cyclic_link_overprotection(callback) {
267267

268268
function test_relative_input_cwd(callback) {
269269
console.log('test_relative_input_cwd');
270+
if (skipSymlinks) {
271+
console.log('skipping symlink test (no privs)');
272+
return runNextTest();
273+
}
270274

271275
// we need to get the relative path to the tmp dir from cwd.
272276
// When the test runner is running it, that will be .../node/test

test/simple/test-http-curl-chunk-problem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var server = http.createServer(function(req, res) {
7373
cat.on('exit', function(code) {
7474
if (code !== 0) {
7575
console.error('subprocess exited with code ' + code);
76-
exit(1);
76+
process.exit(1);
7777
}
7878
res.end();
7979
});

test/simple/test-require-resolve.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ var assert = require('assert');
2525
var path = require('path');
2626

2727
assert.equal(path.join(__dirname, '../fixtures/a.js'),
28-
require.resolve('../fixtures/a'));
28+
path.normalize(require.resolve('../fixtures/a')));
2929
assert.equal(path.join(fixturesDir, 'a.js'),
30-
require.resolve(path.join(fixturesDir, 'a')));
30+
path.normalize(require.resolve(path.join(fixturesDir, 'a'))));
3131
assert.equal(path.join(fixturesDir, 'nested-index', 'one', 'index.js'),
32-
require.resolve('../fixtures/nested-index/one'));
32+
path.normalize(require.resolve('../fixtures/nested-index/one')));
3333
assert.equal('path', require.resolve('path'));
3434

3535
console.log('ok');

0 commit comments

Comments
 (0)