Skip to content

Commit

Permalink
test: continue normalizing fixtures use
Browse files Browse the repository at this point in the history
PR-URL: #14716
Refs: #14332
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
  • Loading branch information
maasencioh authored and MylesBorins committed Sep 12, 2017
1 parent ea2b576 commit ae91b1e
Show file tree
Hide file tree
Showing 24 changed files with 74 additions and 95 deletions.
7 changes: 3 additions & 4 deletions test/async-hooks/test-graph.tls-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ if (!common.hasIPv6)

const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const fs = require('fs');
const tls = require('tls');
const path = require('path');
const fixtures = require('../common/fixtures');

const hooks = initHooks();
hooks.enable();
Expand All @@ -21,8 +20,8 @@ hooks.enable();
//
const server = tls
.createServer({
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')),
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'))
cert: fixtures.readSync('test_cert.pem'),
key: fixtures.readSync('test_key.pem')
})
.on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection))
Expand Down
7 changes: 3 additions & 4 deletions test/async-hooks/test-tlswrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const fixtures = require('../common/fixtures');
const tls = require('tls');

const tick = require('./tick');
Expand All @@ -21,8 +20,8 @@ hooks.enable();
//
const server = tls
.createServer({
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')),
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'))
cert: fixtures.readSync('test_cert.pem'),
key: fixtures.readSync('test_key.pem')
})
.on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection))
Expand Down
6 changes: 3 additions & 3 deletions test/async-hooks/test-writewrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (!common.hasCrypto)

const assert = require('assert');
const initHooks = require('./init-hooks');
const fs = require('fs');
const fixtures = require('../common/fixtures');
const { checkInvocations } = require('./hook-checks');
const tls = require('tls');

Expand All @@ -18,8 +18,8 @@ hooks.enable();
//
const server = tls
.createServer({
cert: fs.readFileSync(`${common.fixturesDir}/test_cert.pem`),
key: fs.readFileSync(`${common.fixturesDir}/test_key.pem`)
cert: fixtures.readSync('test_cert.pem'),
key: fixtures.readSync('test_key.pem')
})
.on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection))
Expand Down
11 changes: 6 additions & 5 deletions test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ try {
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const fixtures = require('../common/fixtures');
const processIncludes = require('../../tools/doc/preprocess.js');
const html = require('../../tools/doc/html.js');

Expand All @@ -21,12 +22,12 @@ const html = require('../../tools/doc/html.js');
// have an html parser.
const testData = [
{
file: path.join(common.fixturesDir, 'sample_document.md'),
file: fixtures.path('sample_document.md'),
html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' +
'<li>Bluefish</li></ol>'
},
{
file: path.join(common.fixturesDir, 'order_of_end_tags_5873.md'),
file: fixtures.path('order_of_end_tags_5873.md'),
html: '<h3>ClassMethod: Buffer.from(array) <span> ' +
'<a class="mark" href="#foo_class_method_buffer_from_array" ' +
'id="foo_class_method_buffer_from_array">#</a> </span> </h3><div' +
Expand All @@ -36,7 +37,7 @@ const testData = [
'</ul></div>'
},
{
file: path.join(common.fixturesDir, 'doc_with_yaml.md'),
file: fixtures.path('doc_with_yaml.md'),
html: '<h1>Sample Markdown with YAML info' +
'<span><a class="mark" href="#foo_sample_markdown_with_yaml_info" ' +
' id="foo_sample_markdown_with_yaml_info">#</a></span></h1>' +
Expand Down Expand Up @@ -72,7 +73,7 @@ const testData = [
'</p>'
},
{
file: path.join(common.fixturesDir, 'doc_with_includes.md'),
file: fixtures.path('doc_with_includes.md'),
html: '<!-- [start-include:doc_inc_1.md] -->' +
'<p>Look <a href="doc_inc_2.html#doc_inc_2_foobar">here</a>!</p>' +
'<!-- [end-include:doc_inc_1.md] -->' +
Expand All @@ -83,7 +84,7 @@ const testData = [
'<!-- [end-include:doc_inc_2.md] -->'
},
{
file: path.join(common.fixturesDir, 'sample_document.md'),
file: fixtures.path('sample_document.md'),
html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' +
'<li>Bluefish</li></ol>',
analyticsId: 'UA-67020396-1'
Expand Down
8 changes: 4 additions & 4 deletions test/doctool/test-doctool-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ try {

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const fixtures = require('../common/fixtures');
const json = require('../../tools/doc/json.js');

// Outputs valid json with the expected fields when given simple markdown
Expand All @@ -19,7 +19,7 @@ const json = require('../../tools/doc/json.js');
// The json property is some json which will be generated by the doctool.
const testData = [
{
file: path.join(common.fixturesDir, 'sample_document.md'),
file: fixtures.path('sample_document.md'),
json: {
source: 'foo',
modules: [{
Expand All @@ -39,7 +39,7 @@ const testData = [
}
},
{
file: path.join(common.fixturesDir, 'order_of_end_tags_5873.md'),
file: fixtures.path('order_of_end_tags_5873.md'),
json: {
source: 'foo',
modules: [{
Expand Down Expand Up @@ -76,7 +76,7 @@ const testData = [
}
},
{
file: path.join(common.fixturesDir, 'doc_with_yaml.md'),
file: fixtures.path('doc_with_yaml.md'),
json: {
source: 'foo',
modules: [
Expand Down
6 changes: 2 additions & 4 deletions test/fixtures/module-require-symlink/symlinked.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
const foo = require('./foo');
const path = require('path');
const fixtures = require('../../common/fixtures');

const linkScriptTarget = path.join(common.fixturesDir,
'module-require-symlink', 'symlinked.js');
const linkScriptTarget = fixtures.path('module-require-symlink', 'symlinked.js');

assert.strictEqual(foo.dep1.bar.version, 'CORRECT_VERSION');
assert.strictEqual(foo.dep2.bar.version, 'CORRECT_VERSION');
Expand Down
13 changes: 4 additions & 9 deletions test/fixtures/tls-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const fs = require('fs');
const join = require('path').join;
const fixtures = require('../common/fixtures');
const tls = require('tls');
const util = require('util');

Expand All @@ -33,17 +32,13 @@ const keys = exports.keys = {
function load(cert, issuer) {
issuer = issuer || cert; // Assume self-signed if no issuer
const id = {
key: read(cert + '-key.pem'),
cert: read(cert + '-cert.pem'),
ca: read(issuer + '-cert.pem'),
key: fixtures.readKey(cert + '-key.pem', 'binary'),
cert: fixtures.readKey(cert + '-cert.pem', 'binary'),
ca: fixtures.readKey(issuer + '-cert.pem', 'binary'),
};
return id;
}

function read(file) {
return fs.readFileSync(join(common.fixturesDir, 'keys', file), 'binary');
}

exports.connect = function connect(options, callback) {
callback = common.mustCall(callback);

Expand Down
4 changes: 2 additions & 2 deletions test/inspector/inspector-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const http = require('http');
const path = require('path');
const fixtures = require('../common/fixtures');
const { spawn } = require('child_process');
const url = require('url');

const _MAINSCRIPT = path.join(common.fixturesDir, 'loop.js');
const _MAINSCRIPT = fixtures.path('loop.js');
const DEBUG = false;
const TIMEOUT = common.platformTimeout(15 * 1000);

Expand Down
4 changes: 2 additions & 2 deletions test/internet/test-tls-add-ca-cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ if (!common.hasCrypto)

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const fixtures = require('../common/fixtures');
const tls = require('tls');

function filenamePEM(n) {
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
return fixtures.path('keys', `${n}.pem`);
}

function loadPEM(n) {
Expand Down
4 changes: 2 additions & 2 deletions test/known_issues/test-repl-require-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Refs: https://github.com/nodejs/node/issues/7788
const common = require('../common');
const assert = require('assert');
const path = require('path');
const path = require('../common/fixtures').path;
const repl = require('repl');
const stream = require('stream');
const inputStream = new stream.PassThrough();
const outputStream = new stream.PassThrough();
const fixture = path.join(common.fixturesDir, 'is-object.js');
const fixture = path('is-object.js');
const r = repl.start({
input: inputStream,
output: outputStream,
Expand Down
8 changes: 3 additions & 5 deletions test/known_issues/test-url-parse-conformance.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
'use strict';

// Refs: https://github.com/nodejs/node/issues/5832

const common = require('../common');
require('../common');
const url = require('url');
const assert = require('assert');
const path = require('path');

const tests = require(path.join(common.fixturesDir, 'url-tests'));
const fixtures = require('../common/fixtures');
const tests = require(fixtures.path('url-tests'));

let failed = 0;
let attempted = 0;
Expand Down
6 changes: 3 additions & 3 deletions test/pummel/test-https-ci-reneg-attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const assert = require('assert');
const spawn = require('child_process').spawn;
const tls = require('tls');
const https = require('https');
const fs = require('fs');
const fixtures = require('../common/fixtures');

// renegotiation limits to test
const LIMITS = [0, 1, 2, 3, 5, 10, 16];
Expand All @@ -48,8 +48,8 @@ const LIMITS = [0, 1, 2, 3, 5, 10, 16];

function test(next) {
const options = {
cert: fs.readFileSync(`${common.fixturesDir}/test_cert.pem`),
key: fs.readFileSync(`${common.fixturesDir}/test_key.pem`)
cert: fixtures.readSync('test_cert.pem'),
key: fixtures.readSync('test_key.pem')
};

let seenError = false;
Expand Down
6 changes: 3 additions & 3 deletions test/pummel/test-https-large-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const fs = require('fs');
const fixtures = require('../common/fixtures');
const https = require('https');

const options = {
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
};

process.stdout.write('build body...');
Expand Down
7 changes: 3 additions & 4 deletions test/pummel/test-https-no-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ if (!common.hasCrypto)

const assert = require('assert');
const https = require('https');
const fs = require('fs');
const path = require('path');
const fixtures = require('../common/fixtures');

const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
key: fixtures.readSync('test_key.pem'),
cert: fixtures.readSync('test_cert.pem')
};

const buf = Buffer.allocUnsafe(1024 * 1024);
Expand Down
9 changes: 4 additions & 5 deletions test/pummel/test-regress-GH-892.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ if (!common.hasCrypto)
const assert = require('assert');
const spawn = require('child_process').spawn;
const https = require('https');
const fs = require('fs');
const fixtures = require('../common/fixtures');

const bytesExpected = 1024 * 1024 * 32;

let started = false;

const childScript = require('path').join(common.fixturesDir,
'GH-892-request.js');
const childScript = fixtures.path('GH-892-request.js');

function makeRequest() {
if (started) return;
Expand Down Expand Up @@ -78,8 +77,8 @@ function makeRequest() {


const serverOptions = {
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
};

let uploadCount = 0;
Expand Down
6 changes: 3 additions & 3 deletions test/pummel/test-tls-ci-reneg-attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (!common.opensslCli)
const assert = require('assert');
const spawn = require('child_process').spawn;
const tls = require('tls');
const fs = require('fs');
const fixtures = require('../common/fixtures');

// renegotiation limits to test
const LIMITS = [0, 1, 2, 3, 5, 10, 16];
Expand All @@ -47,8 +47,8 @@ const LIMITS = [0, 1, 2, 3, 5, 10, 16];

function test(next) {
const options = {
cert: fs.readFileSync(`${common.fixturesDir}/test_cert.pem`),
key: fs.readFileSync(`${common.fixturesDir}/test_key.pem`)
cert: fixtures.readSync('test_cert.pem'),
key: fixtures.readSync('test_key.pem')
};

let seenError = false;
Expand Down
6 changes: 3 additions & 3 deletions test/pummel/test-tls-connect-memleak.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (!common.hasCrypto)

const assert = require('assert');
const tls = require('tls');
const fs = require('fs');
const fixtures = require('../common/fixtures');

assert.strictEqual(
typeof global.gc,
Expand All @@ -37,8 +37,8 @@ assert.strictEqual(
);

tls.createServer({
cert: fs.readFileSync(`${common.fixturesDir}/test_cert.pem`),
key: fs.readFileSync(`${common.fixturesDir}/test_key.pem`)
cert: fixtures.readSync('test_cert.pem'),
key: fixtures.readSync('test_key.pem')
}).listen(common.PORT);

{
Expand Down
10 changes: 3 additions & 7 deletions test/pummel/test-tls-securepair-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ if (!common.opensslCli)
if (!common.hasCrypto)
common.skip('missing crypto');

const join = require('path').join;
const net = require('net');
const assert = require('assert');
const fs = require('fs');
const fixtures = require('../common/fixtures');
const tls = require('tls');
const spawn = require('child_process').spawn;

Expand All @@ -56,11 +55,8 @@ function test2() {
}

function test(keyfn, certfn, check, next) {
keyfn = join(common.fixturesDir, keyfn);
const key = fs.readFileSync(keyfn).toString();

certfn = join(common.fixturesDir, certfn);
const cert = fs.readFileSync(certfn).toString();
const key = fixtures.readSync(keyfn).toString();
const cert = fixtures.readSync(certfn).toString();

const server = spawn(common.opensslCli, ['s_server',
'-accept', common.PORT,
Expand Down
Loading

0 comments on commit ae91b1e

Please sign in to comment.