deflake 1.0.5 → 1.0.7
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 +14 -9
- package/client.js +4 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -272,7 +272,8 @@ function extractFailureLocation(logText) {
|
|
|
272
272
|
stepLine: null
|
|
273
273
|
};
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
// Updated regex to be more flexible with arrows and spaces
|
|
276
|
+
const testMatch = logText.match(/^\s*\d+\)\s+\[.*?\]\s+.+?\s+(.*?.spec.ts):(\d+):(\d+)/m);
|
|
276
277
|
if (testMatch) {
|
|
277
278
|
loc.specFile = testMatch[1];
|
|
278
279
|
loc.testLine = testMatch[2];
|
|
@@ -657,11 +658,6 @@ async function analyzeFailures(artifacts, fullLog, client) {
|
|
|
657
658
|
process.stdout.write(`\r⏳ Analyzing ${art.name}... `);
|
|
658
659
|
const result = await runHealer(specificLog, art.htmlPath, argv.apiUrl, art.name);
|
|
659
660
|
|
|
660
|
-
if (result && result.status === 'error' && result.detail === 'QUOTA_EXCEEDED') {
|
|
661
|
-
console.log(`\n${C.RED}🛑 Quota exceeded! Stopping.${C.RESET}`);
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
661
|
if (result && result.status === 'success') {
|
|
666
662
|
results.push(result);
|
|
667
663
|
|
|
@@ -669,15 +665,18 @@ async function analyzeFailures(artifacts, fullLog, client) {
|
|
|
669
665
|
if (argv.fix) {
|
|
670
666
|
await applySelfHealing(result);
|
|
671
667
|
}
|
|
668
|
+
} else {
|
|
669
|
+
console.log(`\n ${C.RED}❌ Analysis failed for ${art.name}:${C.RESET} ${result?.detail || 'Check server status'}`);
|
|
672
670
|
}
|
|
673
671
|
}
|
|
674
|
-
|
|
672
|
+
process.stdout.write("\r✅ Analysis complete. \n");
|
|
675
673
|
|
|
676
674
|
// GROUPING & PRINTING
|
|
677
675
|
const groups = {};
|
|
678
676
|
for (const res of results) {
|
|
679
|
-
|
|
680
|
-
const
|
|
677
|
+
// Use a unique key for grouping. If location is missing, use testName to ensure it shows up.
|
|
678
|
+
const locId = res.location ? `${res.location.rootFile}:${res.location.rootLine}` : `unknown-${res.testName}`;
|
|
679
|
+
const key = `${locId}|${JSON.stringify(res.fix)}`;
|
|
681
680
|
if (!groups[key]) {
|
|
682
681
|
groups[key] = { location: res.location, sourceCode: res.sourceCode, fix: res.fix, tests: [] };
|
|
683
682
|
}
|
|
@@ -693,6 +692,12 @@ async function analyzeFailures(artifacts, fullLog, client) {
|
|
|
693
692
|
for (const key of sortedKeys) {
|
|
694
693
|
printDetailedFix(groups[key].fix, groups[key].location, groups[key].sourceCode);
|
|
695
694
|
}
|
|
695
|
+
|
|
696
|
+
if (results.length > 0 && sortedKeys.length === 0) {
|
|
697
|
+
console.log(`${C.YELLOW}⚠️ Note: Some suggestions were found but could not be grouped for display.${C.RESET}`);
|
|
698
|
+
} else if (results.length === 0) {
|
|
699
|
+
console.log(`${C.GRAY}ℹ️ DeFlake analyzed the logs but couldn't find a confident fix for these errors.${C.RESET}`);
|
|
700
|
+
}
|
|
696
701
|
}
|
|
697
702
|
|
|
698
703
|
async function main() {
|
package/client.js
CHANGED
|
@@ -69,10 +69,10 @@ class DeFlakeClient {
|
|
|
69
69
|
const htmlContent = fs.readFileSync(htmlPath, 'utf8');
|
|
70
70
|
|
|
71
71
|
const payload = {
|
|
72
|
-
error_log: logContent,
|
|
73
|
-
html_snapshot: htmlContent,
|
|
74
|
-
failing_line: failureLocation ? `Line ${failureLocation.rootLine}` :
|
|
75
|
-
source_code: sourceCode
|
|
72
|
+
error_log: logContent || "",
|
|
73
|
+
html_snapshot: htmlContent || "",
|
|
74
|
+
failing_line: failureLocation ? `Line ${failureLocation.rootLine}` : "",
|
|
75
|
+
source_code: sourceCode || ""
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
const response = await axios.post(this.apiUrl, payload, {
|