@@ -3,6 +3,8 @@ import * as fixtures from '../common/fixtures.mjs';
|
3 | 3 | import * as snapshot from '../common/assertSnapshot.js'; |
4 | 4 | import { describe, it } from 'node:test'; |
5 | 5 | import { hostname } from 'node:os'; |
| 6 | +import { chdir, cwd } from 'node:process'; |
| 7 | +import { fileURLToPath } from 'node:url'; |
6 | 8 | |
7 | 9 | const skipForceColors = |
8 | 10 | process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' || |
@@ -14,8 +16,10 @@ function replaceTestDuration(str) {
|
14 | 16 | .replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *'); |
15 | 17 | } |
16 | 18 | |
| 19 | +const root = fileURLToPath(new URL('../..', import.meta.url)).slice(0, -1); |
| 20 | + |
17 | 21 | const color = '(\\[\\d+m)'; |
18 | | -const stackTraceBasePath = new RegExp(`${color}\\(${process.cwd().replaceAll(/[\\^$*+?.()|[\]{}]/g, '\\$&')}/?${color}(.*)${color}\\)`, 'g'); |
| 22 | +const stackTraceBasePath = new RegExp(`${color}\\(${root.replaceAll(/[\\^$*+?.()|[\]{}]/g, '\\$&')}/?${color}(.*)${color}\\)`, 'g'); |
19 | 23 | |
20 | 24 | function replaceSpecDuration(str) { |
21 | 25 | return str |
@@ -149,6 +153,9 @@ const tests = [
|
149 | 153 | }), |
150 | 154 | })); |
151 | 155 | |
| 156 | +if (cwd() !== root) { |
| 157 | +chdir(root); |
| 158 | +} |
152 | 159 | describe('test runner output', { concurrency: true }, () => { |
153 | 160 | for (const { name, fn } of tests) { |
154 | 161 | it(name, fn); |
|