diff --git a/lifecycle/trial/reporters/writer.d b/lifecycle/trial/reporters/writer.d index 3c40020..141abcd 100644 --- a/lifecycle/trial/reporters/writer.d +++ b/lifecycle/trial/reporters/writer.d @@ -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; + } } diff --git a/lifecycle/trial/runner.d b/lifecycle/trial/runner.d index 5605770..b9b523b 100644 --- a/lifecycle/trial/runner.d +++ b/lifecycle/trial/runner.d @@ -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 ); } } \ No newline at end of file