From 6463dfc94b62dd35f867a6f93d058af13db1f391 Mon Sep 17 00:00:00 2001 From: Hajer Dahmani Date: Sun, 21 Jul 2024 00:08:14 +0100 Subject: [PATCH 1/2] updated the code to handle null output, Fixes #879, signed-off-by: Hajer Dahmani hdahmani@andrew.cmu.edu Signed-off-by: Hajer Dahmani --- TestResultSummaryService/parsers/Test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/TestResultSummaryService/parsers/Test.js b/TestResultSummaryService/parsers/Test.js index 291a74b0..43cbe394 100644 --- a/TestResultSummaryService/parsers/Test.js +++ b/TestResultSummaryService/parsers/Test.js @@ -22,6 +22,20 @@ class Test extends Parser { } async parse(output) { + if (!output) { + return { + tests: [ + { + testName: 'Pre Test', + testOutput: '', + testResult: 'FAILED', + testData: null + } + ], + type: 'Test' + }; + } + const tests = await this.extract(output); const { javaVersion, jdkDate, sdkResource } = this.exactJavaVersion(output); From 8dcd0a5ed4ef6f22c0812d52a71de96f92cb8ea7 Mon Sep 17 00:00:00 2001 From: Hajer Dahmani Date: Mon, 22 Jul 2024 13:57:44 +0100 Subject: [PATCH 2/2] handled null output and made constants for common strings in the code, Fixes #894, signed-off-by: Hajer Dahmani hdahmani@andrew.cmu.edu Signed-off-by: Hajer Dahmani --- TestResultSummaryService/parsers/Test.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/TestResultSummaryService/parsers/Test.js b/TestResultSummaryService/parsers/Test.js index 43cbe394..b0b6d420 100644 --- a/TestResultSummaryService/parsers/Test.js +++ b/TestResultSummaryService/parsers/Test.js @@ -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`); @@ -26,9 +30,9 @@ class Test extends Parser { return { tests: [ { - testName: 'Pre Test', + testName: preTest, testOutput: '', - testResult: 'FAILED', + testResult: testFailed, testData: null } ], @@ -53,8 +57,6 @@ class Test extends Parser { } async extract(str) { - const preTest = 'Pre Test'; - const postTest = 'Post Test'; let m, testStr, testName, @@ -89,7 +91,7 @@ class Test extends Parser { results.push({ testName: preTest, testOutput: nonTestStr, - testResult: 'PASSED', + testResult: testPassed, testData: null, }); nonTestStr = ''; @@ -141,7 +143,7 @@ class Test extends Parser { results.push({ testName, testOutput: testStr, - testResult: 'FAILED', + testResult: testFailed, testData: null, startTime, }); @@ -150,7 +152,7 @@ class Test extends Parser { results.push({ testName: preTest, testOutput: str, - testResult: 'FAILED', + testResult: testFailed, testData: null, }); } else if (!postTestDone) { @@ -160,8 +162,8 @@ class Test extends Parser { testResult: nonTestStr.match( /Finished: (SUCCESS|UNSTABLE|ABORTED)/ ) - ? 'PASSED' - : 'FAILED', + ? testPassed + : testFailed, testData: null, }); }