| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 48f6d9a commit 00c0853
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,10 @@ const assert = require('node:assert/strict'); | |||
| 8 | 8 | const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g; | |
| 9 | 9 | const windowNewlineRegexp = /\r/g; | |
| 10 | 10 | ||
| 11 | + function replaceNodeVersion(str) { | ||
| 12 | + return str.replaceAll(process.version, '*'); | ||
| 13 | + } | ||
| 14 | + | ||
| 11 | 15 | function replaceStackTrace(str, replacement = '$1*$7$8\n') { | |
| 12 | 16 | return str.replace(stackFramesRegexp, replacement); | |
| 13 | 17 | } | |
@@ -69,6 +73,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... | |||
| 69 | 73 | module.exports = { | |
| 70 | 74 | assertSnapshot, | |
| 71 | 75 | getSnapshotPath, | |
| 76 | + replaceNodeVersion, | ||
| 72 | 77 | replaceStackTrace, | |
| 73 | 78 | replaceWindowsLineEndings, | |
| 74 | 79 | replaceWindowsPaths, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,11 +4,11 @@ throw new Error('Should include grayed stack trace') | |||
| 4 | 4 | ||
| 5 | 5 | Error: Should include grayed stack trace | |
| 6 | 6 | at Object.<anonymous> [90m(/[39mtest*force_colors.js:1:7[90m)[39m | |
| 7 | - [90m at Module._compile (node:internal*modules*cjs*loader:1356:14)[39m | ||
| 8 | - [90m at Module._extensions..js (node:internal*modules*cjs*loader:1414:10)[39m | ||
| 9 | - [90m at Module.load (node:internal*modules*cjs*loader:1197:32)[39m | ||
| 10 | - [90m at Module._load (node:internal*modules*cjs*loader:1013:12)[39m | ||
| 11 | - [90m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:128:12)[39m | ||
| 12 | - [90m at node:internal*main*run_main_module:28:49[39m | ||
| 7 | + [90m at *[39m | ||
| 8 | + [90m at *[39m | ||
| 9 | + [90m at *[39m | ||
| 10 | + [90m at *[39m | ||
| 11 | + [90m at *[39m | ||
| 12 | + [90m at *[39m | ||
| 13 | 13 | ||
| 14 | 14 | Node.js * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,14 +11,15 @@ const skipForceColors = | |||
| 11 | 11 | (common.isWindows && (Number(os.release().split('.')[0]) !== 10 || Number(os.release().split('.')[2]) < 14393)); // See https://github.com/nodejs/node/pull/33132 | |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | - function replaceNodeVersion(str) { | ||
| 15 | - return str.replaceAll(process.version, '*'); | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | 14 | function replaceStackTrace(str) { | |
| 19 | 15 | return snapshot.replaceStackTrace(str, '$1at *$7\n'); | |
| 20 | 16 | } | |
| 21 | 17 | ||
| 18 | + function replaceForceColorsStackTrace(str) { | ||
| 19 | + // eslint-disable-next-line no-control-regex | ||
| 20 | + return str.replaceAll(/(\[90m\W+)at .*node:.*/g, '$1at *[39m'); | ||
| 21 | + } | ||
| 22 | + | ||
| 22 | 23 | describe('errors output', { concurrency: true }, () => { | |
| 23 | 24 | function normalize(str) { | |
| 24 | 25 | return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') | |
@@ -35,9 +36,12 @@ describe('errors output', { concurrency: true }, () => { | |||
| 35 | 36 | } | |
| 36 | 37 | const common = snapshot | |
| 37 | 38 | .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths); | |
| 38 | - const defaultTransform = snapshot.transform(common, normalize, replaceNodeVersion); | ||
| 39 | - const errTransform = snapshot.transform(common, normalizeNoNumbers, replaceNodeVersion); | ||
| 40 | - const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion); | ||
| 39 | + const defaultTransform = snapshot.transform(common, normalize, snapshot.replaceNodeVersion); | ||
| 40 | + const errTransform = snapshot.transform(common, normalizeNoNumbers, snapshot.replaceNodeVersion); | ||
| 41 | + const promiseTransform = snapshot.transform(common, replaceStackTrace, | ||
| 42 | + normalizeNoNumbers, snapshot.replaceNodeVersion); | ||
| 43 | + const forceColorsTransform = snapshot.transform(common, normalize, | ||
| 44 | + replaceForceColorsStackTrace, snapshot.replaceNodeVersion); | ||
| 41 | 45 | ||
| 42 | 46 | const tests = [ | |
| 43 | 47 | { name: 'errors/async_error_eval_cjs.js' }, | |
@@ -57,7 +61,8 @@ describe('errors output', { concurrency: true }, () => { | |||
| 57 | 61 | { name: 'errors/throw_in_line_with_tabs.js', transform: errTransform }, | |
| 58 | 62 | { name: 'errors/throw_non_error.js', transform: errTransform }, | |
| 59 | 63 | { name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform }, | |
| 60 | - { skip: skipForceColors, name: 'errors/force_colors.js', env: { FORCE_COLOR: 1 } }, | ||
| 64 | + { skip: skipForceColors, name: 'errors/force_colors.js', | ||
| 65 | + transform: forceColorsTransform, env: { FORCE_COLOR: 1 } }, | ||
| 61 | 66 | ]; | |
| 62 | 67 | for (const { name, transform = defaultTransform, env, skip = false } of tests) { | |
| 63 | 68 | it(name, { skip }, async () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,10 +4,6 @@ import * as snapshot from '../common/assertSnapshot.js'; | |||
| 4 | 4 | import * as path from 'node:path'; | |
| 5 | 5 | import { describe, it } from 'node:test'; | |
| 6 | 6 | ||
| 7 | - function replaceNodeVersion(str) { | ||
| 8 | - return str.replaceAll(process.version, '*'); | ||
| 9 | - } | ||
| 10 | - | ||
| 11 | 7 | describe('sourcemaps output', { concurrency: true }, () => { | |
| 12 | 8 | function normalize(str) { | |
| 13 | 9 | const result = str | |
@@ -16,7 +12,8 @@ describe('sourcemaps output', { concurrency: true }, () => { | |||
| 16 | 12 | .replaceAll('/Users/bencoe/oss/coffee-script-test', '') | |
| 17 | 13 | .replaceAll(/\/(\w)/g, '*$1') | |
| 18 | 14 | .replaceAll('*test*', '*') | |
| 19 | - .replaceAll('*fixtures*source-map*', '*'); | ||
| 15 | + .replaceAll('*fixtures*source-map*', '*') | ||
| 16 | + .replaceAll(/(\W+).*node:internal\*modules.*/g, '$1*'); | ||
| 20 | 17 | if (common.isWindows) { | |
| 21 | 18 | const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 1).toLowerCase(); | |
| 22 | 19 | const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi'); | |
@@ -25,7 +22,8 @@ describe('sourcemaps output', { concurrency: true }, () => { | |||
| 25 | 22 | return result; | |
| 26 | 23 | } | |
| 27 | 24 | const defaultTransform = snapshot | |
| 28 | - .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion); | ||
| 25 | + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, | ||
| 26 | + normalize, snapshot.replaceNodeVersion); | ||
| 29 | 27 | ||
| 30 | 28 | const tests = [ | |
| 31 | 29 | { name: 'source-map/output/source_map_disabled_by_api.js' }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments