| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 88b9572 commit 1fdbaed
113 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -316,6 +316,37 @@ Decrements the `Countdown` counter. | |||
| 316 | 316 | Specifies the remaining number of times `Countdown.prototype.dec()` must be | |
| 317 | 317 | called before the callback is invoked. | |
| 318 | 318 | ||
| 319 | + ## Fixtures Module | ||
| 320 | + | ||
| 321 | + The `common/fixtures` module provides convenience methods for working with | ||
| 322 | + files in the `test/fixtures` directory. | ||
| 323 | + | ||
| 324 | + ### fixtures.fixturesDir | ||
| 325 | + | ||
| 326 | + * [<String>] | ||
| 327 | + | ||
| 328 | + The absolute path to the `test/fixtures/` directory. | ||
| 329 | + | ||
| 330 | + ### fixtures.path(...args) | ||
| 331 | + | ||
| 332 | + * `...args` [<String>] | ||
| 333 | + | ||
| 334 | + Returns the result of `path.join(fixtures.fixturesDir, ...args)`. | ||
| 335 | + | ||
| 336 | + ### fixtures.readSync(args[, enc]) | ||
| 337 | + | ||
| 338 | + * `args` [<String>] | [<Array>] | ||
| 339 | + | ||
| 340 | + Returns the result of | ||
| 341 | + `fs.readFileSync(path.join(fixtures.fixturesDir, ...args), 'enc')`. | ||
| 342 | + | ||
| 343 | + ### fixtures.readKey(arg[, enc]) | ||
| 344 | + | ||
| 345 | + * `arg` [<String>] | ||
| 346 | + | ||
| 347 | + Returns the result of | ||
| 348 | + `fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`. | ||
| 349 | + | ||
| 319 | 350 | ## WPT Module | |
| 320 | 351 | ||
| 321 | 352 | The wpt.js module is a port of parts of | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + /* eslint-disable required-modules */ | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + const path = require('path'); | ||
| 5 | + const fs = require('fs'); | ||
| 6 | + | ||
| 7 | + const fixturesDir = path.join(__dirname, '..', 'fixtures'); | ||
| 8 | + | ||
| 9 | + function fixturesPath(...args) { | ||
| 10 | + return path.join(fixturesDir, ...args); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + function readFixtureSync(args, enc) { | ||
| 14 | + if (Array.isArray(args)) | ||
| 15 | + return fs.readFileSync(fixturesPath(...args), enc); | ||
| 16 | + return fs.readFileSync(fixturesPath(args), enc); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + function readFixtureKey(name, enc) { | ||
| 20 | + return fs.readFileSync(fixturesPath('keys', name), enc); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + module.exports = { | ||
| 24 | + fixturesDir, | ||
| 25 | + path: fixturesPath, | ||
| 26 | + readSync: readFixtureSync, | ||
| 27 | + readKey: readFixtureKey | ||
| 28 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,13 +8,15 @@ const { exec, execSync, spawn, spawnSync } = require('child_process'); | |||
| 8 | 8 | const stream = require('stream'); | |
| 9 | 9 | const util = require('util'); | |
| 10 | 10 | const Timer = process.binding('timer_wrap').Timer; | |
| 11 | + const { fixturesDir } = require('./fixtures'); | ||
| 11 | 12 | ||
| 12 | 13 | const testRoot = process.env.NODE_TEST_DIR ? | |
| 13 | 14 | fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); | |
| 14 | 15 | ||
| 15 | 16 | const noop = () => {}; | |
| 16 | 17 | ||
| 17 | - exports.fixturesDir = path.join(__dirname, '..', 'fixtures'); | ||
| 18 | + exports.fixturesDir = fixturesDir; | ||
| 19 | + | ||
| 18 | 20 | exports.tmpDirName = 'tmp'; | |
| 19 | 21 | // PORT should match the definition in test/testpy/__init__.py. | |
| 20 | 22 | exports.PORT = +process.env.NODE_COMMON_PORT || 12346; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,10 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - const common = require('../common'); | ||
| 2 | + require('../common'); | ||
| 3 | 3 | const assert = require('assert'); | |
| 4 | - const path = require('path'); | ||
| 4 | + const fixtures = require('../common/fixtures'); | ||
| 5 | 5 | ||
| 6 | 6 | const spawn = require('child_process').spawn; | |
| 7 | - const childPath = path.join(common.fixturesDir, | ||
| 8 | - 'parent-process-nonpersistent.js'); | ||
| 7 | + const childPath = fixtures.path('parent-process-nonpersistent.js'); | ||
| 9 | 8 | let persistentPid = -1; | |
| 10 | 9 | ||
| 11 | 10 | const child = spawn(process.execPath, [ childPath ]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,10 +2,10 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const execFile = require('child_process').execFile; | |
| 5 | - const path = require('path'); | ||
| 6 | 5 | const uv = process.binding('uv'); | |
| 6 | + const fixtures = require('../common/fixtures'); | ||
| 7 | 7 | ||
| 8 | - const fixture = path.join(common.fixturesDir, 'exit.js'); | ||
| 8 | + const fixture = fixtures.path('exit.js'); | ||
| 9 | 9 | ||
| 10 | 10 | { | |
| 11 | 11 | execFile( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,18 +2,17 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const spawn = require('child_process').spawn; | |
| 5 | - const path = require('path'); | ||
| 5 | + const fixtures = require('../common/fixtures'); | ||
| 6 | 6 | ||
| 7 | - const exitScript = path.join(common.fixturesDir, 'exit.js'); | ||
| 7 | + const exitScript = fixtures.path('exit.js'); | ||
| 8 | 8 | const exitChild = spawn(process.argv[0], [exitScript, 23]); | |
| 9 | 9 | exitChild.on('exit', common.mustCall(function(code, signal) { | |
| 10 | 10 | assert.strictEqual(code, 23); | |
| 11 | 11 | assert.strictEqual(signal, null); | |
| 12 | 12 | })); | |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | - const errorScript = path.join(common.fixturesDir, | ||
| 16 | - 'child_process_should_emit_error.js'); | ||
| 15 | + const errorScript = fixtures.path('child_process_should_emit_error.js'); | ||
| 17 | 16 | const errorChild = spawn(process.argv[0], [errorScript]); | |
| 18 | 17 | errorChild.on('exit', common.mustCall(function(code, signal) { | |
| 19 | 18 | assert.ok(code !== 0); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,9 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const fork = require('child_process').fork; | |
| 5 | + const fixtures = require('../common/fixtures'); | ||
| 5 | 6 | ||
| 6 | - const cp = fork(`${common.fixturesDir}/child-process-message-and-exit.js`); | ||
| 7 | + const cp = fork(fixtures.path('child-process-message-and-exit.js')); | ||
| 7 | 8 | ||
| 8 | 9 | let gotMessage = false; | |
| 9 | 10 | let gotExit = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,9 @@ const common = require('../common'); | |||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const fork = require('child_process').fork; | |
| 5 | 5 | const args = ['foo', 'bar']; | |
| 6 | + const fixtures = require('../common/fixtures'); | ||
| 6 | 7 | ||
| 7 | - const n = fork(`${common.fixturesDir}/child-process-spawn-node.js`, args); | ||
| 8 | + const n = fork(fixtures.path('child-process-spawn-node.js'), args); | ||
| 8 | 9 | assert.deepStrictEqual(args, ['foo', 'bar']); | |
| 9 | 10 | ||
| 10 | 11 | n.on('message', function(m) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - const common = require('../common'); | ||
| 2 | + require('../common'); | ||
| 3 | 3 | const child_process = require('child_process'); | |
| 4 | + const fixtures = require('../common/fixtures'); | ||
| 4 | 5 | ||
| 5 | - child_process.fork(`${common.fixturesDir}/empty.js`); // should not hang | ||
| 6 | + child_process.fork(fixtures.path('empty.js')); // should not hang | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const common = require('../common'); | ||
| 3 | + require('../common'); | ||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | ||
| 6 | - const spawn = require('child_process').spawn; | ||
| 6 | + const { spawn } = require('child_process'); | ||
| 7 | + const fixtures = require('../common/fixtures'); | ||
| 7 | 8 | ||
| 8 | - const path = require('path'); | ||
| 9 | - | ||
| 10 | - const sub = path.join(common.fixturesDir, 'echo.js'); | ||
| 9 | + const sub = fixtures.path('echo.js'); | ||
| 11 | 10 | ||
| 12 | 11 | let gotHelloWorld = false; | |
| 13 | 12 | let gotEcho = false; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments