mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-06 18:37:07 +00:00
test: 💍 修正测试用例中对实际和期望的 diff 的逻辑
This commit is contained in:
parent
a66ec82879
commit
c46af6376f
@ -31,11 +31,9 @@ function defineTest(caseDirName: string) {
|
|||||||
|
|
||||||
runPrettierSync(actualFiles, actualDir);
|
runPrettierSync(actualFiles, actualDir);
|
||||||
|
|
||||||
const diffRes = diffActualAndExpectedSync(caseFullDir);
|
const differences = diffActualAndExpectedSync(caseFullDir);
|
||||||
if (diffRes) {
|
if (differences) {
|
||||||
t.fail(diffRes);
|
t.fail(differences);
|
||||||
} else {
|
|
||||||
t.pass();
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e; // just for debugger
|
throw e; // just for debugger
|
||||||
@ -64,8 +62,11 @@ function runPrettierSync(files: string[], cwd: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function diffActualAndExpectedSync(caseFullDir: string): string {
|
function diffActualAndExpectedSync(caseFullDir: string): string {
|
||||||
const res = ensureShellExec('diff', ['-wur', 'expected', 'actual'], {
|
const res = spawnSync('diff', ['-wur', 'expected', 'actual'], {
|
||||||
cwd: caseFullDir,
|
cwd: caseFullDir,
|
||||||
|
stdio: 'pipe',
|
||||||
|
shell: true,
|
||||||
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|
||||||
return colorizeDiffOutput(res.stdout);
|
return colorizeDiffOutput(res.stdout);
|
||||||
@ -84,7 +85,7 @@ function ensureShellExec(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.status !== 0) {
|
if (res.status !== 0) {
|
||||||
throw new Error(`Shell command "${shellCmd}" failed with status: ${res.status}`);
|
throw new Error(`Shell command "${shellCmd} ${args.slice(0,2).join(' ')}..." failed with status: ${res.status} (Full command: "${shellCmd} ${args.join(' ')}" )`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user