deflake 1.2.6 ā 1.2.8
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/cli.js +43 -19
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -960,6 +960,27 @@ async function analyzeFailures(artifacts, fullLog, client) {
|
|
|
960
960
|
if (results.length > 0 && argv.fix && argv.report) {
|
|
961
961
|
showFrameworkReport();
|
|
962
962
|
}
|
|
963
|
+
|
|
964
|
+
return results.length;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Helper to run a shell command and capture output.
|
|
969
|
+
*/
|
|
970
|
+
async function runCommand(cmd, args) {
|
|
971
|
+
return new Promise((resolve) => {
|
|
972
|
+
console.log(`š Running command: ${cmd} ${args.join(' ')}`);
|
|
973
|
+
const child = spawn(cmd, args, { shell: true, stdio: 'pipe' });
|
|
974
|
+
let stdout = '';
|
|
975
|
+
let stderr = '';
|
|
976
|
+
|
|
977
|
+
child.stdout.on('data', (data) => { process.stdout.write(data); stdout += data.toString(); });
|
|
978
|
+
child.stderr.on('data', (data) => { process.stderr.write(data); stderr += data.toString(); });
|
|
979
|
+
|
|
980
|
+
child.on('close', (code) => {
|
|
981
|
+
resolve({ code, output: stdout + "\n" + stderr });
|
|
982
|
+
});
|
|
983
|
+
});
|
|
963
984
|
}
|
|
964
985
|
|
|
965
986
|
async function main() {
|
|
@@ -976,26 +997,29 @@ async function main() {
|
|
|
976
997
|
if (command.length > 0) {
|
|
977
998
|
const cmd = command[0];
|
|
978
999
|
const args = command.slice(1);
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
process.exit(0);
|
|
1000
|
+
|
|
1001
|
+
let { code, output } = await runCommand(cmd, args);
|
|
1002
|
+
|
|
1003
|
+
if (code !== 0) {
|
|
1004
|
+
console.log(`\nš“ Command failed with code ${code}. Activating DeFlake...`);
|
|
1005
|
+
const artifacts = detectAllArtifacts(null, argv.html);
|
|
1006
|
+
const fixesApplied = await analyzeFailures(artifacts, output, client);
|
|
1007
|
+
|
|
1008
|
+
// AUTO-VERIFICATION
|
|
1009
|
+
if (fixesApplied > 0 && argv.fix) {
|
|
1010
|
+
console.log(`\n${C.BRIGHT}š Fixes applied. Re-running tests to verify...${C.RESET}`);
|
|
1011
|
+
const secondRun = await runCommand(cmd, args);
|
|
1012
|
+
if (secondRun.code === 0) {
|
|
1013
|
+
console.log(`\n${C.GREEN}${C.BRIGHT}ā
All tests passed after DeFlake healing!${C.RESET}`);
|
|
1014
|
+
} else {
|
|
1015
|
+
console.log(`\n${C.YELLOW}ā ļø Some tests still failing after fixes. Check the report for details.${C.RESET}`);
|
|
1016
|
+
}
|
|
997
1017
|
}
|
|
998
|
-
|
|
1018
|
+
process.exit(code);
|
|
1019
|
+
} else {
|
|
1020
|
+
console.log("\nš¢ Command passed successfully.");
|
|
1021
|
+
process.exit(0);
|
|
1022
|
+
}
|
|
999
1023
|
} else {
|
|
1000
1024
|
const artifacts = detectAllArtifacts(argv.log, argv.html);
|
|
1001
1025
|
const fullLog = argv.log && fs.existsSync(argv.log) ? fs.readFileSync(argv.log, 'utf8') : null;
|