From 4adb0569acf3076dfc985ffac11b131376e85714 Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Sun, 24 Feb 2019 16:42:29 +0100 Subject: [PATCH] Display Authelia server logs when tests fail. --- scripts/authelia-scripts-serve | 5 +++++ scripts/authelia-scripts-test | 7 +++++++ test/helpers/context/WithAutheliaRunning.ts | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/authelia-scripts-serve b/scripts/authelia-scripts-serve index de3795a0f..dbfaf18f7 100755 --- a/scripts/authelia-scripts-serve +++ b/scripts/authelia-scripts-serve @@ -42,3 +42,8 @@ server.stderr.on('data', (data) => { process.stderr.write(`${data}`); }); server.stderr.pipe(logStream); + + +server.on('exit', function(statusCode) { + process.exit(statusCode); +}) \ No newline at end of file diff --git a/scripts/authelia-scripts-test b/scripts/authelia-scripts-test index 67571b5a2..1df64e9a5 100755 --- a/scripts/authelia-scripts-test +++ b/scripts/authelia-scripts-test @@ -54,6 +54,13 @@ mocha.stderr.on('data', (data) => { mocha.on('exit', function(statusCode) { if (statusCode != 0) { console.error("The tests failed... Mocha exited with status code " + statusCode); + fs.readFile('/tmp/authelia-server.log', function(err, data) { + if (err) { + console.error(err); + return; + } + console.log(data.toString('utf-8')); + }); } process.exit(statusCode); }) diff --git a/test/helpers/context/WithAutheliaRunning.ts b/test/helpers/context/WithAutheliaRunning.ts index 9250be5c3..0edd14898 100644 --- a/test/helpers/context/WithAutheliaRunning.ts +++ b/test/helpers/context/WithAutheliaRunning.ts @@ -1,5 +1,6 @@ import ChildProcess from 'child_process'; +import fs from 'fs'; export default function WithAutheliaRunning(configPath: string, waitTimeout: number = 5000) { before(function() { @@ -11,8 +12,17 @@ export default function WithAutheliaRunning(configPath: string, waitTimeout: num ['serve', '--no-watch', '--config', configPath], {detached: true}); - authelia.on('exit', function(status) { - console.log('Server terminated with status ' + status); + authelia.on('exit', function(statusCode) { + console.log('Server terminated with status ' + statusCode); + if (statusCode != 0) { + fs.readFile('/tmp/authelia-server.log', function(err, data) { + if (err) { + console.error(err); + return; + } + console.log(data.toString('utf-8')); + }) + } }); this.authelia = authelia;