Skip to content

Commit

Permalink
add unit test for vercel#775
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Apr 5, 2021
1 parent 6deb812 commit 1456da1
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/test-775/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
console.log('Starting a');
const { Worker } = require('worker_threads');
new Worker('./b.js');
console.log('Finishing a');
3 changes: 3 additions & 0 deletions test/test-775/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// b.js
console.log('Starting b');
console.log('Finishing b');
56 changes: 56 additions & 0 deletions test/test-775/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env node

'use strict';

const path = require('path');
const assert = require('assert');
const utils = require('../utils.js');

assert(!module.parent);
assert(__dirname === process.cwd());

/* eslint-disable no-unused-vars */
const input = 'package.json';
const target = 'host';
const ext = process.platform === 'win32' ? '.exe' : '';
const output = 'output' + ext;

const inspect = ['ignore', 'ignore', 'pipe'];

const logPkg1 = utils.pkg.sync(
['--target', target, '--debug', '--output', output, input],
{ expect: 0 }
);

const log1 = utils.spawn.sync(path.join(__dirname, output), [], {
cwd: __dirname,
expect: 0,
});

assert.strictEqual(
log1,
`Starting a
Finishing a
Starting b
Finishing b
`
);

const logPkg2 = utils.pkg.sync(
['--target', target, '--debug', '--output', output, 'a.js'],
{ expect: 0 }
);

const log2 = utils.spawn.sync(path.join(__dirname, output), [], {
cwd: __dirname,
expect: 0,
});
assert.strictEqual(
log2,
`Starting a
Finishing a
Starting b
Finishing b
`
);
utils.vacuum.sync(output);
16 changes: 16 additions & 0 deletions test/test-775/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "a",
"version": "0.1.0",
"description": "proof",
"bin": "a.js",
"license": "UNLICENSED",
"devDependencies": {
"pkg": "^4.4.0"
},
"pkg": {
"scripts": [
"a.js",
"b.js"
]
}
}

0 comments on commit 1456da1

Please sign in to comment.