@jsenv/test 3.1.0 → 3.2.0
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/exception.js +3 -0
- package/dist/jsenv_test.js +109 -33
- package/package.json +1 -1
- package/src/execution/exception.js +3 -0
- package/src/execution/execute_test_plan.js +37 -32
- package/src/main.js +4 -0
- package/src/runtime_inline/runtime_inline.js +72 -0
package/dist/js/exception.js
CHANGED
|
@@ -809,6 +809,9 @@ const createException = (reason, { rootDirectoryUrl } = {}) => {
|
|
|
809
809
|
|
|
810
810
|
const stackFramesNonNative = [];
|
|
811
811
|
for (const stackFrame of stackFrames) {
|
|
812
|
+
if (!stackFrame.url) {
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
812
815
|
if (stackFrame.url.startsWith("node:")) {
|
|
813
816
|
stackFrame.native = "node";
|
|
814
817
|
continue;
|
package/dist/jsenv_test.js
CHANGED
|
@@ -6133,6 +6133,7 @@ To fix this warning:
|
|
|
6133
6133
|
runtime,
|
|
6134
6134
|
runtimeParams,
|
|
6135
6135
|
allocatedMs = defaultMsAllocatedPerExecution,
|
|
6136
|
+
uses,
|
|
6136
6137
|
} = stepConfig;
|
|
6137
6138
|
const params = {
|
|
6138
6139
|
measureMemoryUsage: true,
|
|
@@ -6140,6 +6141,7 @@ To fix this warning:
|
|
|
6140
6141
|
collectPerformance: false,
|
|
6141
6142
|
collectConsole: true,
|
|
6142
6143
|
allocatedMs,
|
|
6144
|
+
uses,
|
|
6143
6145
|
runtime,
|
|
6144
6146
|
runtimeParams: {
|
|
6145
6147
|
rootDirectoryUrl,
|
|
@@ -6169,6 +6171,7 @@ To fix this warning:
|
|
|
6169
6171
|
}
|
|
6170
6172
|
|
|
6171
6173
|
const execution = {
|
|
6174
|
+
name: `${relativeUrl}/${groupName}`,
|
|
6172
6175
|
counters,
|
|
6173
6176
|
countersInOrder,
|
|
6174
6177
|
index,
|
|
@@ -6321,7 +6324,13 @@ To fix this warning:
|
|
|
6321
6324
|
|
|
6322
6325
|
const executionRemainingSet = new Set(executionPlanifiedSet);
|
|
6323
6326
|
const executionExecutingSet = new Set();
|
|
6327
|
+
const usedTagSet = new Set();
|
|
6324
6328
|
const start = async (execution) => {
|
|
6329
|
+
if (execution.params.uses) {
|
|
6330
|
+
for (const tagThatWillBeUsed of execution.params.uses) {
|
|
6331
|
+
usedTagSet.add(tagThatWillBeUsed);
|
|
6332
|
+
}
|
|
6333
|
+
}
|
|
6325
6334
|
execution.fileExecutionCount = Object.keys(
|
|
6326
6335
|
testPlanResult.results[execution.fileRelativeUrl],
|
|
6327
6336
|
).length;
|
|
@@ -6341,7 +6350,6 @@ To fix this warning:
|
|
|
6341
6350
|
afterEachCallbackSet.add(callback);
|
|
6342
6351
|
}
|
|
6343
6352
|
}
|
|
6344
|
-
|
|
6345
6353
|
for (const beforeEachInOrderCallback of beforeEachInOrderCallbackSet) {
|
|
6346
6354
|
const returnValue = beforeEachInOrderCallback(
|
|
6347
6355
|
execution,
|
|
@@ -6374,7 +6382,6 @@ To fix this warning:
|
|
|
6374
6382
|
process.exitCode = 1;
|
|
6375
6383
|
}
|
|
6376
6384
|
}
|
|
6377
|
-
|
|
6378
6385
|
for (const afterEachCallback of afterEachCallbackSet) {
|
|
6379
6386
|
afterEachCallback(execution, testPlanResult);
|
|
6380
6387
|
}
|
|
@@ -6384,7 +6391,11 @@ To fix this warning:
|
|
|
6384
6391
|
afterEachInOrderCallback(execution, testPlanResult);
|
|
6385
6392
|
}
|
|
6386
6393
|
});
|
|
6387
|
-
|
|
6394
|
+
if (execution.params.uses) {
|
|
6395
|
+
for (const tagNoLongerInUse of execution.params.uses) {
|
|
6396
|
+
usedTagSet.delete(tagNoLongerInUse);
|
|
6397
|
+
}
|
|
6398
|
+
}
|
|
6388
6399
|
if (testPlanResult.failed && failFast && counters.remaining) {
|
|
6389
6400
|
logger.info(`"failFast" enabled -> cancel remaining executions`);
|
|
6390
6401
|
failFastAbortController.abort();
|
|
@@ -6392,23 +6403,16 @@ To fix this warning:
|
|
|
6392
6403
|
}
|
|
6393
6404
|
};
|
|
6394
6405
|
const startAsMuchAsPossible = async () => {
|
|
6406
|
+
operation.throwIfAborted();
|
|
6395
6407
|
const promises = [];
|
|
6396
|
-
|
|
6397
|
-
while (true) {
|
|
6398
|
-
operation.throwIfAborted();
|
|
6399
|
-
if (executionRemainingSet.size === 0) {
|
|
6400
|
-
break;
|
|
6401
|
-
}
|
|
6408
|
+
for (const executionCandidate of executionRemainingSet) {
|
|
6402
6409
|
if (executionExecutingSet.size >= parallel.max) {
|
|
6403
6410
|
break;
|
|
6404
6411
|
}
|
|
6405
|
-
|
|
6406
|
-
if (
|
|
6412
|
+
if (executionExecutingSet.size > 0) {
|
|
6407
6413
|
// starting execution in parallel is limited by
|
|
6408
6414
|
// cpu and memory only when trying to parallelize
|
|
6409
6415
|
// if nothing is executing these limitations don't apply
|
|
6410
|
-
executionExecutingSet.size > 0
|
|
6411
|
-
) {
|
|
6412
6416
|
if (processMemoryUsageMonitoring.measure() > parallel.maxMemory) {
|
|
6413
6417
|
// retry after Xms in case memory usage decreases
|
|
6414
6418
|
const promise = (async () => {
|
|
@@ -6418,7 +6422,6 @@ To fix this warning:
|
|
|
6418
6422
|
promises.push(promise);
|
|
6419
6423
|
break;
|
|
6420
6424
|
}
|
|
6421
|
-
|
|
6422
6425
|
if (processCpuUsageMonitoring.measure() > parallel.maxCpu) {
|
|
6423
6426
|
// retry after Xms in case cpu usage decreases
|
|
6424
6427
|
const promise = (async () => {
|
|
@@ -6428,27 +6431,29 @@ To fix this warning:
|
|
|
6428
6431
|
promises.push(promise);
|
|
6429
6432
|
break;
|
|
6430
6433
|
}
|
|
6434
|
+
if (executionCandidate.params.uses) {
|
|
6435
|
+
const nonAvailableTag = executionCandidate.params.uses.find(
|
|
6436
|
+
(tagToUse) => usedTagSet.has(tagToUse),
|
|
6437
|
+
);
|
|
6438
|
+
if (nonAvailableTag) {
|
|
6439
|
+
logger.debug(
|
|
6440
|
+
`"${nonAvailableTag}" is not available, ${executionCandidate.name} will wait until it is released by a previous execution`,
|
|
6441
|
+
);
|
|
6442
|
+
continue;
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6431
6445
|
}
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
execution = executionCandidate;
|
|
6438
|
-
break;
|
|
6439
|
-
}
|
|
6440
|
-
if (execution) {
|
|
6441
|
-
const promise = (async () => {
|
|
6442
|
-
await start(execution);
|
|
6443
|
-
await startAsMuchAsPossible();
|
|
6444
|
-
})();
|
|
6445
|
-
promises.push(promise);
|
|
6446
|
-
}
|
|
6446
|
+
const promise = (async () => {
|
|
6447
|
+
await start(executionCandidate);
|
|
6448
|
+
await startAsMuchAsPossible();
|
|
6449
|
+
})();
|
|
6450
|
+
promises.push(promise);
|
|
6447
6451
|
}
|
|
6448
|
-
if (promises.length) {
|
|
6449
|
-
|
|
6450
|
-
promises.length = 0;
|
|
6452
|
+
if (promises.length === 0) {
|
|
6453
|
+
return;
|
|
6451
6454
|
}
|
|
6455
|
+
await Promise.all(promises);
|
|
6456
|
+
promises.length = 0;
|
|
6452
6457
|
};
|
|
6453
6458
|
|
|
6454
6459
|
reporters = reporters.flat(Infinity);
|
|
@@ -9186,4 +9191,75 @@ const execute = async ({
|
|
|
9186
9191
|
}
|
|
9187
9192
|
};
|
|
9188
9193
|
|
|
9189
|
-
|
|
9194
|
+
const inlineRuntime = (fn) => {
|
|
9195
|
+
return {
|
|
9196
|
+
type: "inline",
|
|
9197
|
+
name: "inline",
|
|
9198
|
+
version: "1",
|
|
9199
|
+
run: async ({
|
|
9200
|
+
signal = new AbortController().signal,
|
|
9201
|
+
onRuntimeStarted,
|
|
9202
|
+
onRuntimeStopped,
|
|
9203
|
+
}) => {
|
|
9204
|
+
const actionOperation = Abort.startOperation();
|
|
9205
|
+
actionOperation.addAbortSignal(signal);
|
|
9206
|
+
const result = {
|
|
9207
|
+
status: "executing",
|
|
9208
|
+
errors: [],
|
|
9209
|
+
namespace: null,
|
|
9210
|
+
timings: {},
|
|
9211
|
+
memoryUsage: null,
|
|
9212
|
+
performance: null,
|
|
9213
|
+
};
|
|
9214
|
+
try {
|
|
9215
|
+
let executionInternalErrorCallback;
|
|
9216
|
+
let executionCompletedCallback;
|
|
9217
|
+
const winnerPromise = new Promise((resolve) => {
|
|
9218
|
+
raceCallbacks(
|
|
9219
|
+
{
|
|
9220
|
+
aborted: (cb) => {
|
|
9221
|
+
return actionOperation.addAbortCallback(cb);
|
|
9222
|
+
},
|
|
9223
|
+
execution_internal_error: (cb) => {
|
|
9224
|
+
executionInternalErrorCallback = cb;
|
|
9225
|
+
},
|
|
9226
|
+
execution_completed: (cb) => {
|
|
9227
|
+
executionCompletedCallback = cb;
|
|
9228
|
+
},
|
|
9229
|
+
},
|
|
9230
|
+
resolve,
|
|
9231
|
+
);
|
|
9232
|
+
});
|
|
9233
|
+
try {
|
|
9234
|
+
onRuntimeStarted();
|
|
9235
|
+
const value = await fn();
|
|
9236
|
+
executionCompletedCallback(value);
|
|
9237
|
+
} catch (e) {
|
|
9238
|
+
executionInternalErrorCallback(e);
|
|
9239
|
+
}
|
|
9240
|
+
const raceHandlers = {
|
|
9241
|
+
aborted: () => {
|
|
9242
|
+
result.status = "aborted";
|
|
9243
|
+
},
|
|
9244
|
+
execution_internal_error: (e) => {
|
|
9245
|
+
result.status = "failed";
|
|
9246
|
+
result.errors.push(e);
|
|
9247
|
+
},
|
|
9248
|
+
execution_completed: (value) => {
|
|
9249
|
+
result.status = "completed";
|
|
9250
|
+
result.errors = [];
|
|
9251
|
+
result.namespace = value;
|
|
9252
|
+
},
|
|
9253
|
+
};
|
|
9254
|
+
const winner = await winnerPromise;
|
|
9255
|
+
raceHandlers[winner.name](winner.data);
|
|
9256
|
+
} finally {
|
|
9257
|
+
onRuntimeStopped();
|
|
9258
|
+
await actionOperation.end();
|
|
9259
|
+
return result;
|
|
9260
|
+
}
|
|
9261
|
+
},
|
|
9262
|
+
};
|
|
9263
|
+
};
|
|
9264
|
+
|
|
9265
|
+
export { chromium, chromiumIsolatedTab, execute, executeTestPlan, firefox, firefoxIsolatedTab, inlineRuntime, nodeChildProcess, nodeWorkerThread, reportAsJunitXml, reportCoverageAsHtml, reportCoverageAsJson, reportCoverageInConsole, reporterList, webkit, webkitIsolatedTab };
|
package/package.json
CHANGED
|
@@ -110,6 +110,9 @@ export const createException = (reason, { rootDirectoryUrl } = {}) => {
|
|
|
110
110
|
|
|
111
111
|
const stackFramesNonNative = [];
|
|
112
112
|
for (const stackFrame of stackFrames) {
|
|
113
|
+
if (!stackFrame.url) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
113
116
|
if (stackFrame.url.startsWith("node:")) {
|
|
114
117
|
stackFrame.native = "node";
|
|
115
118
|
continue;
|
|
@@ -619,6 +619,7 @@ To fix this warning:
|
|
|
619
619
|
runtime,
|
|
620
620
|
runtimeParams,
|
|
621
621
|
allocatedMs = defaultMsAllocatedPerExecution,
|
|
622
|
+
uses,
|
|
622
623
|
} = stepConfig;
|
|
623
624
|
const params = {
|
|
624
625
|
measureMemoryUsage: true,
|
|
@@ -626,6 +627,7 @@ To fix this warning:
|
|
|
626
627
|
collectPerformance: false,
|
|
627
628
|
collectConsole: true,
|
|
628
629
|
allocatedMs,
|
|
630
|
+
uses,
|
|
629
631
|
runtime,
|
|
630
632
|
runtimeParams: {
|
|
631
633
|
rootDirectoryUrl,
|
|
@@ -655,6 +657,7 @@ To fix this warning:
|
|
|
655
657
|
}
|
|
656
658
|
|
|
657
659
|
const execution = {
|
|
660
|
+
name: `${relativeUrl}/${groupName}`,
|
|
658
661
|
counters,
|
|
659
662
|
countersInOrder,
|
|
660
663
|
index,
|
|
@@ -807,7 +810,13 @@ To fix this warning:
|
|
|
807
810
|
|
|
808
811
|
const executionRemainingSet = new Set(executionPlanifiedSet);
|
|
809
812
|
const executionExecutingSet = new Set();
|
|
813
|
+
const usedTagSet = new Set();
|
|
810
814
|
const start = async (execution) => {
|
|
815
|
+
if (execution.params.uses) {
|
|
816
|
+
for (const tagThatWillBeUsed of execution.params.uses) {
|
|
817
|
+
usedTagSet.add(tagThatWillBeUsed);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
811
820
|
execution.fileExecutionCount = Object.keys(
|
|
812
821
|
testPlanResult.results[execution.fileRelativeUrl],
|
|
813
822
|
).length;
|
|
@@ -827,7 +836,6 @@ To fix this warning:
|
|
|
827
836
|
afterEachCallbackSet.add(callback);
|
|
828
837
|
}
|
|
829
838
|
}
|
|
830
|
-
|
|
831
839
|
for (const beforeEachInOrderCallback of beforeEachInOrderCallbackSet) {
|
|
832
840
|
const returnValue = beforeEachInOrderCallback(
|
|
833
841
|
execution,
|
|
@@ -860,7 +868,6 @@ To fix this warning:
|
|
|
860
868
|
process.exitCode = 1;
|
|
861
869
|
}
|
|
862
870
|
}
|
|
863
|
-
|
|
864
871
|
for (const afterEachCallback of afterEachCallbackSet) {
|
|
865
872
|
afterEachCallback(execution, testPlanResult);
|
|
866
873
|
}
|
|
@@ -870,7 +877,11 @@ To fix this warning:
|
|
|
870
877
|
afterEachInOrderCallback(execution, testPlanResult);
|
|
871
878
|
}
|
|
872
879
|
});
|
|
873
|
-
|
|
880
|
+
if (execution.params.uses) {
|
|
881
|
+
for (const tagNoLongerInUse of execution.params.uses) {
|
|
882
|
+
usedTagSet.delete(tagNoLongerInUse);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
874
885
|
if (testPlanResult.failed && failFast && counters.remaining) {
|
|
875
886
|
logger.info(`"failFast" enabled -> cancel remaining executions`);
|
|
876
887
|
failFastAbortController.abort();
|
|
@@ -878,23 +889,16 @@ To fix this warning:
|
|
|
878
889
|
}
|
|
879
890
|
};
|
|
880
891
|
const startAsMuchAsPossible = async () => {
|
|
892
|
+
operation.throwIfAborted();
|
|
881
893
|
const promises = [];
|
|
882
|
-
|
|
883
|
-
while (true) {
|
|
884
|
-
operation.throwIfAborted();
|
|
885
|
-
if (executionRemainingSet.size === 0) {
|
|
886
|
-
break;
|
|
887
|
-
}
|
|
894
|
+
for (const executionCandidate of executionRemainingSet) {
|
|
888
895
|
if (executionExecutingSet.size >= parallel.max) {
|
|
889
896
|
break;
|
|
890
897
|
}
|
|
891
|
-
|
|
892
|
-
if (
|
|
898
|
+
if (executionExecutingSet.size > 0) {
|
|
893
899
|
// starting execution in parallel is limited by
|
|
894
900
|
// cpu and memory only when trying to parallelize
|
|
895
901
|
// if nothing is executing these limitations don't apply
|
|
896
|
-
executionExecutingSet.size > 0
|
|
897
|
-
) {
|
|
898
902
|
if (processMemoryUsageMonitoring.measure() > parallel.maxMemory) {
|
|
899
903
|
// retry after Xms in case memory usage decreases
|
|
900
904
|
const promise = (async () => {
|
|
@@ -904,7 +908,6 @@ To fix this warning:
|
|
|
904
908
|
promises.push(promise);
|
|
905
909
|
break;
|
|
906
910
|
}
|
|
907
|
-
|
|
908
911
|
if (processCpuUsageMonitoring.measure() > parallel.maxCpu) {
|
|
909
912
|
// retry after Xms in case cpu usage decreases
|
|
910
913
|
const promise = (async () => {
|
|
@@ -914,27 +917,29 @@ To fix this warning:
|
|
|
914
917
|
promises.push(promise);
|
|
915
918
|
break;
|
|
916
919
|
}
|
|
920
|
+
if (executionCandidate.params.uses) {
|
|
921
|
+
const nonAvailableTag = executionCandidate.params.uses.find(
|
|
922
|
+
(tagToUse) => usedTagSet.has(tagToUse),
|
|
923
|
+
);
|
|
924
|
+
if (nonAvailableTag) {
|
|
925
|
+
logger.debug(
|
|
926
|
+
`"${nonAvailableTag}" is not available, ${executionCandidate.name} will wait until it is released by a previous execution`,
|
|
927
|
+
);
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
917
931
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
execution = executionCandidate;
|
|
924
|
-
break;
|
|
925
|
-
}
|
|
926
|
-
if (execution) {
|
|
927
|
-
const promise = (async () => {
|
|
928
|
-
await start(execution);
|
|
929
|
-
await startAsMuchAsPossible();
|
|
930
|
-
})();
|
|
931
|
-
promises.push(promise);
|
|
932
|
-
}
|
|
932
|
+
const promise = (async () => {
|
|
933
|
+
await start(executionCandidate);
|
|
934
|
+
await startAsMuchAsPossible();
|
|
935
|
+
})();
|
|
936
|
+
promises.push(promise);
|
|
933
937
|
}
|
|
934
|
-
if (promises.length) {
|
|
935
|
-
|
|
936
|
-
promises.length = 0;
|
|
938
|
+
if (promises.length === 0) {
|
|
939
|
+
return;
|
|
937
940
|
}
|
|
941
|
+
await Promise.all(promises);
|
|
942
|
+
promises.length = 0;
|
|
938
943
|
};
|
|
939
944
|
|
|
940
945
|
reporters = reporters.flat(Infinity);
|
package/src/main.js
CHANGED
|
@@ -16,3 +16,7 @@ export { reporterList } from "./execution/reporters/reporter_list.js";
|
|
|
16
16
|
export { reportAsJunitXml } from "./execution/junit_xml_file/report_as_junit_xml.js";
|
|
17
17
|
// advanced
|
|
18
18
|
export { execute } from "./execution/execute.js";
|
|
19
|
+
|
|
20
|
+
// internals
|
|
21
|
+
// help for internal self unit test
|
|
22
|
+
export { inlineRuntime } from "./runtime_inline/runtime_inline.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Abort, raceCallbacks } from "@jsenv/abort";
|
|
2
|
+
|
|
3
|
+
export const inlineRuntime = (fn) => {
|
|
4
|
+
return {
|
|
5
|
+
type: "inline",
|
|
6
|
+
name: "inline",
|
|
7
|
+
version: "1",
|
|
8
|
+
run: async ({
|
|
9
|
+
signal = new AbortController().signal,
|
|
10
|
+
onRuntimeStarted,
|
|
11
|
+
onRuntimeStopped,
|
|
12
|
+
}) => {
|
|
13
|
+
const actionOperation = Abort.startOperation();
|
|
14
|
+
actionOperation.addAbortSignal(signal);
|
|
15
|
+
const result = {
|
|
16
|
+
status: "executing",
|
|
17
|
+
errors: [],
|
|
18
|
+
namespace: null,
|
|
19
|
+
timings: {},
|
|
20
|
+
memoryUsage: null,
|
|
21
|
+
performance: null,
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
let executionInternalErrorCallback;
|
|
25
|
+
let executionCompletedCallback;
|
|
26
|
+
const winnerPromise = new Promise((resolve) => {
|
|
27
|
+
raceCallbacks(
|
|
28
|
+
{
|
|
29
|
+
aborted: (cb) => {
|
|
30
|
+
return actionOperation.addAbortCallback(cb);
|
|
31
|
+
},
|
|
32
|
+
execution_internal_error: (cb) => {
|
|
33
|
+
executionInternalErrorCallback = cb;
|
|
34
|
+
},
|
|
35
|
+
execution_completed: (cb) => {
|
|
36
|
+
executionCompletedCallback = cb;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
resolve,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
onRuntimeStarted();
|
|
44
|
+
const value = await fn();
|
|
45
|
+
executionCompletedCallback(value);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
executionInternalErrorCallback(e);
|
|
48
|
+
}
|
|
49
|
+
const raceHandlers = {
|
|
50
|
+
aborted: () => {
|
|
51
|
+
result.status = "aborted";
|
|
52
|
+
},
|
|
53
|
+
execution_internal_error: (e) => {
|
|
54
|
+
result.status = "failed";
|
|
55
|
+
result.errors.push(e);
|
|
56
|
+
},
|
|
57
|
+
execution_completed: (value) => {
|
|
58
|
+
result.status = "completed";
|
|
59
|
+
result.errors = [];
|
|
60
|
+
result.namespace = value;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const winner = await winnerPromise;
|
|
64
|
+
raceHandlers[winner.name](winner.data);
|
|
65
|
+
} finally {
|
|
66
|
+
onRuntimeStopped();
|
|
67
|
+
await actionOperation.end();
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
};
|