From a376702229007bfc7ba1f7656716bc80ed63065a Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Sat, 24 Dec 2016 17:11:31 -0500 Subject: [PATCH] Don't run main after unittests --- src/core/runtime.d | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/runtime.d b/src/core/runtime.d index 184fed7b9a..032d4a7f46 100644 --- a/src/core/runtime.d +++ b/src/core/runtime.d @@ -494,7 +494,7 @@ extern (C) bool runModuleUnitTests() if( Runtime.sm_moduleUnitTester is null ) { - size_t failed = 0; + size_t total = 0; foreach( m; ModuleInfo ) { if( m ) @@ -503,6 +503,7 @@ extern (C) bool runModuleUnitTests() if( fp ) { + ++total; try { fp(); @@ -510,12 +511,13 @@ extern (C) bool runModuleUnitTests() catch( Throwable e ) { _d_print_throwable(e); - failed++; } } } } - return failed == 0; + // Run main if and only if there was no unittest run. This is new + // behavior; previously, main would run if all unittests passed. + return total == 0; } return Runtime.sm_moduleUnitTester(); }