Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6091c8

Browse filesBrowse files
benglevanlucas
authored andcommitted
test: use common.fixturesDir almost everywhere
Updating tests to use `common.fixturesDir` whenever possible/reasonable. Left out things like tests for `path` and `require.resolve`. PR-URL: #6997 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 701e699 commit d6091c8
Copy full SHA for d6091c8
Expand file treeCollapse file tree

15 files changed

+31
-27
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-child-process-detached.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-detached.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
2-
require('../common');
2+
var common = require('../common');
33
var assert = require('assert');
44
var path = require('path');
55

66
var spawn = require('child_process').spawn;
7-
var childPath = path.join(__dirname, '..', 'fixtures',
7+
var childPath = path.join(common.fixturesDir,
88
'parent-process-nonpersistent.js');
99
var persistentPid = -1;
1010

Collapse file

‎test/parallel/test-delayed-require.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-delayed-require.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict';
2-
require('../common');
2+
var common = require('../common');
3+
var path = require('path');
34
var assert = require('assert');
45

56
var a;
67
setTimeout(function() {
7-
a = require('../fixtures/a');
8+
a = require(path.join(common.fixturesDir, 'a'));
89
}, 50);
910

1011
process.on('exit', function() {
Collapse file

‎test/parallel/test-global.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-global.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable strict */
22
var common = require('../common');
3+
var path = require('path');
34
var assert = require('assert');
45

56
common.globalCheck = false;
@@ -13,7 +14,7 @@ assert.equal('bar',
1314
baseBar, // eslint-disable-line no-undef
1415
'global.x -> x in base level not working');
1516

16-
var module = require('../fixtures/global/plain');
17+
var module = require(path.join(common.fixturesDir, 'global', 'plain'));
1718
const fooBar = module.fooBar;
1819

1920
assert.equal('foo', fooBar.foo, 'x -> global.x in sub level not working');
Collapse file

‎test/parallel/test-http-default-port.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-default-port.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const assert = require('assert');
77
const hostExpect = 'localhost';
88
const fs = require('fs');
99
const path = require('path');
10-
const fixtures = path.resolve(__dirname, '../fixtures/keys');
10+
const fixtures = path.join(common.fixturesDir, 'keys');
1111
const options = {
1212
key: fs.readFileSync(fixtures + '/agent1-key.pem'),
1313
cert: fs.readFileSync(fixtures + '/agent1-cert.pem')
Collapse file
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
2-
require('../common');
2+
var common = require('../common');
3+
var path = require('path');
34
var assert = require('assert');
45

56
assert.throws(function() {
67
require('internal/freelist');
78
});
89

9-
assert(require('../fixtures/internal-modules') === 42);
10+
assert(require(path.join(common.fixturesDir, 'internal-modules')) === 42);
Collapse file

‎test/parallel/test-preload.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-preload.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const preloadOption = function(preloads) {
2222
};
2323

2424
const fixture = function(name) {
25-
return path.join(__dirname, '../fixtures/' + name);
25+
return path.join(common.fixturesDir, name);
2626
};
2727

2828
const fixtureA = fixture('printA.js');
@@ -138,7 +138,7 @@ childProcess.exec(nodeBinary + ' '
138138
});
139139

140140
// https://github.com/nodejs/node/issues/1691
141-
process.chdir(path.join(__dirname, '../fixtures/'));
141+
process.chdir(common.fixturesDir);
142142
childProcess.exec(nodeBinary + ' '
143143
+ '--expose_debug_as=v8debug '
144144
+ '--require ' + fixture('cluster-preload.js') + ' '
Collapse file

‎test/parallel/test-repl-persistent-history.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-persistent-history.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const sameHistoryFilePaths = '\nThe old repl history file has the same name ' +
7070
path.join(common.tmpDir, '.node_repl_history') +
7171
' and is empty.\nUsing it as is.\n';
7272
// File paths
73-
const fixtures = path.join(common.testDir, 'fixtures');
73+
const fixtures = common.fixturesDir;
7474
const historyFixturePath = path.join(fixtures, '.node_repl_history');
7575
const historyPath = path.join(common.tmpDir, '.fixture_copy_repl_history');
7676
const historyPathFail = path.join(common.tmpDir, '.node_repl\u0000_history');
Collapse file

‎test/parallel/test-repl-syntax-error-stack.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-syntax-error-stack.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ common.ArrayStream.prototype.write = function(output) {
1717

1818
const putIn = new common.ArrayStream();
1919
repl.start('', putIn);
20-
let file = path.resolve(__dirname, '../fixtures/syntax/bad_syntax');
20+
let file = path.join(common.fixturesDir, 'syntax', 'bad_syntax');
2121

2222
if (common.isWindows)
2323
file = file.replace(/\\/g, '\\\\');
Collapse file

‎test/parallel/test-require-json.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-require-json.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
2-
require('../common');
2+
var common = require('../common');
3+
var path = require('path');
34
var assert = require('assert');
45

56
try {
6-
require('../fixtures/invalid.json');
7+
require(path.join(common.fixturesDir, 'invalid.json'));
78
} catch (err) {
89
var re = /test[\/\\]fixtures[\/\\]invalid.json: Unexpected string/;
910
var i = err.message.match(re);
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2-
require('../common');
2+
var common = require('../common');
33
var assert = require('assert');
44
var path = require('path');
55
var fs = require('fs');
66

7-
var fixture = path.join(__dirname, '../fixtures/x.txt');
7+
var fixture = path.join(common.fixturesDir, 'x.txt');
88

99
assert.equal('xyz\n', fs.readFileSync(fixture));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.