2023-04-27 06:41:58 +00:00
|
|
|
import '../common/index.mjs';
|
|
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
|
|
import * as snapshot from '../common/assertSnapshot.js';
|
|
|
|
import { describe, it } from 'node:test';
|
|
|
|
|
2023-05-18 12:36:38 +00:00
|
|
|
const skipForceColors =
|
|
|
|
process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' ||
|
|
|
|
process.config.variables.node_shared_openssl;
|
2023-04-27 06:41:58 +00:00
|
|
|
|
|
|
|
function replaceStackTrace(str) {
|
|
|
|
return snapshot.replaceStackTrace(str, '$1at *$7\n');
|
|
|
|
}
|
|
|
|
|
2024-03-23 21:11:28 +00:00
|
|
|
describe('console output', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
2023-05-05 17:10:31 +00:00
|
|
|
function normalize(str) {
|
|
|
|
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(process.version, '*').replaceAll(/\d+/g, '*');
|
2023-04-27 06:41:58 +00:00
|
|
|
}
|
|
|
|
const tests = [
|
|
|
|
{ name: 'console/2100bytes.js' },
|
|
|
|
{ name: 'console/console_low_stack_space.js' },
|
|
|
|
{ name: 'console/console.js' },
|
|
|
|
{ name: 'console/hello_world.js' },
|
|
|
|
{
|
|
|
|
name: 'console/stack_overflow.js',
|
|
|
|
transform: snapshot
|
2023-05-05 17:10:31 +00:00
|
|
|
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize)
|
2023-04-27 06:41:58 +00:00
|
|
|
},
|
2023-05-18 12:36:38 +00:00
|
|
|
!skipForceColors ? { name: 'console/force_colors.js', env: { FORCE_COLOR: 1 } } : null,
|
|
|
|
].filter(Boolean);
|
2023-04-27 06:41:58 +00:00
|
|
|
const defaultTransform = snapshot
|
|
|
|
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace);
|
2023-05-18 12:36:38 +00:00
|
|
|
for (const { name, transform, env } of tests) {
|
2023-04-27 06:41:58 +00:00
|
|
|
it(name, async () => {
|
2024-03-15 17:49:51 +00:00
|
|
|
await snapshot.spawnAndAssert(
|
|
|
|
fixtures.path(name),
|
|
|
|
transform ?? defaultTransform,
|
|
|
|
{ env: { ...env, ...process.env } },
|
|
|
|
);
|
2023-04-27 06:41:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|