|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __create = Object.create; |
|
f7eb47b…
|
lmata
|
3 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
5 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
6 |
var __getProtoOf = Object.getPrototypeOf; |
|
f7eb47b…
|
lmata
|
7 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
8 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
9 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
10 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
11 |
}; |
|
f7eb47b…
|
lmata
|
12 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
13 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
14 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
15 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
16 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
17 |
} |
|
f7eb47b…
|
lmata
|
18 |
return to; |
|
f7eb47b…
|
lmata
|
19 |
}; |
|
f7eb47b…
|
lmata
|
20 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
f7eb47b…
|
lmata
|
21 |
// If the importer is in node compatibility mode or this is not an ESM |
|
f7eb47b…
|
lmata
|
22 |
// file that has been converted to a CommonJS file using a Babel- |
|
f7eb47b…
|
lmata
|
23 |
// compatible transform (i.e. "__esModule" has not been set), then set |
|
f7eb47b…
|
lmata
|
24 |
// "default" to the CommonJS "module.exports" for node compatibility. |
|
f7eb47b…
|
lmata
|
25 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
f7eb47b…
|
lmata
|
26 |
mod |
|
f7eb47b…
|
lmata
|
27 |
)); |
|
f7eb47b…
|
lmata
|
28 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
29 |
var testLoader_exports = {}; |
|
f7eb47b…
|
lmata
|
30 |
__export(testLoader_exports, { |
|
f7eb47b…
|
lmata
|
31 |
defaultTimeout: () => defaultTimeout, |
|
f7eb47b…
|
lmata
|
32 |
loadTestFile: () => loadTestFile |
|
f7eb47b…
|
lmata
|
33 |
}); |
|
f7eb47b…
|
lmata
|
34 |
module.exports = __toCommonJS(testLoader_exports); |
|
f7eb47b…
|
lmata
|
35 |
var import_path = __toESM(require("path")); |
|
f7eb47b…
|
lmata
|
36 |
var import_util = __toESM(require("util")); |
|
f7eb47b…
|
lmata
|
37 |
var esmLoaderHost = __toESM(require("./esmLoaderHost")); |
|
f7eb47b…
|
lmata
|
38 |
var import_globals = require("./globals"); |
|
f7eb47b…
|
lmata
|
39 |
var import_test = require("./test"); |
|
f7eb47b…
|
lmata
|
40 |
var import_compilationCache = require("../transform/compilationCache"); |
|
f7eb47b…
|
lmata
|
41 |
var import_transform = require("../transform/transform"); |
|
f7eb47b…
|
lmata
|
42 |
var import_util2 = require("../util"); |
|
f7eb47b…
|
lmata
|
43 |
const defaultTimeout = 3e4; |
|
f7eb47b…
|
lmata
|
44 |
const cachedFileSuites = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
45 |
async function loadTestFile(file, config, testErrors) { |
|
f7eb47b…
|
lmata
|
46 |
if (cachedFileSuites.has(file)) |
|
f7eb47b…
|
lmata
|
47 |
return cachedFileSuites.get(file); |
|
f7eb47b…
|
lmata
|
48 |
const suite = new import_test.Suite(import_path.default.relative(config.config.rootDir, file) || import_path.default.basename(file), "file"); |
|
f7eb47b…
|
lmata
|
49 |
suite._requireFile = file; |
|
f7eb47b…
|
lmata
|
50 |
suite.location = { file, line: 0, column: 0 }; |
|
f7eb47b…
|
lmata
|
51 |
suite._tags = [...config.config.tags]; |
|
f7eb47b…
|
lmata
|
52 |
(0, import_globals.setCurrentlyLoadingFileSuite)(suite); |
|
f7eb47b…
|
lmata
|
53 |
if (!(0, import_globals.isWorkerProcess)()) { |
|
f7eb47b…
|
lmata
|
54 |
(0, import_compilationCache.startCollectingFileDeps)(); |
|
f7eb47b…
|
lmata
|
55 |
await esmLoaderHost.startCollectingFileDeps(); |
|
f7eb47b…
|
lmata
|
56 |
} |
|
f7eb47b…
|
lmata
|
57 |
try { |
|
f7eb47b…
|
lmata
|
58 |
await (0, import_transform.requireOrImport)(file); |
|
f7eb47b…
|
lmata
|
59 |
cachedFileSuites.set(file, suite); |
|
f7eb47b…
|
lmata
|
60 |
} catch (e) { |
|
f7eb47b…
|
lmata
|
61 |
if (!testErrors) |
|
f7eb47b…
|
lmata
|
62 |
throw e; |
|
f7eb47b…
|
lmata
|
63 |
testErrors.push(serializeLoadError(file, e)); |
|
f7eb47b…
|
lmata
|
64 |
} finally { |
|
f7eb47b…
|
lmata
|
65 |
(0, import_globals.setCurrentlyLoadingFileSuite)(void 0); |
|
f7eb47b…
|
lmata
|
66 |
if (!(0, import_globals.isWorkerProcess)()) { |
|
f7eb47b…
|
lmata
|
67 |
(0, import_compilationCache.stopCollectingFileDeps)(file); |
|
f7eb47b…
|
lmata
|
68 |
await esmLoaderHost.stopCollectingFileDeps(file); |
|
f7eb47b…
|
lmata
|
69 |
} |
|
f7eb47b…
|
lmata
|
70 |
} |
|
f7eb47b…
|
lmata
|
71 |
{ |
|
f7eb47b…
|
lmata
|
72 |
const files = /* @__PURE__ */ new Set(); |
|
f7eb47b…
|
lmata
|
73 |
suite.allTests().map((t) => files.add(t.location.file)); |
|
f7eb47b…
|
lmata
|
74 |
if (files.size === 1) { |
|
f7eb47b…
|
lmata
|
75 |
const mappedFile = files.values().next().value; |
|
f7eb47b…
|
lmata
|
76 |
if (suite.location.file !== mappedFile) { |
|
f7eb47b…
|
lmata
|
77 |
if (import_path.default.extname(mappedFile) !== import_path.default.extname(suite.location.file)) |
|
f7eb47b…
|
lmata
|
78 |
suite.location.file = mappedFile; |
|
f7eb47b…
|
lmata
|
79 |
} |
|
f7eb47b…
|
lmata
|
80 |
} |
|
f7eb47b…
|
lmata
|
81 |
} |
|
f7eb47b…
|
lmata
|
82 |
return suite; |
|
f7eb47b…
|
lmata
|
83 |
} |
|
f7eb47b…
|
lmata
|
84 |
function serializeLoadError(file, error) { |
|
f7eb47b…
|
lmata
|
85 |
if (error instanceof Error) { |
|
f7eb47b…
|
lmata
|
86 |
const result = (0, import_util2.filterStackTrace)(error); |
|
f7eb47b…
|
lmata
|
87 |
const loc = error.loc; |
|
f7eb47b…
|
lmata
|
88 |
result.location = loc ? { |
|
f7eb47b…
|
lmata
|
89 |
file, |
|
f7eb47b…
|
lmata
|
90 |
line: loc.line || 0, |
|
f7eb47b…
|
lmata
|
91 |
column: loc.column || 0 |
|
f7eb47b…
|
lmata
|
92 |
} : void 0; |
|
f7eb47b…
|
lmata
|
93 |
return result; |
|
f7eb47b…
|
lmata
|
94 |
} |
|
f7eb47b…
|
lmata
|
95 |
return { value: import_util.default.inspect(error) }; |
|
f7eb47b…
|
lmata
|
96 |
} |
|
f7eb47b…
|
lmata
|
97 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
98 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
99 |
defaultTimeout, |
|
f7eb47b…
|
lmata
|
100 |
loadTestFile |
|
f7eb47b…
|
lmata
|
101 |
}); |