@tapjs/processinfo 3.0.2 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +8 -9
  2. package/dist/cjs/find-source-map-safe.d.ts +2 -1
  3. package/dist/cjs/find-source-map-safe.d.ts.map +1 -1
  4. package/dist/cjs/find-source-map-safe.js +15 -4
  5. package/dist/cjs/find-source-map-safe.js.map +1 -1
  6. package/dist/cjs/node-options-env.js +1 -1
  7. package/dist/cjs/node-options-env.js.map +1 -1
  8. package/dist/cjs/path-to-url.d.ts +2 -0
  9. package/dist/cjs/path-to-url.d.ts.map +1 -0
  10. package/dist/cjs/path-to-url.js +11 -0
  11. package/dist/cjs/path-to-url.js.map +1 -0
  12. package/dist/cjs/register-coverage.d.ts.map +1 -1
  13. package/dist/cjs/register-coverage.js +16 -10
  14. package/dist/cjs/register-coverage.js.map +1 -1
  15. package/dist/cjs/register-process-end.d.ts.map +1 -1
  16. package/dist/cjs/register-process-end.js +2 -15
  17. package/dist/cjs/register-process-end.js.map +1 -1
  18. package/dist/cjs/set-sources.d.ts +2 -0
  19. package/dist/cjs/set-sources.d.ts.map +1 -0
  20. package/dist/cjs/set-sources.js +20 -0
  21. package/dist/cjs/set-sources.js.map +1 -0
  22. package/dist/cjs/url-to-path.d.ts +2 -0
  23. package/dist/cjs/url-to-path.d.ts.map +1 -0
  24. package/dist/cjs/url-to-path.js +7 -0
  25. package/dist/cjs/url-to-path.js.map +1 -0
  26. package/dist/mjs/find-source-map-safe.d.ts +2 -1
  27. package/dist/mjs/find-source-map-safe.d.ts.map +1 -1
  28. package/dist/mjs/find-source-map-safe.js +15 -4
  29. package/dist/mjs/find-source-map-safe.js.map +1 -1
  30. package/dist/mjs/node-options-env.js +1 -1
  31. package/dist/mjs/node-options-env.js.map +1 -1
  32. package/dist/mjs/path-to-url.d.ts +2 -0
  33. package/dist/mjs/path-to-url.d.ts.map +1 -0
  34. package/dist/mjs/path-to-url.js +7 -0
  35. package/dist/mjs/path-to-url.js.map +1 -0
  36. package/dist/mjs/register-coverage.d.ts.map +1 -1
  37. package/dist/mjs/register-coverage.js +16 -10
  38. package/dist/mjs/register-coverage.js.map +1 -1
  39. package/dist/mjs/register-process-end.d.ts.map +1 -1
  40. package/dist/mjs/register-process-end.js +2 -15
  41. package/dist/mjs/register-process-end.js.map +1 -1
  42. package/dist/mjs/set-sources.d.ts +2 -0
  43. package/dist/mjs/set-sources.d.ts.map +1 -0
  44. package/dist/mjs/set-sources.js +16 -0
  45. package/dist/mjs/set-sources.js.map +1 -0
  46. package/dist/mjs/url-to-path.d.ts +2 -0
  47. package/dist/mjs/url-to-path.d.ts.map +1 -0
  48. package/dist/mjs/url-to-path.js +3 -0
  49. package/dist/mjs/url-to-path.js.map +1 -0
  50. package/package.json +1 -1
package/README.md CHANGED
@@ -119,22 +119,21 @@ will be empty.
119
119
  To disable coverage entirely, set
120
120
  `_TAPJS_PROCESSINFO_COVERAGE_=0` in the environment.
121
121
 
122
- To exclude certain file paths from coverage, set the
123
- `_TAPJS_PROCESSINFO_COV_EXCLUDE_` to a regular expression string.
124
- By default, it will ignore:
122
+ To exclude certain file paths from coverage with a pattern, set
123
+ the `_TAPJS_PROCESSINFO_COV_EXCLUDE_` to a regular expression
124
+ string. Note that processinfo will _never_ provide coverage for a
125
+ file that's excluded from process file tracking.
125
126
 
126
- - Anything in a folder named `node_modules`, `.tap`,
127
- `tap-snapshots`, `test`, `tests`, `__test__`, `__tests__`, or
128
- starting with `tap-testdir-`.
129
- - Any file named `*.test.{ext}` where `{ext}` is one of js, cjs,
130
- mjs, ts, cts, mts, jsx, or tsx.
127
+ To exclude specific individual file paths from coverage, set the
128
+ `_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_` to a `\n` delimited
129
+ set of file paths.
131
130
 
