Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use common.skip for tap skip output and test cleanup #8841

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions test/parallel/test-fs-readfile-pipe-large.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
const common = require('../common');
const assert = require('assert');
const path = require('path');

// simulate `cat readfile.js | node readfile.js`

if (common.isWindows || common.isAix) {
console.log(`1..0 # Skipped: No /dev/stdin on ${process.platform}.`);
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}

var fs = require('fs');
const fs = require('fs');

if (process.argv[2] === 'child') {
fs.readFile('/dev/stdin', function(er, data) {
Expand All @@ -20,15 +20,15 @@ if (process.argv[2] === 'child') {
return;
}

var filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt');
var dataExpected = new Array(1000000).join('a');
const filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt');
const dataExpected = new Array(1000000).join('a');
Copy link
Member

@lpinca lpinca Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about using 'a'.repeat(1e6 - 1)?

common.refreshTmpDir();
fs.writeFileSync(filename, dataExpected);

var exec = require('child_process').exec;
var f = JSON.stringify(__filename);
var node = JSON.stringify(process.execPath);
var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child';
const exec = require('child_process').exec;
const f = JSON.stringify(__filename);
const node = JSON.stringify(process.execPath);
const cmd = `cat ${filename} | ${node} ${f} child`;
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');
Expand Down
18 changes: 9 additions & 9 deletions test/parallel/test-fs-readfile-pipe.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

// simulate `cat readfile.js | node readfile.js`

if (common.isWindows || common.isAix) {
console.log(`1..0 # Skipped: No /dev/stdin on ${process.platform}.`);
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}

var fs = require('fs');
const fs = require('fs');

var dataExpected = fs.readFileSync(__filename, 'utf8');
const dataExpected = fs.readFileSync(__filename, 'utf8');

if (process.argv[2] === 'child') {
fs.readFile('/dev/stdin', function(er, data) {
Expand All @@ -21,10 +21,10 @@ if (process.argv[2] === 'child') {
return;
}

var exec = require('child_process').exec;
var f = JSON.stringify(__filename);
var node = JSON.stringify(process.execPath);
var cmd = 'cat ' + f + ' | ' + node + ' ' + f + ' child';
const exec = require('child_process').exec;
const f = JSON.stringify(__filename);
const node = JSON.stringify(process.execPath);
const cmd = `cat ${f} | ${node} ${f} child`;
exec(cmd, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');
Expand Down
22 changes: 11 additions & 11 deletions test/parallel/test-fs-readfilesync-pipe-large.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
const common = require('../common');
const assert = require('assert');
const path = require('path');

// simulate `cat readfile.js | node readfile.js`

if (common.isWindows || common.isAix) {
console.log(`1..0 # Skipped: No /dev/stdin on ${process.platform}.`);
common.skip(`No /dev/stdin on ${process.platform}.`);
return;
}

var fs = require('fs');
const fs = require('fs');

if (process.argv[2] === 'child') {
process.stdout.write(fs.readFileSync('/dev/stdin', 'utf8'));
return;
}

var filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt');
var dataExpected = new Array(1000000).join('a');
const filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt');
const dataExpected = new Array(1000000).join('a');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

common.refreshTmpDir();
fs.writeFileSync(filename, dataExpected);

var exec = require('child_process').exec;
var f = JSON.stringify(__filename);
var node = JSON.stringify(process.execPath);
var cmd = 'cat ' + filename + ' | ' + node + ' ' + f + ' child';
const exec = require('child_process').exec;
const f = JSON.stringify(__filename);
const node = JSON.stringify(process.execPath);
const cmd = `cat ${filename} | ${node} ${f} child`;
exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) {
if (err) console.error(err);
assert(!err, 'it exits normally');
Expand Down