summaryrefslogtreecommitdiff
path: root/test/message/async_error_eval_cjs.js
blob: a2caaa0937745e9ef7f664b48d23d078cb45dc12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';

require('../common');
const { spawnSync } = require('child_process');

const four = require('../common/fixtures')
  .readSync('async-error.js')
  .toString()
  .split('\n')
  .slice(2, -2)
  .join('\n');

const main = `${four}

async function main() {
  try {
    await four();
  } catch (e) {
    console.log(e);
  }
}

main();
`;

// --eval CJS
{
  const child = spawnSync(process.execPath, [
    '-e',
    main
  ], {
    env: { ...process.env }
  });

  if (child.status !== 0) {
    console.error(child.stderr.toString());
  }
  console.error(child.stdout.toString());
}