Skip to content

Commit

Permalink
Only fail text is printed, and multiple asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacLambat committed Apr 6, 2022
1 parent a2374b0 commit 710f4c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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]}`);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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]}`);
}
}
}
Expand Down

0 comments on commit 710f4c9

Please sign in to comment.