From c272420f05383c62545db716399a3d02a3a27f45 Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Sun, 18 Oct 2020 22:16:23 -0400 Subject: [PATCH] Test error checking --- dist/index.js | 25 ++++++++++++++++++++++++- main.js | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3855512..2478fa1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12197,9 +12197,21 @@ try { process.chdir(work_dir); } + let script_errors = []; + + // Test handler stream var test_handler = new stream.Writable({ write: function(chunk, encoding, next) { - console.log("LINE: " + chunk.toString()); + + // Check for script errors + let re = new RegExp("SCRIPT ERROR: ?([^']+)'?:", "i") + var match = re.exec(chunk.toString()); + if (match) { + script_errors.push(match[0]); + } + + // Print to stdout + console.log(chunk.toString()); next(); } }); @@ -12232,6 +12244,17 @@ try { if( data.StatusCode != "0" ) { core.setFailed("GUT tests failed!"); + } else if (script_errors.length > 0) // Check for script errors + { + // Fail action + core.setFailed(script_errors.length.toString() + " script errors were found!"); + + // Log script errors + console.log("The following scripts had script errors:") + script_errors.forEach(error => { + console.log(error) + }); + } }) diff --git a/main.js b/main.js index 6f87776..61949d8 100644 --- a/main.js +++ b/main.js @@ -18,9 +18,21 @@ try { process.chdir(work_dir); } + let script_errors = []; + + // Test handler stream var test_handler = new stream.Writable({ write: function(chunk, encoding, next) { - console.log("LINE: " + chunk.toString()); + + // Check for script errors + let re = new RegExp("SCRIPT ERROR: ?([^']+)'?:", "i") + var match = re.exec(chunk.toString()); + if (match) { + script_errors.push(match[0]); + } + + // Print to stdout + console.log(chunk.toString()); next(); } }); @@ -53,6 +65,17 @@ try { if( data.StatusCode != "0" ) { core.setFailed("GUT tests failed!"); + } else if (script_errors.length > 0) // Check for script errors + { + // Fail action + core.setFailed(script_errors.length.toString() + " script errors were found!"); + + // Log script errors + console.log("The following scripts had script errors:") + script_errors.forEach(error => { + console.log(error) + }); + } })