Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated the code to handle null outpuT #894

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions TestResultSummaryService/parsers/Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const regexFinishTime = /(.*?) Finish Time\: .* Epoch Time \(ms\)\: (\d+).*/;
const regexStartTime = /(.*?) Start Time\: .* Epoch Time \(ms\)\: (\d+).*/;
const TestBenchmarkParser = require(`./TestBenchmarkParser`);
const ExternalTestParser = require(`./ExternalTestParser`);
const preTest = 'Pre Test';
const postTest = 'Post Test';
const testPassed = 'PASSED';
const testFailed = 'FAILED';

const Utils = require(`./Utils`);

Expand All @@ -22,6 +26,20 @@ class Test extends Parser {
}

async parse(output) {
if (!output) {
return {
tests: [
{
testName: preTest,
testOutput: '',
testResult: testFailed,
testData: null
}
],
type: 'Test'
};
}

const tests = await this.extract(output);
const { javaVersion, jdkDate, sdkResource } =
this.exactJavaVersion(output);
Expand All @@ -39,8 +57,6 @@ class Test extends Parser {
}

async extract(str) {
const preTest = 'Pre Test';
const postTest = 'Post Test';
let m,
testStr,
testName,
Expand Down Expand Up @@ -75,7 +91,7 @@ class Test extends Parser {
results.push({
testName: preTest,
testOutput: nonTestStr,
testResult: 'PASSED',
testResult: testPassed,
testData: null,
});
nonTestStr = '';
Expand Down Expand Up @@ -127,7 +143,7 @@ class Test extends Parser {
results.push({
testName,
testOutput: testStr,
testResult: 'FAILED',
testResult: testFailed,
testData: null,
startTime,
});
Expand All @@ -136,7 +152,7 @@ class Test extends Parser {
results.push({
testName: preTest,
testOutput: str,
testResult: 'FAILED',
testResult: testFailed,
testData: null,
});
} else if (!postTestDone) {
Expand All @@ -146,8 +162,8 @@ class Test extends Parser {
testResult: nonTestStr.match(
/Finished: (SUCCESS|UNSTABLE|ABORTED)/
)
? 'PASSED'
: 'FAILED',
? testPassed
: testFailed,
testData: null,
});
}
Expand Down
Loading