132
131
  To include only a specific set of files for coverage (as with
133
132
  node-tap's `coverage-map` option), set
134
133
  `_TAPJS_PROCESSINFO_COV_FILES_` to a `\n` delimited list of the
135
134
  files to include. These will have their coverage reported even if
136
135
  they would be excluded by the `_TAPJS_PROCESSINFO_COV_EXCLUDE_`
137
- regexp.
136
+ regexp or `_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_` list.
138
137
 
139
138
  Note that coverage _instrumentation_ is by necessity enabled for
140
139
  all files, but it's only written to disk if the file (or any of
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
- export declare const findSourceMapSafe: (s: string) => import("module").SourceMap | undefined;
2
+ import { SourceMap } from 'module';
3
+ export declare const findSourceMapSafe: (s: string | URL) => SourceMap | undefined;
3
4
  //# sourceMappingURL=find-source-map-safe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,iBAAiB,MAAO,MAAM,2CAI1C,CAAA"}
1
+ {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAA;AAKjD,eAAO,MAAM,iBAAiB,MAAO,MAAM,GAAG,GAAG,0BAehD,CAAA"}
@@ -2,14 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findSourceMapSafe = void 0;
4
4
  const module_1 = require("module");
5
- // this can throw in some cases in node 19
6
- /* c8 ignore start */
5
+ const path_to_url_js_1 = require("./path-to-url.js");
6
+ const sourceMaps = new Map();
7
7
  const findSourceMapSafe = (s) => {
8
+ // Have to look up by URL, because the ?tapmock param will be in
9
+ // the internal key used by node, as those are "different" modules.
10
+ const mod = (0, path_to_url_js_1.pathToURL)(s);
11
+ const c = sourceMaps.get(mod);
12
+ if (c)
13
+ return c;
14
+ // this can throw in some cases in node 19
8
15
  try {
9
- return (0, module_1.findSourceMap)(s);
16
+ const sm = (0, module_1.findSourceMap)(mod);
17
+ if (sm)
18
+ sourceMaps.set(mod, sm);
19
+ return sm;
20
+ /* c8 ignore start */
10
21
  }
11
22
  catch { }
23
+ /* c8 ignore stop */
12
24
  };
13
25
  exports.findSourceMapSafe = findSourceMapSafe;
14
- /* c8 ignore stop */
15
26
  //# sourceMappingURL=find-source-map-safe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,0CAA0C;AAC1C,qBAAqB;AACd,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7C,IAAI;QACF,OAAO,IAAA,sBAAa,EAAC,CAAC,CAAC,CAAA;KACxB;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AAJY,QAAA,iBAAiB,qBAI7B;AACD,oBAAoB","sourcesContent":["import { findSourceMap } from 'module'\n\n// this can throw in some cases in node 19\n/* c8 ignore start */\nexport const findSourceMapSafe = (s: string) => {\n try {\n return findSourceMap(s)\n } catch {}\n}\n/* c8 ignore stop */\n"]}
1
+ {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AACjD,qDAA4C;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAExC,MAAM,iBAAiB,GAAG,CAAC,CAAe,EAAE,EAAE;IACnD,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,GAAG,GAAG,IAAA,0BAAS,EAAC,CAAC,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAEf,0CAA0C;IAC1C,IAAI;QACF,MAAM,EAAE,GAAG,IAAA,sBAAa,EAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,EAAE;YAAE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC/B,OAAO,EAAE,CAAA;QACT,qBAAqB;KACtB;IAAC,MAAM,GAAE;IACV,oBAAoB;AACtB,CAAC,CAAA;AAfY,QAAA,iBAAiB,qBAe7B","sourcesContent":["import { findSourceMap, SourceMap } from 'module'\nimport { pathToURL } from './path-to-url.js'\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const findSourceMapSafe = (s: string | URL) => {\n // Have to look up by URL, because the ?tapmock param will be in\n // the internal key used by node, as those are \"different\" modules.\n const mod = pathToURL(s)\n const c = sourceMaps.get(mod)\n if (c) return c\n\n // this can throw in some cases in node 19\n try {\n const sm = findSourceMap(mod)\n if (sm) sourceMaps.set(mod, sm)\n return sm\n /* c8 ignore start */\n } catch {}\n /* c8 ignore stop */\n}\n"]}
@@ -82,7 +82,7 @@ const addLoader = (args) => {
82
82
  const addIgnoreLoadersWarning = (args) => args.includes('--no-warnings') ||
83
83
  args.includes('--no-warnings=ExperimentalLoader')
84
84
  ? args
85
- : args.concat('--no-warnings=ExperimentalLoader');
85
+ : args.concat('--no-warnings');
86
86
  const nodeOptionsEnv = (env) => {
87
87
  const no = (0, node_options_to_argv_js_1.nodeOptionsToArgv)(env.NODE_OPTIONS);
88
88
  return (0, argv_to_node_options_js_1.argvToNodeOptions)(addLoader(no));
@@ -1 +1 @@
1
- {"version":3,"file":"node-options-env.js","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":";;;;;;AAAA,uEAA6D;AAC7D,uDAK0B;AAC1B,uEAA6D;AAE7D,8DAAgC;AAEhC,MAAM,WAAW,GAAG,CAClB,IAAc,EACd,CAAS,EAC8B,EAAE;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnC,OAA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BAAuB,GAAG,CAAC,IAAuB,EAAE,EAAE,CAC1D,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;IAC9B,IAAI,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC/C,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAA;AAE9C,MAAM,cAAc,GAAG,CAC5B,GAAsB,EACtB,EAAE;IACF,MAAM,EAAE,GAAG,IAAA,2CAAiB,EAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,IAAA,2CAAiB,EAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B","sourcesContent":["import { argvToNodeOptions } from './argv-to-node-options.js'\nimport {\n legacyLoader,\n legacyMatch,\n importLoader,\n importMatch,\n} from './loader-paths.js'\nimport { nodeOptionsToArgv } from './node-options-to-argv.js'\n\nimport Module from 'node:module'\n\nconst getKeyValue = (\n args: string[],\n i: number\n): [boolean, string, string | undefined] => {\n const arg = args[i]\n if (arg.includes('=')) {\n const [k, ...rest] = arg.split('=')\n return [true, k, rest.join('=')]\n } else if (i < args.length - 1) {\n return [false, arg, args[i + 1]]\n } else {\n return [false, arg, undefined]\n }\n}\n\nconst useImport = !!(Module as { register?: (...a: any[]) => any })\n .register\n\nconst addLoader = (args: string[]) => {\n const addKey = useImport ? '--import' : '--loader'\n const addValue = useImport ? importLoader : legacyLoader\n const doNotWantKeys = [\n '--experimental-loader',\n useImport ? '--loader' : '--import',\n ]\n const test = useImport ? importMatch : legacyMatch\n\n const added: string[] = []\n\n let doubledash = false\n let found = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (!arg.startsWith('--') || doubledash) {\n added.push(arg)\n continue\n }\n if (arg === '--') {\n added.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n added.push(arg)\n continue\n }\n if (!eq) i++\n if (\n doNotWantKeys.includes(k) &&\n (importMatch(v) || legacyMatch(v))\n ) {\n // it's ours, but not how we want it, omit\n continue\n }\n\n if (k === addKey && test(v)) {\n // already present, don't let it be set multiple times.\n if (found) continue\n found = true\n added.push(arg)\n if (!eq) added.push(args[i])\n } else {\n // not ours\n added.push(arg)\n if (!eq) added.push(args[i])\n continue\n }\n }\n if (!found) added.push(`${addKey}=${addValue}`)\n return !useImport ? addIgnoreLoadersWarning(added) : added\n}\n\nconst addIgnoreLoadersWarning = (args: readonly string[]) =>\n args.includes('--no-warnings') ||\n args.includes('--no-warnings=ExperimentalLoader')\n ? args\n : args.concat('--no-warnings=ExperimentalLoader')\n\nexport const nodeOptionsEnv = (\n env: NodeJS.ProcessEnv,\n) => {\n const no = nodeOptionsToArgv(env.NODE_OPTIONS)\n return argvToNodeOptions(addLoader(no))\n}\n"]}
1
+ {"version":3,"file":"node-options-env.js","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":";;;;;;AAAA,uEAA6D;AAC7D,uDAK0B;AAC1B,uEAA6D;AAE7D,8DAAgC;AAEhC,MAAM,WAAW,GAAG,CAClB,IAAc,EACd,CAAS,EAC8B,EAAE;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;KACjC;SAAM,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;KACjC;SAAM;QACL,OAAO,C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AE;IACF,MAAM,EAAE,GAAG,IAAA,2CAAiB,EAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,IAAA,2CAAiB,EAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B","sourcesContent":["import { argvToNodeOptions } from './argv-to-node-options.js'\nimport {\n legacyLoader,\n legacyMatch,\n importLoader,\n importMatch,\n} from './loader-paths.js'\nimport { nodeOptionsToArgv } from './node-options-to-argv.js'\n\nimport Module from 'node:module'\n\nconst getKeyValue = (\n args: string[],\n i: number\n): [boolean, string, string | undefined] => {\n const arg = args[i]\n if (arg.includes('=')) {\n const [k, ...rest] = arg.split('=')\n return [true, k, rest.join('=')]\n } else if (i < args.length - 1) {\n return [false, arg, args[i + 1]]\n } else {\n return [false, arg, undefined]\n }\n}\n\nconst useImport = !!(Module as { register?: (...a: any[]) => any })\n .register\n\nconst addLoader = (args: string[]) => {\n const addKey = useImport ? '--import' : '--loader'\n const addValue = useImport ? importLoader : legacyLoader\n const doNotWantKeys = [\n '--experimental-loader',\n useImport ? '--loader' : '--import',\n ]\n const test = useImport ? importMatch : legacyMatch\n\n const added: string[] = []\n\n let doubledash = false\n let found = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (!arg.startsWith('--') || doubledash) {\n added.push(arg)\n continue\n }\n if (arg === '--') {\n added.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n added.push(arg)\n continue\n }\n if (!eq) i++\n if (\n doNotWantKeys.includes(k) &&\n (importMatch(v) || legacyMatch(v))\n ) {\n // it's ours, but not how we want it, omit\n continue\n }\n\n if (k === addKey && test(v)) {\n // already present, don't let it be set multiple times.\n if (found) continue\n found = true\n added.push(arg)\n if (!eq) added.push(args[i])\n } else {\n // not ours\n added.push(arg)\n if (!eq) added.push(args[i])\n continue\n }\n }\n if (!found) added.push(`${addKey}=${addValue}`)\n return !useImport ? addIgnoreLoadersWarning(added) : added\n}\n\nconst addIgnoreLoadersWarning = (args: readonly string[]) =>\n args.includes('--no-warnings') ||\n args.includes('--no-warnings=ExperimentalLoader')\n ? args\n : args.concat('--no-warnings')\n\nexport const nodeOptionsEnv = (\n env: NodeJS.ProcessEnv,\n) => {\n const no = nodeOptionsToArgv(env.NODE_OPTIONS)\n return argvToNodeOptions(addLoader(no))\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const pathToURL: (s: string | URL) => string;
2
+ //# sourceMappingURL=path-to-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.d.ts","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,KAAG,MAKd,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pathToURL = void 0;
4
+ const url_1 = require("url");
5
+ const pathToURL = (s) => typeof s === 'object'
6
+ ? String(s)
7
+ : s.startsWith('file://')
8
+ ? s
9
+ : String((0, url_1.pathToFileURL)(s));
10
+ exports.pathToURL = pathToURL;
11
+ //# sourceMappingURL=path-to-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.js","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AAE5B,MAAM,SAAS,GAAG,CAAC,CAAe,EAAU,EAAE,CACnD,OAAO,CAAC,KAAK,QAAQ;IACnB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,MAAM,CAAC,IAAA,mBAAa,EAAC,CAAC,CAAC,CAAC,CAAA;AALjB,QAAA,SAAS,aAKQ","sourcesContent":["import { pathToFileURL } from 'url'\n\nexport const pathToURL = (s: string | URL): string =>\n typeof s === 'object'\n ? String(s)\n : s.startsWith('file://')\n ? s\n : String(pathToFileURL(s))\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAMxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAG5D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAmDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
1
+ {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAOxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AA+DnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
@@ -13,10 +13,6 @@ const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
13
13
  const get_exclude_js_1 = require("./get-exclude.js");
14
14
  const line_lengths_js_1 = require("./line-lengths.js");
15
15
  exports.SESSION = undefined;
16
- // NB: coverage exclusion is in addition to processinfo
17
- // exclusion. Only show coverage for a file we care
18
- // about at least somewhat, but coverage is a subset.
19
- const exclude = (0, get_exclude_js_1.getExclude)('_TAPJS_PROCESSINFO_COV_EXCLUDE_');
20
16
  // This is a \n delimited list of files to show coverage for
21
17
  // If not set, or empty, then coverage is included for all files
22
18
  // that pass the exclusion RegExp filter. If included in this list,
@@ -26,6 +22,17 @@ const coveredFiles = cfEnv
26
22
  .trim()
27
23
  .split('\n')
28
24
  .filter(f => !!f);
25
+ // NB: coverage exclusion is in addition to processinfo
26
+ // exclusion. Only show coverage for a file we care
27
+ // about at least somewhat, but coverage is a subset.
28
+ const cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || '';
29
+ const uncoveredFiles = cxEnv
30
+ .trim()
31
+ .split('\n')
32
+ .filter(f => !!f);
33
+ const exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_
34
+ ? (0, get_exclude_js_1.getExclude)('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)
35
+ : undefined;
29
36
  const fileCovered = (f, s, files = []) => {
30
37
  const testFiles = [f];
31
38
  if (s) {
@@ -33,6 +40,7 @@ const fileCovered = (f, s, files = []) => {
33
40
  testFiles.push((0, node_path_1.resolve)(src.startsWith('file://') ? (0, node_url_1.fileURLToPath)(src) : src));
34
41
  }
35
42
  }
43
+ // never include coverage if the file is fully ignored.
36
44
  if (!testFiles.some(f => files.includes(f)))
37
45
  return false;
38
46
  // if at least one of them are explicitly covered, then include it,
@@ -40,11 +48,9 @@ const fileCovered = (f, s, files = []) => {
40
48
  if (coveredFiles.length) {
41
49
  return testFiles.some(f => coveredFiles.includes(f));
42
50
  }
43
- for (const f of testFiles) {
44
- if (!exclude.test(f))
45
- return true;
46
- }
47
- return false;
51
+ // if any of the filenames are explicitly excluded, no coverage
52
+ // otherwise, it is covered
53
+ return !testFiles.some(f => uncoveredFiles.includes(f) || exclude?.test(f));
48
54
  };
49
55
  // C8 can't see that this function runs, best theory is that it
50
56
  // collides with what it's doing with the coverage it's collecting
@@ -101,7 +107,7 @@ const coverageOnProcessEnd = (cwd, processInfo) => {
101
107
  // see if it has a source map
102
108
  // need to look up via the url, not the file path, because mocks
103
109
  // attach a tapmock search param, which is in node's internal key.
104
- const s = (0, find_source_map_safe_js_1.findSourceMapSafe)(String(obj.url));
110
+ const s = (0, find_source_map_safe_js_1.findSourceMapSafe)(obj.url);
105
111
  if (!fileCovered(f, s?.payload, processInfo.files)) {
106
112
  return false;
107
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,qCAAkD;AAClD,mDAAwC;AAExC,yCAAmC;AACnC,uCAAwC;AACxC,uEAA6D;AAC7D,qDAA6C;AAE7C,uDAAkD;AAEvC,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;AACvD,oDAAoD;AACpD,qDAAqD;AACrD,MAAM,OAAO,GAAG,IAAA,2BAAU,EAAC,iCAAiC,CAAC,CAAA;AAE7D,4DAA4D;AAC5D,gEAAgE;AAChE,mEAAmE;AACnE,8DAA8D;AAC9D,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,6BAA6B,IAAI,EAAE,CAAA;AACvD,MAAM,YAAY,GAAa,KAAK;KACjC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnB,MAAM,WAAW,GAAG,CAClB,CAAS,EACT,CAAoB,EACpB,QAAkB,EAAE,EACpB,EAAE;IACF,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,CAAA;IACrB,IAAI,CAAC,EAAE;QACL,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE;YACjC,SAAS,CAAC,IAAI,CACZ,IAAA,mBAAO,EAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAC9D,CAAA;SACF;KACF;IACD,IAAI,CAAC,SAAS,CAAC,I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AAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,IAAA,gCAAc,EAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAA,uBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AA7DY,QAAA,oBAAoB,wBA6DhC;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\nimport { getLineLengths } from './line-lengths.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(String(obj.url))\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
1
+ {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,qCAAkD;AAClD,mDAAwC;AAExC,yCAAmC;AACnC,uCAAwC;AACxC,uEAA6D;AAC7D,qDAA6C;AAC7C,uDAAkD;AAGvC,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,4DAA4D;AAC5D,gEAAgE;AAChE,mEAAmE;AACnE,8DAA8D;AAC9D,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,6BAA6B,IAAI,EAAE,CAAA;AACvD,MAAM,YAAY,GAAa,KAAK;KACjC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnB,uDAAuD;AACvD,oDAAoD;AACpD,qDAAqD;AACrD,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,qCAAqC,IAAI,EAAE,CAAA;AAC/D,MAAM,cAAc,GAAa,KAAK;KACnC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,CAA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cAAc;SACnC,CAAC,CAAA;QAEF,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC3B,OAAO,KAAK,CAAA;aACb;YACD,MAAM,CAAC,GAAG,IAAA,wBAAa,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChC,6BAA6B;YAC7B,gEAAgE;YAChE,kEAAkE;YAClE,MAAM,CAAC,GAAG,IAAA,2CAAiB,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACpC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO,KAAK,CAAA;aACb;YACD,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;YAC1C,IAAI,OAAO,EAAE;gBACX,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,IAAA,gCAAc,EAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAA,uBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AA7DY,QAAA,oBAAoB,wBA6DhC;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getExclude } from './get-exclude.js'\nimport { getLineLengths } from './line-lengths.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || ''\nconst uncoveredFiles: string[] = cxEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\nconst exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_\n ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)\n : undefined\n\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n\n // never include coverage if the file is fully ignored.\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n // if any of the filenames are explicitly excluded, no coverage\n // otherwise, it is covered\n return !testFiles.some(\n f => uncoveredFiles.includes(f) || exclude?.test(f)\n )\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(obj.url)\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,YAsCpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ,YA4BpB,CAAA"}
@@ -4,14 +4,12 @@ exports.register = void 0;
4
4
  const signal_exit_1 = require("signal-exit");
5
5
  const get_process_info_js_1 = require("./get-process-info.js");
6
6
  const fs_1 = require("fs");
7
- const url_1 = require("url");
8
- const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
9
7
  const register_coverage_js_1 = require("./register-coverage.js");
8
+ const set_sources_js_1 = require("./set-sources.js");
10
9
  const proc = process;
11
10
  const cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd();
12
11
  proc.env._TAPJS_PROCESSINFO_CWD_ = cwd;
13
12
  const globals = new Set(Object.keys(global));
14
- const sourceMaps = new Map();
15
13
  const register = () => {
16
14
  (0, signal_exit_1.onExit)((code, signal) => {
17
15
  const processInfo = (0, get_process_info_js_1.getProcessInfo)();
@@ -24,18 +22,7 @@ const register = () => {
24
22
  // This can't be done up front, because the sourcemap isn't
25
23
  // present during the load phase, since it's in the contents.
26
24
  for (const file of processInfo.files) {
27
- const sm = sourceMaps.get(file) || (0, find_source_map_safe_js_1.findSourceMapSafe)(file);
28
- if (sm && !sourceMaps.has(file))
29
- sourceMaps.set(file, sm);
30
- const sources = sm?.payload.sources?.map(s =>
31
- // it SHOULD always start with file://, but could in theory
32
- // be literally any string.
33
- /* c8 ignore start */
34
- s.startsWith('file://') ? (0, url_1.fileURLToPath)(s) : s
35
- /* c8 ignore stop */
36
- );
37
- if (sources)
38
- processInfo.sources[file] = sources;
25
+ (0, set_sources_js_1.setSources)(file);
39
26
  }
40
27
  processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6;
41
28
  const globalsAdded = Object.keys(global).filter(k => !globals.has(k));
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AACpC,+DAAsD;AAEtD,2BAA6C;AAE7C,6BAAmC;AACnC,uEAA6D;AAC7D,iEAA6D;AAE7D,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAExC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,IAAA,oBAAM,EACJ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,WAAW,GAAG,IAAA,oCAAc,GAAE,CAAA;QACpC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAA;QACvB,WAAW,CAAC,MAAM,GAAG,MAAM,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,WAAW,CAAC,OAAO,CAAA;QAC1B,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;QACnD,wDAAwD;QACxD,2DAA2D;QAC3D,6DAA6D;QAC7D,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE;YACpC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAA,2CAAiB,EAA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,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA;AAtCY,QAAA,QAAQ,YAsCpB","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { SourceMap } from 'module'\nimport { fileURLToPath } from 'url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { coverageOnProcessEnd } from './register-coverage.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n const sm = sourceMaps.get(file) || findSourceMapSafe(file)\n if (sm && !sourceMaps.has(file)) sourceMaps.set(file, sm)\n const sources = sm?.payload.sources?.map(\n s =>\n // it SHOULD always start with file://, but could in theory\n // be literally any string.\n /* c8 ignore start */\n s.startsWith('file://') ? fileURLToPath(s) : s\n /* c8 ignore stop */\n )\n if (sources) processInfo.sources[file] = sources\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}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E,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACrE,IAAI,YAAY,CAAC,MAAM,EAAE;YACvB,WAAW,CAAC,YAAY,GAAG,YAAY,CAAA;SACxC;QAED,MAAM,CAAC,GAAG,GAAG,GAAG,qBAAqB,WAAW,CAAC,IAAI,OAAO,CAAA;QAC5D,IAAA,cAAS,EAAC,GAAG,GAAG,mBAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,IAAA,kBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACrE,IAAA,2CAAoB,EAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA;AA5BY,QAAA,QAAQ,YA4BpB","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { coverageOnProcessEnd } from './register-coverage.js'\nimport { setSources } from './set-sources.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n setSources(file)\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const setSources: (file: string) => void;
2
+ //# sourceMappingURL=set-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.d.ts","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,SAAU,MAAM,SAOtC,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setSources = void 0;
4
+ const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
5
+ const get_process_info_js_1 = require("./get-process-info.js");
6
+ const url_to_path_js_1 = require("./url-to-path.js");
7
+ // set the processInfo.sources for a given file, but don't clobber
8
+ // if called multiple times, or create duplicate entries.
9
+ // Should only be called *after* the file in question has been loaded.
10
+ const setSources = (file) => {
11
+ const sm = (0, find_source_map_safe_js_1.findSourceMapSafe)(file);
12
+ if (!sm)
13
+ return;
14
+ const pi = (0, get_process_info_js_1.getProcessInfo)();
15
+ const s = pi.sources[file] || [];
16
+ s.push(...sm.payload.sources.map(s => (0, url_to_path_js_1.urlToPath)(s)));
17
+ pi.sources[file] = [...new Set(s)];
18
+ };
19
+ exports.setSources = setSources;
20
+ //# sourceMappingURL=set-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.js","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":";;;AAAA,uEAA6D;AAC7D,+DAAsD;AACtD,qDAA0C;AAE1C,kEAAkE;AAClE,yDAAyD;AACzD,sEAAsE;AAC/D,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,MAAM,EAAE,GAAG,IAAA,2CAAiB,EAAC,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,EAAE;QAAE,OAAM;IACf,MAAM,EAAE,GAAG,IAAA,oCAAc,GAAE,CAAA;IAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAChC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,0BAAS,EAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC,CAAA;AAPY,QAAA,UAAU,cAOtB","sourcesContent":["import { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport {urlToPath} from './url-to-path.js'\n\n// set the processInfo.sources for a given file, but don't clobber\n// if called multiple times, or create duplicate entries.\n// Should only be called *after* the file in question has been loaded.\nexport const setSources = (file: string) => {\n const sm = findSourceMapSafe(file)\n if (!sm) return\n const pi = getProcessInfo()\n const s = pi.sources[file] || []\n s.push(...sm.payload.sources.map(s => urlToPath(s)))\n pi.sources[file] = [...new Set(s)]\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const urlToPath: (s: string | URL) => string;
2
+ //# sourceMappingURL=url-to-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.d.ts","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,WACgC,CAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.urlToPath = void 0;
4
+ const url_1 = require("url");
5
+ const urlToPath = (s) => typeof s === 'object' || s.startsWith('file://') ? (0, url_1.fileURLToPath)(s) : s;
6
+ exports.urlToPath = urlToPath;
7
+ //# sourceMappingURL=url-to-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.js","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AAE5B,MAAM,SAAS,GAAG,CAAC,CAAe,EAAE,EAAE,CAC3C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAa,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAD5D,QAAA,SAAS,aACmD","sourcesContent":["import { fileURLToPath } from 'url'\n\nexport const urlToPath = (s: string | URL) =>\n typeof s === 'object' || s.startsWith('file://') ? fileURLToPath(s) : s\n"]}
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
- export declare const findSourceMapSafe: (s: string) => import("module").SourceMap | undefined;
2
+ import { SourceMap } from 'module';
3
+ export declare const findSourceMapSafe: (s: string | URL) => SourceMap | undefined;
3
4
  //# sourceMappingURL=find-source-map-safe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,iBAAiB,MAAO,MAAM,2CAI1C,CAAA"}
1
+ {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAA;AAKjD,eAAO,MAAM,iBAAiB,MAAO,MAAM,GAAG,GAAG,0BAehD,CAAA"}
@@ -1,11 +1,22 @@
1
1
  import { findSourceMap } from 'module';
2
- // this can throw in some cases in node 19
3
- /* c8 ignore start */
2
+ import { pathToURL } from './path-to-url.js';
3
+ const sourceMaps = new Map();
4
4
  export const findSourceMapSafe = (s) => {
5
+ // Have to look up by URL, because the ?tapmock param will be in
6
+ // the internal key used by node, as those are "different" modules.
7
+ const mod = pathToURL(s);
8
+ const c = sourceMaps.get(mod);
9
+ if (c)
10
+ return c;
11
+ // this can throw in some cases in node 19
5
12
  try {
6
- return findSourceMap(s);
13
+ const sm = findSourceMap(mod);
14
+ if (sm)
15
+ sourceMaps.set(mod, sm);
16
+ return sm;
17
+ /* c8 ignore start */
7
18
  }
8
19
  catch { }
20
+ /* c8 ignore stop */
9
21
  };
10
- /* c8 ignore stop */
11
22
  //# sourceMappingURL=find-source-map-safe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC,0CAA0C;AAC1C,qBAAqB;AACrB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7C,IAAI;QACF,OAAO,aAAa,CAAC,CAAC,CAAC,CAAA;KACxB;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["import { findSourceMap } from 'module'\n\n// this can throw in some cases in node 19\n/* c8 ignore start */\nexport const findSourceMapSafe = (s: string) => {\n try {\n return findSourceMap(s)\n } catch {}\n}\n/* c8 ignore stop */\n"]}
1
+ {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAe,EAAE,EAAE;IACnD,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAEf,0CAA0C;IAC1C,IAAI;QACF,MAAM,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,EAAE;YAAE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC/B,OAAO,EAAE,CAAA;QACT,qBAAqB;KACtB;IAAC,MAAM,GAAE;IACV,oBAAoB;AACtB,CAAC,CAAA","sourcesContent":["import { findSourceMap, SourceMap } from 'module'\nimport { pathToURL } from './path-to-url.js'\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const findSourceMapSafe = (s: string | URL) => {\n // Have to look up by URL, because the ?tapmock param will be in\n // the internal key used by node, as those are \"different\" modules.\n const mod = pathToURL(s)\n const c = sourceMaps.get(mod)\n if (c) return c\n\n // this can throw in some cases in node 19\n try {\n const sm = findSourceMap(mod)\n if (sm) sourceMaps.set(mod, sm)\n return sm\n /* c8 ignore start */\n } catch {}\n /* c8 ignore stop */\n}\n"]}
@@ -76,7 +76,7 @@ const addLoader = (args) => {
76
76
  const addIgnoreLoadersWarning = (args) => args.includes('--no-warnings') ||
77
77
  args.includes('--no-warnings=ExperimentalLoader')
78
78
  ? args
79
- : args.concat('--no-warnings=ExperimentalLoader');
79
+ : args.concat('--no-warnings');
80
80
  export const nodeOptionsEnv = (env) => {
81
81
  const no = nodeOptionsToArgv(env.NODE_OPTIONS);
82
82
  return argvToNodeOptions(addLoader(no));
@@ -1 +1 @@
1
- {"version":3,"file":"node-options-env.js","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAA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AAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;YAC5B,SAAQ;SACT;KACF;IACD,IAAI,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAC5D,CAAC,CAAA;AAED,MAAM,uBAAuB,GAAG,CAAC,IAAuB,EAAE,EAAE,CAC1D,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;IAC9B,IAAI,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC/C,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAA;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,GAAsB,EACtB,EAAE;IACF,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import { argvToNodeOptions } from './argv-to-node-options.js'\nimport {\n legacyLoader,\n legacyMatch,\n importLoader,\n importMatch,\n} from './loader-paths.js'\nimport { nodeOptionsToArgv } from './node-options-to-argv.js'\n\nimport Module from 'node:module'\n\nconst getKeyValue = (\n args: string[],\n i: number\n): [boolean, string, string | undefined] => {\n const arg = args[i]\n if (arg.includes('=')) {\n const [k, ...rest] = arg.split('=')\n return [true, k, rest.join('=')]\n } else if (i < args.length - 1) {\n return [false, arg, args[i + 1]]\n } else {\n return [false, arg, undefined]\n }\n}\n\nconst useImport = !!(Module as { register?: (...a: any[]) => any })\n .register\n\nconst addLoader = (args: string[]) => {\n const addKey = useImport ? '--import' : '--loader'\n const addValue = useImport ? importLoader : legacyLoader\n const doNotWantKeys = [\n '--experimental-loader',\n useImport ? '--loader' : '--import',\n ]\n const test = useImport ? importMatch : legacyMatch\n\n const added: string[] = []\n\n let doubledash = false\n let found = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (!arg.startsWith('--') || doubledash) {\n added.push(arg)\n continue\n }\n if (arg === '--') {\n added.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n added.push(arg)\n continue\n }\n if (!eq) i++\n if (\n doNotWantKeys.includes(k) &&\n (importMatch(v) || legacyMatch(v))\n ) {\n // it's ours, but not how we want it, omit\n continue\n }\n\n if (k === addKey && test(v)) {\n // already present, don't let it be set multiple times.\n if (found) continue\n found = true\n added.push(arg)\n if (!eq) added.push(args[i])\n } else {\n // not ours\n added.push(arg)\n if (!eq) added.push(args[i])\n continue\n }\n }\n if (!found) added.push(`${addKey}=${addValue}`)\n return !useImport ? addIgnoreLoadersWarning(added) : added\n}\n\nconst addIgnoreLoadersWarning = (args: readonly string[]) =>\n args.includes('--no-warnings') ||\n args.includes('--no-warnings=ExperimentalLoader')\n ? args\n : args.concat('--no-warnings=ExperimentalLoader')\n\nexport const nodeOptionsEnv = (\n env: NodeJS.ProcessEnv,\n) => {\n const no = nodeOptionsToArgv(env.NODE_OPTIONS)\n return argvToNodeOptions(addLoader(no))\n}\n"]}
1
+ {"version":3,"file":"node-options-env.js","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,CAClB,IAAc,EACd,CAAS,EAC8B,EAAE;IACzC,MAAM,GAAG,GAAG,I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,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAC5D,CAAC,CAAA;AAED,MAAM,uBAAuB,GAAG,CAAC,IAAuB,EAAE,EAAE,CAC1D,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;IAC9B,IAAI,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC/C,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;AAElC,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,GAAsB,EACtB,EAAE;IACF,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import { argvToNodeOptions } from './argv-to-node-options.js'\nimport {\n legacyLoader,\n legacyMatch,\n importLoader,\n importMatch,\n} from './loader-paths.js'\nimport { nodeOptionsToArgv } from './node-options-to-argv.js'\n\nimport Module from 'node:module'\n\nconst getKeyValue = (\n args: string[],\n i: number\n): [boolean, string, string | undefined] => {\n const arg = args[i]\n if (arg.includes('=')) {\n const [k, ...rest] = arg.split('=')\n return [true, k, rest.join('=')]\n } else if (i < args.length - 1) {\n return [false, arg, args[i + 1]]\n } else {\n return [false, arg, undefined]\n }\n}\n\nconst useImport = !!(Module as { register?: (...a: any[]) => any })\n .register\n\nconst addLoader = (args: string[]) => {\n const addKey = useImport ? '--import' : '--loader'\n const addValue = useImport ? importLoader : legacyLoader\n const doNotWantKeys = [\n '--experimental-loader',\n useImport ? '--loader' : '--import',\n ]\n const test = useImport ? importMatch : legacyMatch\n\n const added: string[] = []\n\n let doubledash = false\n let found = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (!arg.startsWith('--') || doubledash) {\n added.push(arg)\n continue\n }\n if (arg === '--') {\n added.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n added.push(arg)\n continue\n }\n if (!eq) i++\n if (\n doNotWantKeys.includes(k) &&\n (importMatch(v) || legacyMatch(v))\n ) {\n // it's ours, but not how we want it, omit\n continue\n }\n\n if (k === addKey && test(v)) {\n // already present, don't let it be set multiple times.\n if (found) continue\n found = true\n added.push(arg)\n if (!eq) added.push(args[i])\n } else {\n // not ours\n added.push(arg)\n if (!eq) added.push(args[i])\n continue\n }\n }\n if (!found) added.push(`${addKey}=${addValue}`)\n return !useImport ? addIgnoreLoadersWarning(added) : added\n}\n\nconst addIgnoreLoadersWarning = (args: readonly string[]) =>\n args.includes('--no-warnings') ||\n args.includes('--no-warnings=ExperimentalLoader')\n ? args\n : args.concat('--no-warnings')\n\nexport const nodeOptionsEnv = (\n env: NodeJS.ProcessEnv,\n) => {\n const no = nodeOptionsToArgv(env.NODE_OPTIONS)\n return argvToNodeOptions(addLoader(no))\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const pathToURL: (s: string | URL) => string;
2
+ //# sourceMappingURL=path-to-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.d.ts","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,KAAG,MAKd,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { pathToFileURL } from 'url';
2
+ export const pathToURL = (s) => typeof s === 'object'
3
+ ? String(s)
4
+ : s.startsWith('file://')
5
+ ? s
6
+ : String(pathToFileURL(s));
7
+ //# sourceMappingURL=path-to-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.js","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAe,EAAU,EAAE,CACnD,OAAO,CAAC,KAAK,QAAQ;IACnB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { pathToFileURL } from 'url'\n\nexport const pathToURL = (s: string | URL): string =>\n typeof s === 'object'\n ? String(s)\n : s.startsWith('file://')\n ? s\n : String(pathToFileURL(s))\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAMxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAG5D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAmDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
1
+ {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAOxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AA+DnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
@@ -10,10 +10,6 @@ import { findSourceMapSafe } from './find-source-map-safe.js';
10
10
  import { getExclude } from './get-exclude.js';
11
11
  import { getLineLengths } from './line-lengths.js';
12
12
  export let SESSION = undefined;
13
- // NB: coverage exclusion is in addition to processinfo
14
- // exclusion. Only show coverage for a file we care
15
- // about at least somewhat, but coverage is a subset.
16
- const exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_');
17
13
  // This is a \n delimited list of files to show coverage for
18
14
  // If not set, or empty, then coverage is included for all files
19
15
  // that pass the exclusion RegExp filter. If included in this list,
@@ -23,6 +19,17 @@ const coveredFiles = cfEnv
23
19
  .trim()
24
20
  .split('\n')
25
21
  .filter(f => !!f);
22
+ // NB: coverage exclusion is in addition to processinfo
23
+ // exclusion. Only show coverage for a file we care
24
+ // about at least somewhat, but coverage is a subset.
25
+ const cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || '';
26
+ const uncoveredFiles = cxEnv
27
+ .trim()
28
+ .split('\n')
29
+ .filter(f => !!f);
30
+ const exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_
31
+ ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)
32
+ : undefined;
26
33
  const fileCovered = (f, s, files = []) => {
27
34
  const testFiles = [f];
28
35
  if (s) {
@@ -30,6 +37,7 @@ const fileCovered = (f, s, files = []) => {
30
37
  testFiles.push(resolve(src.startsWith('file://') ? fileURLToPath(src) : src));
31
38
  }
32
39
  }
40
+ // never include coverage if the file is fully ignored.
33
41
  if (!testFiles.some(f => files.includes(f)))
34
42
  return false;
35
43
  // if at least one of them are explicitly covered, then include it,
@@ -37,11 +45,9 @@ const fileCovered = (f, s, files = []) => {
37
45
  if (coveredFiles.length) {
38
46
  return testFiles.some(f => coveredFiles.includes(f));
39
47
  }
40
- for (const f of testFiles) {
41
- if (!exclude.test(f))
42
- return true;
43
- }
44
- return false;
48
+ // if any of the filenames are explicitly excluded, no coverage
49
+ // otherwise, it is covered
50
+ return !testFiles.some(f => uncoveredFiles.includes(f) || exclude?.test(f));
45
51
  };
46
52
  // C8 can't see that this function runs, best theory is that it
47
53
  // collides with what it's doing with the coverage it's collecting
@@ -97,7 +103,7 @@ export const coverageOnProcessEnd = (cwd, processInfo) => {
97
103
  // see if it has a source map
98
104
  // need to look up via the url, not the file path, because mocks
99
105
  // attach a tapmock search param, which is in node's internal key.
100
- const s = findSourceMapSafe(String(obj.url));
106
+ const s = findSourceMapSafe(obj.url);
101
107
  if (!fileCovered(f, s?.payload, processInfo.files)) {
102
108
  return false;
103
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,CAAC,IAAI,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;AACvD,oDAAoD;AACpD,qDAAqD;AACrD,MAAM,OAAO,GAAG,UAAU,CAAC,iCAAiC,CAAC,CAAA;AAE7D,4DAA4D;AAC5D,gEAAgE;AAChE,mEAAmE;AACnE,8DAA8D;AAC9D,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,6BAA6B,IAAI,EAAE,CAAA;AACvD,MAAM,YAAY,GAAa,KAAK;KACjC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,CAAC,CAAC,CAAC,EAAE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GAAG,CAAC,GAAG,CAAC,CAAA;YAChC,6BAA6B;YAC7B,gEAAgE;YAChE,kEAAkE;YAClE,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5C,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO,KAAK,CAAA;aACb;YACD,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;YAC1C,IAAI,OAAO,EAAE;gBACX,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\nimport { getLineLengths } from './line-lengths.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(String(obj.url))\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
1
+ {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2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1C,IAAI,OAAO,EAAE;gBACX,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getExclude } from './get-exclude.js'\nimport { getLineLengths } from './line-lengths.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || ''\nconst uncoveredFiles: string[] = cxEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\nconst exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_\n ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)\n : undefined\n\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n\n // never include coverage if the file is fully ignored.\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n // if any of the filenames are explicitly excluded, no coverage\n // otherwise, it is covered\n return !testFiles.some(\n f => uncoveredFiles.includes(f) || exclude?.test(f)\n )\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(obj.url)\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,YAsCpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ,YA4BpB,CAAA"}
@@ -1,14 +1,12 @@
1
1
  import { onExit } from 'signal-exit';
2
2
  import { getProcessInfo } from './get-process-info.js';
3
3
  import { mkdirSync, writeFileSync } from 'fs';
4
- import { fileURLToPath } from 'url';
5
- import { findSourceMapSafe } from './find-source-map-safe.js';
6
4
  import { coverageOnProcessEnd } from './register-coverage.js';
5
+ import { setSources } from './set-sources.js';
7
6
  const proc = process;
8
7
  const cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd();
9
8
  proc.env._TAPJS_PROCESSINFO_CWD_ = cwd;
10
9
  const globals = new Set(Object.keys(global));
11
- const sourceMaps = new Map();
12
10
  export const register = () => {
13
11
  onExit((code, signal) => {
14
12
  const processInfo = getProcessInfo();
@@ -21,18 +19,7 @@ export const register = () => {
21
19
  // This can't be done up front, because the sourcemap isn't
22
20
  // present during the load phase, since it's in the contents.
23
21
  for (const file of processInfo.files) {
24
- const sm = sourceMaps.get(file) || findSourceMapSafe(file);
25
- if (sm && !sourceMaps.has(file))
26
- sourceMaps.set(file, sm);
27
- const sources = sm?.payload.sources?.map(s =>
28
- // it SHOULD always start with file://, but could in theory
29
- // be literally any string.
30
- /* c8 ignore start */
31
- s.startsWith('file://') ? fileURLToPath(s) : s
32
- /* c8 ignore stop */
33
- );
34
- if (sources)
35
- processInfo.sources[file] = sources;
22
+ setSources(file);
36
23
  }
37
24
  processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6;
38
25
  const globalsAdded = Object.keys(global).filter(k => !globals.has(k));
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAA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AAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;QACzD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACrE,IAAI,YAAY,CAAC,MAAM,EAAE;YACvB,WAAW,CAAC,YAAY,GAAG,YAAY,CAAA;SACxC;QAED,MAAM,CAAC,GAAG,GAAG,GAAG,qBAAqB,WAAW,CAAC,IAAI,OAAO,CAAA;QAC5D,SAAS,CAAC,GAAG,GAAG,mBAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACrE,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { SourceMap } from 'module'\nimport { fileURLToPath } from 'url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { coverageOnProcessEnd } from './register-coverage.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n const sm = sourceMaps.get(file) || findSourceMapSafe(file)\n if (sm && !sourceMaps.has(file)) sourceMaps.set(file, sm)\n const sources = sm?.payload.sources?.map(\n s =>\n // it SHOULD always start with file://, but could in theory\n // be literally any string.\n /* c8 ignore start */\n s.startsWith('file://') ? fileURLToPath(s) : s\n /* c8 ignore stop */\n )\n if (sources) processInfo.sources[file] = sources\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
1
+ {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,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,EAAE,MAAM,CAAC,CAAA;QACrE,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { coverageOnProcessEnd } from './register-coverage.js'\nimport { setSources } from './set-sources.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n setSources(file)\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const setSources: (file: string) => void;
2
+ //# sourceMappingURL=set-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.d.ts","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,SAAU,MAAM,SAOtC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { findSourceMapSafe } from './find-source-map-safe.js';
2
+ import { getProcessInfo } from './get-process-info.js';
3
+ import { urlToPath } from './url-to-path.js';
4
+ // set the processInfo.sources for a given file, but don't clobber
5
+ // if called multiple times, or create duplicate entries.
6
+ // Should only be called *after* the file in question has been loaded.
7
+ export const setSources = (file) => {
8
+ const sm = findSourceMapSafe(file);
9
+ if (!sm)
10
+ return;
11
+ const pi = getProcessInfo();
12
+ const s = pi.sources[file] || [];
13
+ s.push(...sm.payload.sources.map(s => urlToPath(s)));
14
+ pi.sources[file] = [...new Set(s)];
15
+ };
16
+ //# sourceMappingURL=set-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.js","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAA;AAE1C,kEAAkE;AAClE,yDAAyD;AACzD,sEAAsE;AACtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,MAAM,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,EAAE;QAAE,OAAM;IACf,MAAM,EAAE,GAAG,cAAc,EAAE,CAAA;IAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAChC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC,CAAA","sourcesContent":["import { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport {urlToPath} from './url-to-path.js'\n\n// set the processInfo.sources for a given file, but don't clobber\n// if called multiple times, or create duplicate entries.\n// Should only be called *after* the file in question has been loaded.\nexport const setSources = (file: string) => {\n const sm = findSourceMapSafe(file)\n if (!sm) return\n const pi = getProcessInfo()\n const s = pi.sources[file] || []\n s.push(...sm.payload.sources.map(s => urlToPath(s)))\n pi.sources[file] = [...new Set(s)]\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const urlToPath: (s: string | URL) => string;
2
+ //# sourceMappingURL=url-to-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.d.ts","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,WACgC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { fileURLToPath } from 'url';
2
+ export const urlToPath = (s) => typeof s === 'object' || s.startsWith('file://') ? fileURLToPath(s) : s;
3
+ //# sourceMappingURL=url-to-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.js","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAe,EAAE,EAAE,CAC3C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { fileURLToPath } from 'url'\n\nexport const urlToPath = (s: string | URL) =>\n typeof s === 'object' || s.startsWith('file://') ? fileURLToPath(s) : s\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapjs/processinfo",
3
- "version": "3.0.2",
3
+ "version": "3.1.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],