@midscene/cli 1.13.1-beta-20260921080849.0 → 1.13.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.
- package/dist/es/framework/index.mjs +31 -26
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +35 -28
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +31 -26
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +35 -28
- package/dist/lib/index.js.map +1 -1
- package/package.json +10 -10
|
@@ -15,6 +15,7 @@ import { stripVTControlCharacters } from "node:util";
|
|
|
15
15
|
import node_process from "node:process";
|
|
16
16
|
import { createRequire } from "node:module";
|
|
17
17
|
import { pathToFileURL } from "node:url";
|
|
18
|
+
import { serializeError } from "@midscene/shared/agent-tools/error-formatter";
|
|
18
19
|
var __webpack_modules__ = {
|
|
19
20
|
"../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
20
21
|
module = __webpack_require__.nmd(module);
|
|
@@ -3965,27 +3966,23 @@ const createYamlProgressReporter = ()=>({
|
|
|
3965
3966
|
}
|
|
3966
3967
|
});
|
|
3967
3968
|
const RSTEST_YAML_CASE_IDS_META_KEY = 'midsceneYamlCaseIds';
|
|
3968
|
-
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
3969
|
+
const formatRunError = (error)=>error.stack || `${error.name || 'Error'}: ${error.message}`;
|
|
3969
3970
|
const collectRunErrors = (result)=>{
|
|
3970
3971
|
const messages = [];
|
|
3971
3972
|
const push = (error, label)=>{
|
|
3972
3973
|
const formatted = formatRunError(error);
|
|
3973
3974
|
messages.push(label ? `${label}: ${formatted}` : formatted);
|
|
3974
3975
|
};
|
|
3975
|
-
for (const file of result.
|
|
3976
|
+
for (const file of result.results){
|
|
3976
3977
|
for (const error of file.errors ?? [])push(error, file.name || file.testPath);
|
|
3977
3978
|
for (const testResult of file.results ?? [])for (const error of testResult.errors ?? [])push(error, testResult.name);
|
|
3978
3979
|
}
|
|
3979
|
-
for (const error of result.unhandledErrors
|
|
3980
|
+
for (const error of result.unhandledErrors)push(error);
|
|
3980
3981
|
return Array.from(new Set(messages));
|
|
3981
3982
|
};
|
|
3982
3983
|
const rstest_runner_errorMessage = (error)=>error.message || error.name || 'YAML case failed';
|
|
3983
3984
|
const mapRunErrorsToCases = (project, result)=>{
|
|
3984
|
-
const
|
|
3985
|
-
item.caseId,
|
|
3986
|
-
item
|
|
3987
|
-
]));
|
|
3988
|
-
const knownCaseIds = new Set(casesById.keys());
|
|
3985
|
+
const knownCaseIds = new Set(project.cases.map((item)=>item.caseId));
|
|
3989
3986
|
const errors = new Map();
|
|
3990
3987
|
const add = (caseId, message)=>{
|
|
3991
3988
|
if (knownCaseIds.has(caseId) && message && !errors.has(caseId)) errors.set(caseId, message);
|
|
@@ -4008,7 +4005,7 @@ const mapRunErrorsToCases = (project, result)=>{
|
|
|
4008
4005
|
const value = testResult.meta?.[RSTEST_YAML_CASE_IDS_META_KEY];
|
|
4009
4006
|
return Array.isArray(value) ? value.filter((item)=>'string' == typeof item) : [];
|
|
4010
4007
|
};
|
|
4011
|
-
for (const file of result.
|
|
4008
|
+
for (const file of result.results){
|
|
4012
4009
|
const moduleCaseIds = findModuleCaseIds(file);
|
|
4013
4010
|
for (const error of file.errors ?? [])addCases(moduleCaseIds, rstest_runner_errorMessage(error));
|
|
4014
4011
|
for (const testResult of file.results ?? []){
|
|
@@ -4016,18 +4013,13 @@ const mapRunErrorsToCases = (project, result)=>{
|
|
|
4016
4013
|
for (const error of testResult.errors ?? [])addCases(caseIds.length ? caseIds : moduleCaseIds, rstest_runner_errorMessage(error));
|
|
4017
4014
|
}
|
|
4018
4015
|
}
|
|
4019
|
-
if (
|
|
4016
|
+
if (result.unhandledErrors.length) {
|
|
4020
4017
|
const message = rstest_runner_errorMessage(result.unhandledErrors[0]);
|
|
4021
|
-
for (const
|
|
4022
|
-
const item = casesById.get(caseId);
|
|
4023
|
-
if (!errors.has(caseId) || item && !existsSync(item.resultFile)) errors.set(caseId, message);
|
|
4024
|
-
}
|
|
4018
|
+
for (const item of project.cases)if (!errors.has(item.caseId) && !existsSync(item.resultFile)) errors.set(item.caseId, message);
|
|
4025
4019
|
}
|
|
4026
4020
|
return errors;
|
|
4027
4021
|
};
|
|
4028
|
-
const
|
|
4029
|
-
if (!project.cases.length) return;
|
|
4030
|
-
const caseErrors = mapRunErrorsToCases(project, result);
|
|
4022
|
+
const writePendingCaseFailures = (project, caseErrors)=>{
|
|
4031
4023
|
for (const item of project.cases){
|
|
4032
4024
|
if (existsSync(item.resultFile)) continue;
|
|
4033
4025
|
const error = caseErrors.get(item.caseId);
|
|
@@ -4049,13 +4041,13 @@ const recordUnreportedCaseFailures = (project, result)=>{
|
|
|
4049
4041
|
}
|
|
4050
4042
|
};
|
|
4051
4043
|
async function runRstestYamlProject(options) {
|
|
4052
|
-
const [{
|
|
4044
|
+
const [{ createRstest }, { rspack }] = await Promise.all([
|
|
4053
4045
|
import("@rstest/core/api"),
|
|
4054
4046
|
import(pathToFileURL(resolvePackageFromRstestCore('@rsbuild/core')).href)
|
|
4055
4047
|
]);
|
|
4056
4048
|
const { project } = options;
|
|
4057
4049
|
const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
|
|
4058
|
-
const
|
|
4050
|
+
const config = {
|
|
4059
4051
|
root: project.projectDir,
|
|
4060
4052
|
include: project.modules.map((item)=>item.id),
|
|
4061
4053
|
testEnvironment: 'node',
|
|
@@ -4086,18 +4078,31 @@ async function runRstestYamlProject(options) {
|
|
|
4086
4078
|
}
|
|
4087
4079
|
}
|
|
4088
4080
|
};
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4081
|
+
let result;
|
|
4082
|
+
try {
|
|
4083
|
+
const rstest = await createRstest({
|
|
4084
|
+
cwd: options.cwd || project.projectDir,
|
|
4085
|
+
config
|
|
4086
|
+
});
|
|
4087
|
+
result = await rstest.run();
|
|
4088
|
+
} catch (error) {
|
|
4089
|
+
const serialized = serializeError(error);
|
|
4090
|
+
writePendingCaseFailures(project, new Map(project.cases.map((item)=>[
|
|
4091
|
+
item.caseId,
|
|
4092
|
+
serialized.message
|
|
4093
|
+
])));
|
|
4094
|
+
if ('pipe' !== options.stdio) console.error(`\nYAML execution failed:\n${formatRunError(serialized)}`);
|
|
4095
|
+
return 1;
|
|
4096
|
+
}
|
|
4097
|
+
const ok = 'pass' === result.status;
|
|
4098
|
+
if (!ok) {
|
|
4099
|
+
writePendingCaseFailures(project, mapRunErrorsToCases(project, result));
|
|
4095
4100
|
if ('pipe' !== options.stdio) {
|
|
4096
4101
|
const runErrors = collectRunErrors(result);
|
|
4097
4102
|
if (runErrors.length) console.error(`\nYAML execution failed:\n${runErrors.join('\n\n')}`);
|
|
4098
4103
|
}
|
|
4099
4104
|
}
|
|
4100
|
-
return
|
|
4105
|
+
return ok ? 0 : 1;
|
|
4101
4106
|
}
|
|
4102
4107
|
const defaultInProcessRunner = (config)=>new BatchRunner(config).run();
|
|
4103
4108
|
async function runConfigInMainProcess(config, commandOptions) {
|