Skip to content

Commit

Permalink
add se handler to the main runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Szabo committed Sep 26, 2017
1 parent b4f37ab commit 6cb7171
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
36 changes: 23 additions & 13 deletions lifecycle/trial/runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ unittest {

/// Runs the tests and returns the results
auto runTests(const(TestCase)[] tests, string testName = "") {
setupSegmentationHandler();
setupSegmentationHandler!true();

const(TestCase)[] filteredTests = tests;

Expand Down Expand Up @@ -427,10 +427,9 @@ unittest {
LifeCycleListeners.instance.runningTest.should.equal("trial.runner.It should return the name of this test");
}

void setupSegmentationHandler()
void setupSegmentationHandler(bool testRunner)()
{
import core.runtime;
writeln("SETUP Seg handler");

// backtrace
version( CRuntime_Glibc )
Expand All @@ -456,21 +455,32 @@ void setupSegmentationHandler()

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

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");
}
if(signum == SIGSEGV) {
core.stdc.stdio.printf("Got a Segmentation Fault! ");
}

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");
}

static enum MAXFRAMES = 128;
void*[MAXFRAMES] callstack;
Expand Down
3 changes: 3 additions & 0 deletions runner/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ void showVersion() {

version(unitttest) {} else {
int main(string[] arguments) {
import trial.runner;
setupSegmentationHandler!false;

arguments = arguments.map!(a => a.strip).filter!(a => a != "").array;

version(Windows) {
Expand Down

0 comments on commit 6cb7171

Please sign in to comment.