Browse Source
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: https://github.com/nodejs/node/pull/6997
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v4.x
Bryan English
9 years ago
committed by
Myles Borins
No known key found for this signature in database
GPG Key ID: 933B01F40B5CA946
13 changed files with
28 additions and
24 deletions
test/parallel/test-child-process-detached.js
test/parallel/test-delayed-require.js
test/parallel/test-global.js
test/parallel/test-http-default-port.js
test/parallel/test-internal-modules.js
test/parallel/test-preload.js
test/parallel/test-repl-persistent-history.js
test/parallel/test-repl-syntax-error-stack.js
test/parallel/test-require-json.js
test/parallel/test-sync-fileread.js
test/parallel/test-tls-connect-stream-writes.js
test/parallel/test-util-internal.js
test/sequential/test-deprecation-flags.js
@ -1,10 +1,10 @@
'use strict' ;
require ( '../common' ) ;
var common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
var path = require ( 'path' ) ;
var spawn = require ( 'child_process' ) . spawn ;
var childPath = path . join ( __ dirname , '..' , 'fixtures' ,
var childPath = path . join ( common . fixturesDir ,
'parent-process-nonpersistent.js' ) ;
var persistentPid = - 1 ;
@ -1,9 +1,10 @@
'use strict' ;
const common = require ( '../common' ) ;
var common = require ( '../common' ) ;
var path = require ( 'path' ) ;
var assert = require ( 'assert' ) ;
setTimeout ( common . mustCall ( function ( ) {
const a = require ( '../fixtures/a' ) ;
const a = require ( path . join ( common . fixturesDir , 'a' ) ) ;
assert . strictEqual ( true , 'A' in a ) ;
assert . strictEqual ( 'A' , a . A ( ) ) ;
assert . strictEqual ( 'D' , a . D ( ) ) ;
@ -1,5 +1,6 @@
/* eslint-disable strict */
var common = require ( '../common' ) ;
var path = require ( 'path' ) ;
var assert = require ( 'assert' ) ;
common . globalCheck = false ;
@ -13,7 +14,7 @@ assert.equal('bar',
baseBar , // eslint-disable-line no-undef
'global.x -> x in base level not working' ) ;
var module = require ( '../fixtures/global/plain' ) ;
var module = require ( path . join ( common . fixturesDir , 'global' , 'plain' ) ) ;
const fooBar = module . fooBar ;
assert . equal ( 'foo' , fooBar . foo , 'x -> global.x in sub level not working' ) ;
@ -5,7 +5,7 @@ const assert = require('assert');
const hostExpect = 'localhost' ;
const fs = require ( 'fs' ) ;
const path = require ( 'path' ) ;
const fixtures = path . resolve ( __ dirname , '../fixtures/ keys' ) ;
const fixtures = path . join ( common . fixturesDir , 'keys' ) ;
const options = {
key : fs . readFileSync ( fixtures + '/agent1-key.pem' ) ,
cert : fs . readFileSync ( fixtures + '/agent1-cert.pem' )
@ -1,9 +1,10 @@
'use strict' ;
require ( '../common' ) ;
var common = require ( '../common' ) ;
var path = require ( 'path' ) ;
var assert = require ( 'assert' ) ;
assert . throws ( function ( ) {
require ( 'internal/freelist' ) ;
} ) ;
assert ( require ( '../fixtures/internal-modules' ) === 42 ) ;
assert ( require ( path . join ( common . fixturesDir , 'internal-modules' ) ) === 42 ) ;
@ -1,5 +1,5 @@
'use strict' ;
require ( '../common' ) ;
const common = require ( '../common' ) ;
const assert = require ( 'assert' ) ;
const path = require ( 'path' ) ;
const child_process = require ( 'child_process' ) ;
@ -15,7 +15,7 @@ var preloadOption = function(preloads) {
} ;
var fixture = function ( name ) {
return path . join ( __ dirname , '../fixtures/' + name ) ;
return path . join ( common . fixturesDir , name ) ;
} ;
var fixtureA = fixture ( 'printA.js' ) ;
@ -82,7 +82,7 @@ child_process.exec(nodeBinary + ' '
} ) ;
// https://github.com/nodejs/node/issues/1691
process . chdir ( path . join ( __ dirname , '../fixtures/' ) ) ;
process . chdir ( common . fixturesDir ) ;
child_process . exec ( nodeBinary + ' '
+ '--expose_debug_as=v8debug '
+ '--require ' + fixture ( 'cluster-preload.js' ) + ' '
@ -68,7 +68,7 @@ const sameHistoryFilePaths = '\nThe old repl history file has the same name ' +
path . join ( common . tmpDir , '.node_repl_history' ) +
' and is empty.\nUsing it as is.\n' ;
// File paths
const fixtures = path . join ( common . testDir , 'fixtures' ) ;
const fixtures = common . fixturesDir ;
const historyFixturePath = path . join ( fixtures , '.node_repl_history' ) ;
const historyPath = path . join ( common . tmpDir , '.fixture_copy_repl_history' ) ;
const historyPathFail = path . join ( common . tmpDir , '.node_repl\u0000_history' ) ;
@ -17,7 +17,7 @@ common.ArrayStream.prototype.write = function(output) {
const putIn = new common . ArrayStream ( ) ;
repl . start ( '' , putIn ) ;
let file = path . resolve ( __ dirname , '../fixtures/ syntax/ bad_syntax' ) ;
let file = path . join ( common . fixturesDir , 'syntax' , ' bad_syntax' ) ;
if ( common . isWindows )
file = file . replace ( /\\/g , '\\\\' ) ;
@ -1,9 +1,10 @@
'use strict' ;
require ( '../common' ) ;
var common = require ( '../common' ) ;
var path = require ( 'path' ) ;
var assert = require ( 'assert' ) ;
try {
require ( '../fixtures/invalid.json' ) ;
require ( path . join ( common . fixturesDir , 'invalid.json' ) ) ;
} catch ( err ) {
var re = /test[\/\\]fixtures[\/\\]invalid.json: Unexpected string/ ;
var i = err . message . match ( re ) ;
@ -1,9 +1,9 @@
'use strict' ;
require ( '../common' ) ;
var common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
var path = require ( 'path' ) ;
var fs = require ( 'fs' ) ;
var fixture = path . join ( __ dirname , '../fixtures/ x.txt' ) ;
var fixture = path . join ( common . fixturesDir , 'x.txt' ) ;
assert . equal ( 'xyz\n' , fs . readFileSync ( fixture ) ) ;
@ -1,14 +1,13 @@
'use strict' ;
require ( '../common' ) ;
const common = require ( '../common' ) ;
const assert = require ( 'assert' ) ;
const fs = require ( 'fs' ) ;
const path = require ( 'path' ) ;
const tls = require ( 'tls' ) ;
const stream = require ( 'stream' ) ;
const net = require ( 'net' ) ;
var server ;
var cert_dir = path . resolve ( __ dirname , '../fixtures' ) ;
var cert_dir = common . fixturesDir ;
var options = { key : fs . readFileSync ( cert_dir + '/test_key.pem' ) ,
cert : fs . readFileSync ( cert_dir + '/test_cert.pem' ) ,
ca : [ fs . readFileSync ( cert_dir + '/test_ca.pem' ) ] ,
@ -1,7 +1,8 @@
'use strict' ;
// Flags: --expose_internals
require ( '../common' ) ;
const common = require ( '../common' ) ;
const path = require ( 'path' ) ;
const assert = require ( 'assert' ) ;
const internalUtil = require ( 'internal/util' ) ;
@ -24,7 +25,7 @@ assert.deepEqual(internalUtil.getHiddenValue({}, 'foo'), undefined);
let arrowMessage ;
try {
require ( '../fixtures/syntax/bad_syntax' ) ;
require ( path . join ( common . fixturesDir , 'syntax' , 'bad_syntax' ) ) ;
} catch ( err ) {
arrowMessage = internalUtil . getHiddenValue ( err , 'arrowMessage' ) ;
}
@ -1,12 +1,12 @@
'use strict' ;
require ( '../common' ) ;
var common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
var execFile = require ( 'child_process' ) . execFile ;
var depmod = require . resolve ( '../fixtures/deprecated.js' ) ;
var node = process . execPath ;
var depUserland =
require . resolve ( '../fixtures /deprecated-userland-function.js') ;
require . resolve ( common . fixturesDir + ' /deprecated-userland-function.js') ;
var normal = [ depmod ] ;
var noDep = [ '--no-deprecation' , depmod ] ;