Skip to content

Commit

Permalink
handle gitlab-runner console output
Browse files Browse the repository at this point in the history
  • Loading branch information
Szabo Bogdan committed Dec 3, 2017
1 parent 35fbe36 commit c130822
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 40 deletions.
17 changes: 14 additions & 3 deletions lifecycle/trial/reporters/writer.d
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,26 @@ import trial.terminal;

shared static this()
{
version (windows)
version (Windows)
{
import core.sys.windows.windows;

SetConsoleCP(65001);
SetConsoleOutputCP(65001);
}

defaultWriter = new ColorConsoleWriter;
auto consoleType = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE));

if(consoleType == 2) {
writeln("using the color console.");
defaultWriter = new ColorConsoleWriter;
} else {
writeln("using the standard console.");
defaultWriter = new ConsoleWriter;
}
std.stdio.stdout.flush;
} else {
defaultWriter = new ColorConsoleWriter;
}
}


Expand Down
76 changes: 39 additions & 37 deletions lifecycle/trial/runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -497,55 +497,57 @@ void setupSegmentationHandler(bool testRunner)()

static if( __traits( compiles, backtrace ) )
{
import core.sys.posix.signal; // segv handler
version(Posix) {
import core.sys.posix.signal; // segv handler

static extern (C) void unittestSegvHandler(int signum, siginfo_t* info, void* ptr ) nothrow
{
import core.stdc.stdio;
static extern (C) void unittestSegvHandler(int signum, siginfo_t* info, void* ptr ) nothrow
{
import core.stdc.stdio;

core.stdc.stdio.printf("\n\n");
core.stdc.stdio.printf("\n\n");

static if(testRunner) {
if(signum == SIGSEGV) {
core.stdc.stdio.printf("Got a Segmentation Fault running ");
}
static if(testRunner) {
if(signum == SIGSEGV) {
core.stdc.stdio.printf("Got a Segmentation Fault running ");
}

if(signum == SIGBUS) {
core.stdc.stdio.printf("Got a bus error running ");
}
if(signum == SIGBUS) {
core.stdc.stdio.printf("Got a bus error running ");
}


if(LifeCycleListeners.instance.runningTest != "") {
core.stdc.stdio.printf("%s\n\n", LifeCycleListeners.instance.runningTest.ptr);
if(LifeCycleListeners.instance.runningTest != "") {
core.stdc.stdio.printf("%s\n\n", LifeCycleListeners.instance.runningTest.ptr);
} else {
core.stdc.stdio.printf("some setup step. This is probably a Trial bug. Please create an issue on github.\n\n");
}
} else {
core.stdc.stdio.printf("some setup step. This is probably a Trial bug. Please create an issue on github.\n\n");
}
} else {
if(signum == SIGSEGV) {
core.stdc.stdio.printf("Got a Segmentation Fault! ");
}
if(signum == SIGSEGV) {
core.stdc.stdio.printf("Got a Segmentation Fault! ");
}

if(signum == SIGBUS) {
core.stdc.stdio.printf("Got a bus error! ");
if(signum == SIGBUS) {
core.stdc.stdio.printf("Got a bus error! ");
}

core.stdc.stdio.printf(" This is probably a Trial bug. Please create an issue on github.\n\n");
}

core.stdc.stdio.printf(" This is probably a Trial bug. Please create an issue on github.\n\n");
}
static enum MAXFRAMES = 128;
void*[MAXFRAMES] callstack;
int numframes;

static enum MAXFRAMES = 128;
void*[MAXFRAMES] callstack;
int numframes;
numframes = backtrace( callstack.ptr, MAXFRAMES );
backtrace_symbols_fd( callstack.ptr, numframes, 2);
}

numframes = backtrace( callstack.ptr, MAXFRAMES );
backtrace_symbols_fd( callstack.ptr, numframes, 2);
sigaction_t action = void;
(cast(byte*) &action)[0 .. action.sizeof] = 0;
sigfillset( &action.sa_mask ); // block other signals
action.sa_flags = SA_SIGINFO | SA_RESETHAND;
action.sa_sigaction = &unittestSegvHandler;
sigaction( SIGSEGV, &action, null );
sigaction( SIGBUS, &action, null );
}

sigaction_t action = void;
(cast(byte*) &action)[0 .. action.sizeof] = 0;
sigfillset( &action.sa_mask ); // block other signals
action.sa_flags = SA_SIGINFO | SA_RESETHAND;
action.sa_sigaction = &unittestSegvHandler;
sigaction( SIGSEGV, &action, null );
sigaction( SIGBUS, &action, null );
}
}

0 comments on commit c130822

Please sign in to comment.