Skip to content

Commit 8fed843

Browse files
authored
Merge pull request #263 from veghdev/integration_failed
Integration test log failed tests separately
2 parents c58e72a + 154f7a4 commit 8fed843

File tree

4 files changed

+65
-14
lines changed

4 files changed

+65
-14
lines changed

test/integration/modules/integration-test/test-case/test-case-result.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const path = require("path");
55
const fs = require("fs");
66

77
const TestEnv = require("../../../modules/integration-test/test-env.js");
8-
const VizzuUrl = require("../../../modules/vizzu/vizzu-url.js");
98

109
class TestCaseResult {
1110
#cnsl;
@@ -181,7 +180,7 @@ class TestCaseResult {
181180
this.#testCaseObj.testSuiteResults.WARNING.push(
182181
this.#testCaseObj.testCase.testName
183182
);
184-
this.#testCaseObj.testSuiteResults.MANUAL.push(this.#testCaseObj.testCase);
183+
this.#createTestCaseResultManual();
185184
this.#cnsl.log(
186185
(
187186
"[ " +
@@ -216,9 +215,7 @@ class TestCaseResult {
216215
this.#testCaseObj.testSuiteResults.FAILED.push(
217216
this.#testCaseObj.testCase.testName
218217
);
219-
this.#testCaseObj.testSuiteResults.MANUAL.push(
220-
this.#testCaseObj.testCase
221-
);
218+
this.#createTestCaseResultManual();
222219
this.#createTestCaseResultErrorMsg();
223220
if (failureMsgs) {
224221
failureMsgs.forEach(failureMsg => {
@@ -231,7 +228,7 @@ class TestCaseResult {
231228
this.#testCaseObj.testSuiteResults.FAILED.push(
232229
this.#testCaseObj.testCase.testName
233230
);
234-
this.#testCaseObj.testSuiteResults.MANUAL.push(this.#testCaseObj.testCase);
231+
this.#createTestCaseResultManual();
235232
this.#createTestCaseResultErrorMsg();
236233
}
237234

@@ -274,6 +271,16 @@ class TestCaseResult {
274271
}
275272
}
276273

274+
#createTestCaseResultManual() {
275+
this.#testCaseObj.testSuiteResults.MANUAL.push(this.#testCaseObj.testCase);
276+
let formatted = path.relative(
277+
TestEnv.getTestSuitePath(),
278+
path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase.testName)
279+
);
280+
this.#testCaseObj.testSuiteResults.MANUAL_FORMATTED.push(formatted);
281+
this.#cnsl.writeFailure(" " + formatted);
282+
}
283+
277284
#deleteTestCaseResult() {
278285
return new Promise((resolve, reject) => {
279286
let testCaseResultPath = path.join(

test/integration/modules/integration-test/test-console.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
const path = require("path");
2+
const fs = require("fs");
23

34
const TestEnv = require("../../modules/integration-test/test-env.js");
45
const Console = require("../../modules/console/console.js");
56

67
class TestConsole extends Console {
78
#testSuiteLogPath;
9+
#testSuiteFailuresPath;
10+
#testSuiteFailuresPathReady;
811

912
#testStatusPad = 8;
1013
#testNumberPad = 0;
@@ -17,9 +20,15 @@ class TestConsole extends Console {
1720
TestEnv.getTestSuiteReportPath(),
1821
pathPrefix
1922
);
23+
var testSuiteFailuresPath = path.join(
24+
TestEnv.getTestSuiteReportPath(),
25+
"failures.log"
26+
);
2027
}
2128
super(filePrefix, testSuiteLogPath);
2229
this.#testSuiteLogPath = testSuiteLogPath;
30+
this.#testSuiteFailuresPath = testSuiteFailuresPath;
31+
this.#testSuiteFailuresPathReady = this.#createFailuresLog();
2332
}
2433

2534
getTestSuiteLogPath() {
@@ -49,6 +58,47 @@ class TestConsole extends Console {
4958
}
5059
this.#testNumberPad = testNumberPad;
5160
}
61+
62+
#createFailuresLog() {
63+
return new Promise((resolve, reject) => {
64+
if (this.#testSuiteFailuresPath) {
65+
fs.mkdir(path.dirname(this.#testSuiteFailuresPath), { recursive: true }, (err) => {
66+
if (err) {
67+
console.error('Failed to create directory:', err);
68+
reject(err);
69+
} else {
70+
fs.writeFile(this.#testSuiteFailuresPath, '', { flag: 'w' }, (err) => {
71+
if (err) {
72+
console.error('Failed to write file:', err);
73+
reject(err);
74+
} else {
75+
resolve();
76+
}
77+
});
78+
}
79+
});
80+
} else {
81+
resolve();
82+
}
83+
});
84+
}
85+
86+
writeFailure(line) {
87+
if (this.#testSuiteFailuresPath) {
88+
this.#testSuiteFailuresPathReady.then(() => {
89+
return new Promise((resolve, reject) => {
90+
fs.writeFile(this.#testSuiteFailuresPath, line, { flag: 'a' }, (err) => {
91+
if (err) {
92+
console.error('Failed to write file:', err);
93+
reject(err);
94+
} else {
95+
resolve();
96+
}
97+
});
98+
});
99+
});
100+
}
101+
}
52102
}
53103

54104
module.exports = TestConsole;

test/integration/modules/integration-test/test-suite-result.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ class TestSuiteResult {
2929
createTestSuiteResult() {
3030
this.#createNewConfig();
3131
if (this.#testSuiteResults.MANUAL.length != 0) {
32-
const manualTestCases = [];
3332
this.#cnsl.log("\n");
3433
this.#testSuiteResults.MANUAL.forEach((testCase) => {
35-
manualTestCases.push(
36-
path.relative(
37-
TestEnv.getTestSuitePath(),
38-
path.join(TestEnv.getWorkspacePath(), testCase.testName)
39-
)
40-
);
4134
this.#cnsl.log(
4235
"".padEnd(this.#cnsl.getTestStatusPad() + 5, " ") +
4336
path.relative(
@@ -61,7 +54,7 @@ class TestSuiteResult {
6154
"".padEnd(this.#cnsl.getTestStatusPad() + 5, " ") +
6255
"node man.js" +
6356
" " +
64-
manualTestCases.map((s) => `'${s}'`).join(" ")
57+
this.#testSuiteResults.MANUAL_FORMATTED.map((s) => `'${s}'`).join(" ")
6558
);
6659
}
6760
this.#testSuiteResults.TIME.END = Math.round(Date.now() / 1000);

test/integration/modules/integration-test/test-suite.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class TestSuite {
4646
TIME: { START: Math.round(Date.now() / 1000), END: 0 },
4747
FINISHED: 0,
4848
MANUAL: [],
49+
MANUAL_FORMATTED: [],
4950
RESULTS: {},
5051
};
5152

0 commit comments

Comments
 (0)