From 47b8ac2ebb347ff3dc0a208ba66aff97f539f74a Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Thu, 27 Jan 2022 18:29:54 +0000 Subject: [PATCH] Fix so util test on 7zip will log 7zip output on errors --- test/util.test.mjs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/test/util.test.mjs b/test/util.test.mjs index 15520b8..c38478e 100644 --- a/test/util.test.mjs +++ b/test/util.test.mjs @@ -202,7 +202,16 @@ t.describe('#extractFile()', function() { assert.isRejected(fs.stat(util.getPathFromRoot('./testapp/file2.txt'))), ]) - await util.extractFile(util.getPathFromRoot('./testapp/example.7z')) + let log = '' + try { + await util.extractFile(util.getPathFromRoot('./testapp/example.7z'), function(msg) { + log += msg + '\n' + }) + } catch (err) { + console.log(log) + console.log(err) + throw err + } let stats = await Promise.all([ fs.stat(util.getPathFromRoot('./testapp/file1.txt')), @@ -218,7 +227,16 @@ t.describe('#extractFile()', function() { assert.isRejected(fs.stat(util.getPathFromRoot('./testapp/file2.txt'))), ]) - await util.extractFile(util.getPathFromRoot('./testapp/example.tar.gz')) + let log = '' + try { + await util.extractFile(util.getPathFromRoot('./testapp/example.tar.gz'), function(msg) { + log += msg + '\n' + }) + } catch (err) { + console.log(log) + console.log(err) + throw err + } let stats = await Promise.all([ fs.stat(util.getPathFromRoot('./testapp/file1.txt')), @@ -232,7 +250,14 @@ t.describe('#extractFile()', function() { t.test('should stream the process of extracting', async function() { let output = '' - await util.extractFile(util.getPathFromRoot('./testapp/example.tar.gz'), function(msg) { output += msg + '\n' }) + + try { + await util.extractFile(util.getPathFromRoot('./testapp/example.tar.gz'), function(msg) { output += msg + '\n' }) + } catch (err) { + console.log(output) + console.log(err) + throw err + } assert.match(output, /Extracting archive\:.+example.tar.gz/) assert.match(output, /1 file, 123 bytes/)