diff --git a/dist/index.js b/dist/index.js index 3d08b25..49e7b2c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10,7 +10,7 @@ const lineReader = __webpack_require__(631); const fs = __webpack_require__(747); try { - const regex = /[\w\d]+_test.go:\d+:/iu; // Extracts file name and line where test failures occurred + const regex = /(\s*[\w\d]+_test.go:\d+:)(.*?)(Test:\s+Test[\w\d]*?%0A)/gu; // Extracts only the failure from the logs (including whitespace) const testResultsPath = core.getInput('test-results'); const customPackageName = core.getInput('package-name'); @@ -58,12 +58,12 @@ try { lr.on('end', function() { for (const [key, value] of Object.entries(obj)) { if (value.includes("FAIL") && value.includes("_test.go")) { - const result = regex.exec(value); - if (result != null) { + var result; + while ((result = regex.exec(value)) !== null) { const parts = result[0].split(":"); - const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0]; + const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0].trimStart(); const lineNumber = parts[1]; - core.info(`::error file=${file},line=${lineNumber}::${value}`); + core.info(`::error file=${file},line=${lineNumber}::${result[0]}`); } } } diff --git a/index.js b/index.js index ada01e4..3b901c5 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ const lineReader = require('line-by-line'); const fs = require('fs'); try { - const regex = /[\w\d]+_test.go:\d+:/iu; // Extracts file name and line where test failures occurred + const regex = /(\s*[\w\d]+_test.go:\d+:)(.*?)(Test:\s+Test[\w\d]*?%0A)/gu; // Extracts only the failure from the logs (including whitespace) const testResultsPath = core.getInput('test-results'); const customPackageName = core.getInput('package-name'); @@ -51,12 +51,12 @@ try { lr.on('end', function() { for (const [key, value] of Object.entries(obj)) { if (value.includes("FAIL") && value.includes("_test.go")) { - const result = regex.exec(value); - if (result != null) { + var result; + while ((result = regex.exec(value)) !== null) { const parts = result[0].split(":"); - const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0]; + const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0].trimStart(); const lineNumber = parts[1]; - core.info(`::error file=${file},line=${lineNumber}::${value}`); + core.info(`::error file=${file},line=${lineNumber}::${result[0]}`); } } }