@jsenv/test 3.3.17 → 3.3.19
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.
- package/dist/js/execute_using_dynamic_import.js +2 -2
- package/dist/js/v8_coverage.js +535 -2
- package/dist/jsenv_test.js +47 -69
- package/dist/node_child_process_controlled.mjs +1 -1
- package/dist/node_worker_thread_controlled.mjs +1 -1
- package/package.json +9 -9
- package/src/execution/run.js +1 -2
- package/src/runtime_node/execute_using_dynamic_import.js +1 -2
- package/src/runtime_node/node_child_process_controlled.mjs +1 -2
- package/src/runtime_node/node_worker_thread_controlled.mjs +1 -2
- package/dist/js/exception.js +0 -932
- package/src/execution/exception.js +0 -231
package/dist/jsenv_test.js
CHANGED
|
@@ -3,7 +3,7 @@ import os, { cpus, release, totalmem, availableParallelism, freemem } from "node
|
|
|
3
3
|
import tty from "node:tty";
|
|
4
4
|
import stringWidth from "string-width";
|
|
5
5
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
6
|
-
import { URL_META,
|
|
6
|
+
import { URL_META, filterV8Coverage } from "./js/v8_coverage.js";
|
|
7
7
|
import { readdir, chmod, stat, lstat, chmodSync, statSync, lstatSync, promises, readFile as readFile$1, readFileSync, writeFileSync as writeFileSync$1, mkdirSync, unlink, openSync, closeSync, rmdir, unlinkSync, readdirSync, rmdirSync, existsSync } from "node:fs";
|
|
8
8
|
import { dirname } from "node:path";
|
|
9
9
|
import crypto from "node:crypto";
|
|
@@ -12,7 +12,7 @@ import { takeCoverage } from "node:v8";
|
|
|
12
12
|
import stripAnsi from "strip-ansi";
|
|
13
13
|
import { createRequire } from "node:module";
|
|
14
14
|
import { applyBabelPlugins } from "@jsenv/ast";
|
|
15
|
-
import {
|
|
15
|
+
import { createException } from "@jsenv/exception";
|
|
16
16
|
import { createServer } from "node:net";
|
|
17
17
|
import { spawn, spawnSync, fork } from "node:child_process";
|
|
18
18
|
import { SOURCEMAP, generateSourcemapDataUrl } from "@jsenv/sourcemap";
|
|
@@ -1675,11 +1675,12 @@ const pathnameToExtension = (pathname) => {
|
|
|
1675
1675
|
return extension;
|
|
1676
1676
|
};
|
|
1677
1677
|
|
|
1678
|
-
const
|
|
1678
|
+
const transformUrlPathname = (url, transformer) => {
|
|
1679
1679
|
if (typeof url === "string") {
|
|
1680
1680
|
const urlObject = new URL(url);
|
|
1681
1681
|
const { pathname } = urlObject;
|
|
1682
|
-
|
|
1682
|
+
const pathnameTransformed = transformer(pathname);
|
|
1683
|
+
if (pathnameTransformed === pathname) {
|
|
1683
1684
|
return url;
|
|
1684
1685
|
}
|
|
1685
1686
|
let { origin } = urlObject;
|
|
@@ -1688,15 +1689,18 @@ const ensurePathnameTrailingSlash = (url) => {
|
|
|
1688
1689
|
origin = "file://";
|
|
1689
1690
|
}
|
|
1690
1691
|
const { search, hash } = urlObject;
|
|
1691
|
-
const
|
|
1692
|
-
return
|
|
1693
|
-
}
|
|
1694
|
-
if (url.pathname.endsWith("/")) {
|
|
1695
|
-
return url;
|
|
1692
|
+
const urlWithPathnameTransformed = `${origin}${pathnameTransformed}${search}${hash}`;
|
|
1693
|
+
return urlWithPathnameTransformed;
|
|
1696
1694
|
}
|
|
1697
|
-
url.pathname
|
|
1695
|
+
const pathnameTransformed = transformer(url.pathname);
|
|
1696
|
+
url.pathname = pathnameTransformed;
|
|
1698
1697
|
return url;
|
|
1699
1698
|
};
|
|
1699
|
+
const ensurePathnameTrailingSlash = (url) => {
|
|
1700
|
+
return transformUrlPathname(url, (pathname) => {
|
|
1701
|
+
return pathname.endsWith("/") ? pathname : `${pathname}/`;
|
|
1702
|
+
});
|
|
1703
|
+
};
|
|
1700
1704
|
|
|
1701
1705
|
const isFileSystemPath = (value) => {
|
|
1702
1706
|
if (typeof value !== "string") {
|
|
@@ -2816,7 +2820,6 @@ const writeDirectorySync = (
|
|
|
2816
2820
|
const removeEntrySync = (
|
|
2817
2821
|
source,
|
|
2818
2822
|
{
|
|
2819
|
-
signal = new AbortController().signal,
|
|
2820
2823
|
allowUseless = false,
|
|
2821
2824
|
recursive = false,
|
|
2822
2825
|
maxRetries = 3,
|
|
@@ -2825,51 +2828,36 @@ const removeEntrySync = (
|
|
|
2825
2828
|
} = {},
|
|
2826
2829
|
) => {
|
|
2827
2830
|
const sourceUrl = assertAndNormalizeFileUrl(source);
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
nullIfNotFound: true,
|
|
2836
|
-
followLink: false,
|
|
2837
|
-
});
|
|
2838
|
-
if (!sourceStats) {
|
|
2839
|
-
if (allowUseless) {
|
|
2840
|
-
return;
|
|
2841
|
-
}
|
|
2842
|
-
throw new Error(`nothing to remove at ${urlToFileSystemPath(sourceUrl)}`);
|
|
2831
|
+
const sourceStats = readEntryStatSync(sourceUrl, {
|
|
2832
|
+
nullIfNotFound: true,
|
|
2833
|
+
followLink: false,
|
|
2834
|
+
});
|
|
2835
|
+
if (!sourceStats) {
|
|
2836
|
+
if (allowUseless) {
|
|
2837
|
+
return;
|
|
2843
2838
|
}
|
|
2839
|
+
throw new Error(`nothing to remove at ${urlToFileSystemPath(sourceUrl)}`);
|
|
2840
|
+
}
|
|
2844
2841
|
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
signal: removeOperation.signal,
|
|
2865
|
-
recursive,
|
|
2866
|
-
maxRetries,
|
|
2867
|
-
retryDelay,
|
|
2868
|
-
onlyContent,
|
|
2869
|
-
});
|
|
2870
|
-
}
|
|
2871
|
-
} finally {
|
|
2872
|
-
removeOperation.end();
|
|
2842
|
+
// https://nodejs.org/dist/latest-v13.x/docs/api/fs.html#fs_class_fs_stats
|
|
2843
|
+
// FIFO and socket are ignored, not sure what they are exactly and what to do with them
|
|
2844
|
+
// other libraries ignore them, let's do the same.
|
|
2845
|
+
if (
|
|
2846
|
+
sourceStats.isFile() ||
|
|
2847
|
+
sourceStats.isSymbolicLink() ||
|
|
2848
|
+
sourceStats.isCharacterDevice() ||
|
|
2849
|
+
sourceStats.isBlockDevice()
|
|
2850
|
+
) {
|
|
2851
|
+
removeNonDirectory(
|
|
2852
|
+
sourceUrl.endsWith("/") ? sourceUrl.slice(0, -1) : sourceUrl);
|
|
2853
|
+
} else if (sourceStats.isDirectory()) {
|
|
2854
|
+
const directoryUrl = ensurePathnameTrailingSlash(sourceUrl);
|
|
2855
|
+
removeDirectorySync(directoryUrl, {
|
|
2856
|
+
recursive,
|
|
2857
|
+
maxRetries,
|
|
2858
|
+
retryDelay,
|
|
2859
|
+
onlyContent,
|
|
2860
|
+
});
|
|
2873
2861
|
}
|
|
2874
2862
|
};
|
|
2875
2863
|
|
|
@@ -2904,13 +2892,9 @@ const unlinkSyncNaive = (sourcePath, { handleTemporaryError = null } = {}) => {
|
|
|
2904
2892
|
|
|
2905
2893
|
const removeDirectorySync = (
|
|
2906
2894
|
rootDirectoryUrl,
|
|
2907
|
-
{
|
|
2895
|
+
{ maxRetries, retryDelay, recursive, onlyContent },
|
|
2908
2896
|
) => {
|
|
2909
|
-
const removeDirectoryOperation = Abort.startOperation();
|
|
2910
|
-
removeDirectoryOperation.addAbortSignal(signal);
|
|
2911
|
-
|
|
2912
2897
|
const visit = (sourceUrl) => {
|
|
2913
|
-
removeDirectoryOperation.throwIfAborted();
|
|
2914
2898
|
const sourceStats = readEntryStatSync(sourceUrl, {
|
|
2915
2899
|
nullIfNotFound: true,
|
|
2916
2900
|
followLink: false,
|
|
@@ -2944,7 +2928,6 @@ const removeDirectorySync = (
|
|
|
2944
2928
|
},
|
|
2945
2929
|
}
|
|
2946
2930
|
: {};
|
|
2947
|
-
removeDirectoryOperation.throwIfAborted();
|
|
2948
2931
|
removeDirectorySyncNaive(directoryPath, {
|
|
2949
2932
|
...optionsFromRecursive,
|
|
2950
2933
|
// Workaround for https://github.com/joyent/node/issues/4337
|
|
@@ -2982,7 +2965,6 @@ const removeDirectorySync = (
|
|
|
2982
2965
|
};
|
|
2983
2966
|
|
|
2984
2967
|
const removeDirectoryContent = (directoryUrl) => {
|
|
2985
|
-
removeDirectoryOperation.throwIfAborted();
|
|
2986
2968
|
const entryNames = readdirSync(new URL(directoryUrl));
|
|
2987
2969
|
for (const entryName of entryNames) {
|
|
2988
2970
|
const url = resolveUrl(entryName, directoryUrl);
|
|
@@ -2998,14 +2980,10 @@ const removeDirectorySync = (
|
|
|
2998
2980
|
removeNonDirectory(symbolicLinkUrl);
|
|
2999
2981
|
};
|
|
3000
2982
|
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
visitDirectory(rootDirectoryUrl);
|
|
3006
|
-
}
|
|
3007
|
-
} finally {
|
|
3008
|
-
removeDirectoryOperation.end();
|
|
2983
|
+
if (onlyContent) {
|
|
2984
|
+
removeDirectoryContent(rootDirectoryUrl);
|
|
2985
|
+
} else {
|
|
2986
|
+
visitDirectory(rootDirectoryUrl);
|
|
3009
2987
|
}
|
|
3010
2988
|
};
|
|
3011
2989
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { createException } from "@jsenv/exception";
|
|
1
2
|
import { memoryUsage } from "node:process";
|
|
2
|
-
import { createException } from "./js/exception.js";
|
|
3
3
|
import { executeUsingDynamicImport } from "./js/execute_using_dynamic_import.js";
|
|
4
4
|
import "node:fs";
|
|
5
5
|
import "node:perf_hooks";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createException } from "@jsenv/exception";
|
|
1
2
|
import { memoryUsage } from "node:process";
|
|
2
3
|
import { setFlagsFromString } from "node:v8";
|
|
3
4
|
import { runInNewContext } from "node:vm";
|
|
4
5
|
import { parentPort } from "node:worker_threads";
|
|
5
|
-
import { createException } from "./js/exception.js";
|
|
6
6
|
import { executeUsingDynamicImport } from "./js/execute_using_dynamic_import.js";
|
|
7
7
|
import "node:fs";
|
|
8
8
|
import "node:perf_hooks";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/test",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@c88/v8-coverage": "0.1.1",
|
|
40
40
|
"@jsenv/abort": "4.3.0",
|
|
41
|
-
"@jsenv/ast": "6.2.
|
|
42
|
-
"@jsenv/
|
|
43
|
-
"@jsenv/
|
|
41
|
+
"@jsenv/ast": "6.2.7",
|
|
42
|
+
"@jsenv/exception": "1.0.0",
|
|
43
|
+
"@jsenv/filesystem": "4.9.4",
|
|
44
|
+
"@jsenv/github-check-run": "0.1.26",
|
|
44
45
|
"@jsenv/humanize": "1.2.5",
|
|
45
|
-
"@jsenv/plugin-supervisor": "1.5.
|
|
46
|
-
"@jsenv/sourcemap": "1.2.
|
|
46
|
+
"@jsenv/plugin-supervisor": "1.5.8",
|
|
47
|
+
"@jsenv/sourcemap": "1.2.18",
|
|
47
48
|
"@jsenv/url-meta": "8.4.2",
|
|
48
|
-
"@jsenv/urls": "2.
|
|
49
|
-
"@jsenv/utils": "2.1.
|
|
50
|
-
"errorstacks": "2.4.1",
|
|
49
|
+
"@jsenv/urls": "2.4.0",
|
|
50
|
+
"@jsenv/utils": "2.1.2",
|
|
51
51
|
"he": "1.2.0",
|
|
52
52
|
"istanbul-lib-coverage": "3.2.2",
|
|
53
53
|
"istanbul-lib-instrument": "6.0.3",
|
package/src/execution/run.js
CHANGED
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { Abort, raceCallbacks } from "@jsenv/abort";
|
|
14
|
+
import { createException } from "@jsenv/exception";
|
|
14
15
|
import { ensureParentDirectories } from "@jsenv/filesystem";
|
|
15
16
|
import crypto from "node:crypto";
|
|
16
17
|
|
|
17
|
-
import { createException } from "./exception.js";
|
|
18
|
-
|
|
19
18
|
export const run = async ({
|
|
20
19
|
signal = new AbortController().signal,
|
|
21
20
|
logger,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createException } from "@jsenv/exception";
|
|
1
2
|
import { writeFileSync } from "node:fs";
|
|
2
3
|
import { memoryUsage } from "node:process";
|
|
3
|
-
|
|
4
|
-
import { createException } from "../execution/exception.js";
|
|
5
4
|
import { startObservingPerformances } from "./node_execution_performance.js";
|
|
6
5
|
import { startJsCoverage } from "./profiler_v8_coverage.js";
|
|
7
6
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { createException } from "@jsenv/exception";
|
|
1
2
|
import { memoryUsage } from "node:process";
|
|
2
|
-
|
|
3
|
-
import { createException } from "../execution/exception.js";
|
|
4
3
|
import { executeUsingDynamicImport } from "./execute_using_dynamic_import.js";
|
|
5
4
|
|
|
6
5
|
let memoryHeapUsedAtStart;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { createException } from "@jsenv/exception";
|
|
1
2
|
import { memoryUsage } from "node:process";
|
|
2
3
|
import { setFlagsFromString } from "node:v8";
|
|
3
4
|
import { runInNewContext } from "node:vm";
|
|
4
5
|
import { parentPort } from "node:worker_threads";
|
|
5
|
-
|
|
6
|
-
import { createException } from "../execution/exception.js";
|
|
7
6
|
import { executeUsingDynamicImport } from "./execute_using_dynamic_import.js";
|
|
8
7
|
|
|
9
8
|
setFlagsFromString("--expose_gc");
|