fix: harden backend stability and test production utilities
This commit is contained in:
@@ -7,6 +7,8 @@ const path = require('path');
|
||||
|
||||
const testFiles = [
|
||||
'boundary-tests.js',
|
||||
'production-utils-tests.js',
|
||||
'archive-tests.js',
|
||||
'network-concurrent-tests.js',
|
||||
'state-consistency-tests.js'
|
||||
];
|
||||
@@ -42,7 +44,9 @@ function runTest(file) {
|
||||
const failMatch = output.match(/失败:\s*(\d+)/);
|
||||
|
||||
const passed = passMatch ? parseInt(passMatch[1]) : 0;
|
||||
const failed = failMatch ? parseInt(failMatch[1]) : 0;
|
||||
const parsedFailed = failMatch ? parseInt(failMatch[1]) : 0;
|
||||
// A syntax error or early crash may not print the normal summary.
|
||||
const failed = code !== 0 && parsedFailed === 0 ? 1 : parsedFailed;
|
||||
|
||||
results.files.push({
|
||||
file,
|
||||
@@ -91,7 +95,8 @@ async function runAllTests() {
|
||||
console.log(`总计: 通过 ${results.total.passed}, 失败 ${results.total.failed}`);
|
||||
console.log('');
|
||||
|
||||
if (results.total.failed > 0) {
|
||||
const hasProcessFailure = results.files.some(file => file.exitCode !== 0);
|
||||
if (results.total.failed > 0 || hasProcessFailure) {
|
||||
console.log('存在失败的测试,请检查输出以了解详情。');
|
||||
process.exit(1);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user