Display Authelia server logs when tests fail.

pull/330/head
Clement Michaud 2019-02-24 16:42:29 +01:00
parent c258c25a38
commit 4adb0569ac
3 changed files with 24 additions and 2 deletions

View File

@ -42,3 +42,8 @@ server.stderr.on('data', (data) => {
process.stderr.write(`${data}`); process.stderr.write(`${data}`);
}); });
server.stderr.pipe(logStream); server.stderr.pipe(logStream);
server.on('exit', function(statusCode) {
process.exit(statusCode);
})

View File

@ -54,6 +54,13 @@ mocha.stderr.on('data', (data) => {
mocha.on('exit', function(statusCode) { mocha.on('exit', function(statusCode) {
if (statusCode != 0) { if (statusCode != 0) {
console.error("The tests failed... Mocha exited with status code " + statusCode); 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); process.exit(statusCode);
}) })

View File

@ -1,5 +1,6 @@
import ChildProcess from 'child_process'; import ChildProcess from 'child_process';
import fs from 'fs';
export default function WithAutheliaRunning(configPath: string, waitTimeout: number = 5000) { export default function WithAutheliaRunning(configPath: string, waitTimeout: number = 5000) {
before(function() { before(function() {
@ -11,8 +12,17 @@ export default function WithAutheliaRunning(configPath: string, waitTimeout: num
['serve', '--no-watch', '--config', configPath], ['serve', '--no-watch', '--config', configPath],
{detached: true}); {detached: true});
authelia.on('exit', function(status) { authelia.on('exit', function(statusCode) {
console.log('Server terminated with status ' + status); 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; this.authelia = authelia;