From a2374b087b5f42003ec9deffa843b7bed72cb8b5 Mon Sep 17 00:00:00 2001 From: Isaac Lambat Date: Wed, 6 Apr 2022 13:12:21 +0100 Subject: [PATCH] Fixed file path being omitted --- dist/index.js | 350 +++++++++++++++++++++++++------------------------- index.js | 6 +- 2 files changed, 178 insertions(+), 178 deletions(-) diff --git a/dist/index.js b/dist/index.js index d7133ef..3d08b25 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+_test.go:\d+:)/g; // Extracts file name and line where test failures occurred + const regex = /[\w\d]+_test.go:\d+:/iu; // Extracts file name and line where test failures occurred const testResultsPath = core.getInput('test-results'); const customPackageName = core.getInput('package-name'); @@ -61,9 +61,9 @@ try { const result = regex.exec(value); if (result != null) { const parts = result[0].split(":"); - const file = parts[0] + const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0]; const lineNumber = parts[1]; - core.info(`::error file=${file},line=${lineNumber}::${value}`) + core.info(`::error file=${file},line=${lineNumber}::${value}`); } } } @@ -584,178 +584,178 @@ exports.toCommandProperties = toCommandProperties; /***/ 631: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -/* - * Line By Line - * - * A NodeJS module that helps you reading large text files, line by line, - * without buffering the files into memory. - * - * Copyright (c) 2012 Markus von der Wehd - * MIT License, see LICENSE.txt, see http://www.opensource.org/licenses/mit-license.php - */ - -var stream = __webpack_require__(413); -var StringDecoder = __webpack_require__(304).StringDecoder; -var path = __webpack_require__(622); -var fs = __webpack_require__(747); -var events = __webpack_require__(614); - -// let's make sure we have a setImmediate function (node.js <0.10) -if (typeof global.setImmediate == 'undefined') { setImmediate = process.nextTick;} - -var LineByLineReader = function (filepath, options) { - var self = this; - - this._encoding = options && options.encoding || 'utf8'; - if (filepath instanceof stream.Readable) { - this._readStream = filepath; - } - else { - this._readStream = null; - this._filepath = path.normalize(filepath); - this._streamOptions = { encoding: this._encoding }; - - if (options && options.start) { - this._streamOptions.start = options.start; - } - - if (options && options.end) { - this._streamOptions.end = options.end; - } - } - this._skipEmptyLines = options && options.skipEmptyLines || false; - - this._lines = []; - this._lineFragment = ''; - this._paused = false; - this._end = false; - this._ended = false; - this.decoder = new StringDecoder(this._encoding); - - events.EventEmitter.call(this); - - setImmediate(function () { - self._initStream(); - }); -}; - -LineByLineReader.prototype = Object.create(events.EventEmitter.prototype, { - constructor: { - value: LineByLineReader, - enumerable: false - } -}); - -LineByLineReader.prototype._initStream = function () { - var self = this, - readStream = this._readStream ? this._readStream : - fs.createReadStream(this._filepath, this._streamOptions); - - readStream.on('error', function (err) { - self.emit('error', err); - }); - - readStream.on('open', function () { - self.emit('open'); - }); - - readStream.on('data', function (data) { - self._readStream.pause(); - var dataAsString = data; - if (data instanceof Buffer) { - dataAsString = self.decoder.write(data); - } - self._lines = self._lines.concat(dataAsString.split(/(?:\n|\r\n|\r)/g)); - - self._lines[0] = self._lineFragment + self._lines[0]; - self._lineFragment = self._lines.pop() || ''; - - setImmediate(function () { - self._nextLine(); - }); - }); - - readStream.on('end', function () { - self._end = true; - - setImmediate(function () { - self._nextLine(); - }); - }); - - this._readStream = readStream; -}; - -LineByLineReader.prototype._nextLine = function () { - var self = this, - line; - - if (this._paused) { - return; - } - - if (this._lines.length === 0) { - if (this._end) { - if (this._lineFragment) { - this.emit('line', this._lineFragment); - this._lineFragment = ''; - } - if (!this._paused) { - this.end(); - } - } else { - this._readStream.resume(); - } - return; - } - - line = this._lines.shift(); - - if (!this._skipEmptyLines || line.length > 0) { - this.emit('line', line); - } - - setImmediate(function () { - if (!this._paused) { - self._nextLine(); - } - }); -}; - -LineByLineReader.prototype.pause = function () { - this._paused = true; -}; - -LineByLineReader.prototype.resume = function () { - var self = this; - - this._paused = false; - - setImmediate(function () { - self._nextLine(); - }); -}; - -LineByLineReader.prototype.end = function () { - if (!this._ended){ - this._ended = true; - this.emit('end'); - } -}; - -LineByLineReader.prototype.close = function () { - var self = this; - - this._readStream.destroy(); - this._end = true; - this._lines = []; - - setImmediate(function () { - self._nextLine(); - }); -}; - -module.exports = LineByLineReader; +/* + * Line By Line + * + * A NodeJS module that helps you reading large text files, line by line, + * without buffering the files into memory. + * + * Copyright (c) 2012 Markus von der Wehd + * MIT License, see LICENSE.txt, see http://www.opensource.org/licenses/mit-license.php + */ + +var stream = __webpack_require__(413); +var StringDecoder = __webpack_require__(304).StringDecoder; +var path = __webpack_require__(622); +var fs = __webpack_require__(747); +var events = __webpack_require__(614); + +// let's make sure we have a setImmediate function (node.js <0.10) +if (typeof global.setImmediate == 'undefined') { setImmediate = process.nextTick;} + +var LineByLineReader = function (filepath, options) { + var self = this; + + this._encoding = options && options.encoding || 'utf8'; + if (filepath instanceof stream.Readable) { + this._readStream = filepath; + } + else { + this._readStream = null; + this._filepath = path.normalize(filepath); + this._streamOptions = { encoding: this._encoding }; + + if (options && options.start) { + this._streamOptions.start = options.start; + } + + if (options && options.end) { + this._streamOptions.end = options.end; + } + } + this._skipEmptyLines = options && options.skipEmptyLines || false; + + this._lines = []; + this._lineFragment = ''; + this._paused = false; + this._end = false; + this._ended = false; + this.decoder = new StringDecoder(this._encoding); + + events.EventEmitter.call(this); + + setImmediate(function () { + self._initStream(); + }); +}; + +LineByLineReader.prototype = Object.create(events.EventEmitter.prototype, { + constructor: { + value: LineByLineReader, + enumerable: false + } +}); + +LineByLineReader.prototype._initStream = function () { + var self = this, + readStream = this._readStream ? this._readStream : + fs.createReadStream(this._filepath, this._streamOptions); + + readStream.on('error', function (err) { + self.emit('error', err); + }); + + readStream.on('open', function () { + self.emit('open'); + }); + + readStream.on('data', function (data) { + self._readStream.pause(); + var dataAsString = data; + if (data instanceof Buffer) { + dataAsString = self.decoder.write(data); + } + self._lines = self._lines.concat(dataAsString.split(/(?:\n|\r\n|\r)/g)); + + self._lines[0] = self._lineFragment + self._lines[0]; + self._lineFragment = self._lines.pop() || ''; + + setImmediate(function () { + self._nextLine(); + }); + }); + + readStream.on('end', function () { + self._end = true; + + setImmediate(function () { + self._nextLine(); + }); + }); + + this._readStream = readStream; +}; + +LineByLineReader.prototype._nextLine = function () { + var self = this, + line; + + if (this._paused) { + return; + } + + if (this._lines.length === 0) { + if (this._end) { + if (this._lineFragment) { + this.emit('line', this._lineFragment); + this._lineFragment = ''; + } + if (!this._paused) { + this.end(); + } + } else { + this._readStream.resume(); + } + return; + } + + line = this._lines.shift(); + + if (!this._skipEmptyLines || line.length > 0) { + this.emit('line', line); + } + + setImmediate(function () { + if (!this._paused) { + self._nextLine(); + } + }); +}; + +LineByLineReader.prototype.pause = function () { + this._paused = true; +}; + +LineByLineReader.prototype.resume = function () { + var self = this; + + this._paused = false; + + setImmediate(function () { + self._nextLine(); + }); +}; + +LineByLineReader.prototype.end = function () { + if (!this._ended){ + this._ended = true; + this.emit('end'); + } +}; + +LineByLineReader.prototype.close = function () { + var self = this; + + this._readStream.destroy(); + this._end = true; + this._lines = []; + + setImmediate(function () { + self._nextLine(); + }); +}; + +module.exports = LineByLineReader; /***/ }), diff --git a/index.js b/index.js index d4239e9..ada01e4 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+_test.go:\d+:)/g; // Extracts file name and line where test failures occurred + const regex = /[\w\d]+_test.go:\d+:/iu; // Extracts file name and line where test failures occurred const testResultsPath = core.getInput('test-results'); const customPackageName = core.getInput('package-name'); @@ -54,9 +54,9 @@ try { const result = regex.exec(value); if (result != null) { const parts = result[0].split(":"); - const file = parts[0] + const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0]; const lineNumber = parts[1]; - core.info(`::error file=${file},line=${lineNumber}::${value}`) + core.info(`::error file=${file},line=${lineNumber}::${value}`); } } }