Skip to content

Commit 9bc372f

Browse files
committed
Improve regex in TRSS to handle long CSV output
Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>
1 parent 10f7312 commit 9bc372f

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

TestResultSummaryService/DataManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class DataManager {
2222
}
2323

2424
async parseOutput(buildName, output) {
25+
logger.verbose('parseOutput');
2526
const parserTypes = await Promise.all(
2627
Object.keys(Parsers).map(async (type) => {
2728
if (Parsers[type].canParse(buildName, output)) {
@@ -37,6 +38,7 @@ class DataManager {
3738
const parser = new DefaultParser();
3839
results = await parser.parse(output);
3940
}
41+
logger.verbose('parseOutput done');
4042
return Object.assign.apply({}, results);
4143
}
4244

@@ -219,7 +221,8 @@ class DataManager {
219221
update.buildOutputId = buildOutputId;
220222
update.hasChildren = false;
221223
}
222-
const result = await testResults.update(criteria, { $set: update });
224+
await testResults.update(criteria, { $set: update });
225+
logger.verbose('updateBuildWithOutput done');
223226
}
224227

225228
// create build only if the build does not exist in database

TestResultSummaryService/JenkinsInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class JenkinsInfo {
6969
});
7070
const size = await logStream.getSize();
7171
logger.debug(
72-
'JenkinsInfo: getBuildOutput() is waiting for 5 secs after getSize()'
72+
'JenkinsInfo: getBuildOutput() is waiting for 1 secs after getSize()'
7373
);
7474
await Promise.delay(1 * 1000);
7575

TestResultSummaryService/parsers/Parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Parser {
1414
/=JAVA VERSION OUTPUT BEGIN=[\r\n]+([\s\S]*?)[\r\n]+.*=JAVA VERSION OUTPUT END=/;
1515
const javaBuildDateRegex =
1616
/\s([0-9]{4})-?(0[1-9]|1[012])-?(0[1-9]|[12][0-9]|3[01])/;
17-
const sdkResourceRegex = /.*?SDK_RESOURCE\=(.*)[\r\n]+/;
17+
const sdkResourceRegex = /SDK_RESOURCE\=(.*)[\r\n]+/;
1818
let curRegexResult = null;
1919
let javaVersion, jdkDate, sdkResource;
2020
if ((curRegexResult = javaVersionRegex.exec(output)) !== null) {
@@ -142,7 +142,7 @@ class Parser {
142142
let disabled = 0;
143143
// An example of test result summary: "TOTAL: 69 EXECUTED: 64 PASSED: 64 FAILED: 0 DISABLED: 0 SKIPPED: 5\n"
144144
const summaryRegex =
145-
/\S*\s*?TOTAL:\s*([0-9]*)\s*EXECUTED:\s*([0-9]*)\s*PASSED:\s*([0-9]*)\s*FAILED:\s*([0-9]*)\s*DISABLED:\s*([0-9]*)\s*SKIPPED:\s*([0-9]*)\s*(\r\n|\r|\n)/;
145+
/TOTAL:\s*([0-9]*)\s*EXECUTED:\s*([0-9]*)\s*PASSED:\s*([0-9]*)\s*FAILED:\s*([0-9]*)\s*DISABLED:\s*([0-9]*)\s*SKIPPED:\s*([0-9]*)\s*(\r\n|\r|\n)/;
146146
if ((m = summaryRegex.exec(output)) !== null) {
147147
total = parseInt(m[1], 10);
148148
executed = parseInt(m[2], 10);

TestResultSummaryService/parsers/Test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const Parser = require('./Parser');
2-
const regexRunningTest = /.*?Running test (.*?) \.\.\.\r?/;
3-
const testSeparator = /.*?===============================================\r?/;
4-
const regexFinishTime = /(.*?) Finish Time\: .* Epoch Time \(ms\)\: (\d+).*/;
5-
const regexStartTime = /(.*?) Start Time\: .* Epoch Time \(ms\)\: (\d+).*/;
2+
const regexRunningTest = /Running test (.*?) \.\.\.\r?/;
3+
const testSeparator = /===============================================\r?/;
4+
const regexFinishTime = /^(.*?) Finish Time\: .* Epoch Time \(ms\)\: (\d+).*/;
5+
const regexStartTime = /^(.*?) Start Time\: .* Epoch Time \(ms\)\: (\d+).*/;
66
const TestBenchmarkParser = require(`./TestBenchmarkParser`);
77
const ExternalTestParser = require(`./ExternalTestParser`);
88

0 commit comments

Comments
 (0)