2018-02-07 10:33:51 +01:00
|
|
|
'use strict';
|
2018-05-18 01:20:25 +02:00
|
|
|
const common = require('../common');
|
2025-01-22 14:19:38 -08:00
|
|
|
const { isMainThread } = require('worker_threads');
|
|
|
|
|
|
|
|
if (!isMainThread) {
|
test: fix weird string error
Previously getting this error when running `tap2junit` (what parses our
`.tap` files in CI):
```
Traceback (most recent call last):
File "/usr/local/bin/tap2junit", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/tap2junit/__main__.py", line 46, in main
result.to_file(args.output, [result], prettyprint=False)
File "/usr/local/lib/python2.7/site-packages/junit_xml/__init__.py", line 289, in to_file
test_suites, prettyprint=prettyprint, encoding=encoding)
File "/usr/local/lib/python2.7/site-packages/junit_xml/__init__.py", line 257, in to_xml_string
ts_xml = ts.build_xml_doc(encoding=encoding)
File "/usr/local/lib/python2.7/site-packages/junit_xml/__init__.py", line 221, in build_xml_doc
attrs['message'] = decode(case.skipped_message, encoding)
File "/usr/local/lib/python2.7/site-packages/junit_xml/__init__.py", line 68, in decode
ret = unicode(var)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 11: ordinal not in range(128)
```
PR-URL: https://github.com/nodejs/node/pull/21793
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-07-13 10:45:42 -04:00
|
|
|
common.skip("Workers don't have process-like stdio");
|
2025-01-22 14:19:38 -08:00
|
|
|
}
|
2018-02-07 10:33:51 +01:00
|
|
|
|
2018-10-06 21:09:29 -04:00
|
|
|
// Test if Node handles accessing process.stdin if it is a redirected
|
2018-02-07 10:33:51 +01:00
|
|
|
// pipe without deadlocking
|
|
|
|
const { spawn, spawnSync } = require('child_process');
|
|
|
|
|
|
|
|
const numTries = 5;
|
|
|
|
const who = process.argv.length <= 2 ? 'runner' : process.argv[2];
|
|
|
|
|
|
|
|
switch (who) {
|
|
|
|
case 'runner':
|
|
|
|
for (let num = 0; num < numTries; ++num) {
|
|
|
|
spawnSync(process.argv0,
|
|
|
|
[process.argv[1], 'parent'],
|
|
|
|
{ 'stdio': 'inherit' });
|
|
|
|
}
|
|
|
|
break;
|
2022-01-02 20:21:46 -08:00
|
|
|
case 'parent': {
|
2018-02-07 10:33:51 +01:00
|
|
|
const middle = spawn(process.argv0,
|
|
|
|
[process.argv[1], 'middle'],
|
|
|
|
{ 'stdio': 'pipe' });
|
|
|
|
middle.stdout.on('data', () => {});
|
|
|
|
break;
|
2022-01-02 20:21:46 -08:00
|
|
|
}
|
2018-02-07 10:33:51 +01:00
|
|
|
case 'middle':
|
|
|
|
spawn(process.argv0,
|
|
|
|
[process.argv[1], 'bottom'],
|
|
|
|
{ 'stdio': [ process.stdin,
|
|
|
|
process.stdout,
|
|
|
|
process.stderr ] });
|
|
|
|
break;
|
|
|
|
case 'bottom':
|
2020-11-24 14:11:20 +01:00
|
|
|
process.stdin; // eslint-disable-line no-unused-expressions
|
2018-02-07 10:33:51 +01:00
|
|
|
break;
|
|
|
|
}
|