From 6833d64a4f3ab2fb7af979ddf9ab1558dd369606 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Fri, 27 Mar 2015 17:04:00 +0000 Subject: [PATCH 1/2] fix Issue 14350 - Unit test failures are not displayed in Windows GUI programs --- src/core/runtime.d | 9 ++------- src/rt/dmain2.d | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/runtime.d b/src/core/runtime.d index c569d74efd1..d5ffe8a9a6f 100644 --- a/src/core/runtime.d +++ b/src/core/runtime.d @@ -42,6 +42,7 @@ private extern (C) TraceHandler rt_getTraceHandler(); alias void delegate( Throwable ) ExceptionHandler; + extern (C) void printThrowable(Throwable t); extern (C) void* thread_stackBottom(); @@ -380,12 +381,6 @@ extern (C) bool runModuleUnitTests() if( Runtime.sm_moduleUnitTester is null ) { - void printErr(in char[] buf) - { - import core.stdc.stdio : fprintf, stderr; - fprintf(stderr, "%.*s", cast(int)buf.length, buf.ptr); - } - size_t failed = 0; foreach( m; ModuleInfo ) { @@ -401,7 +396,7 @@ extern (C) bool runModuleUnitTests() } catch( Throwable e ) { - e.toString(&printErr); printErr("\n"); + printThrowable(e); failed++; } } diff --git a/src/rt/dmain2.d b/src/rt/dmain2.d index 77edcd592b5..323486086cd 100644 --- a/src/rt/dmain2.d +++ b/src/rt/dmain2.d @@ -460,7 +460,7 @@ private void formatThrowable(Throwable t, void delegate(in char[] s) nothrow sin } } -private void printThrowable(Throwable t) +extern (C) void printThrowable(Throwable t) { // On Windows, a console may not be present to print the output to. // Show a message box instead. From bed8a4ddde899860d5678f0f6dcb6f6848d4da3e Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 7 Apr 2015 02:32:41 +0000 Subject: [PATCH 2/2] Rename printThrowable to _d_print_throwable --- src/core/runtime.d | 4 ++-- src/rt/dmain2.d | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/runtime.d b/src/core/runtime.d index d5ffe8a9a6f..dc9656db2fc 100644 --- a/src/core/runtime.d +++ b/src/core/runtime.d @@ -42,7 +42,7 @@ private extern (C) TraceHandler rt_getTraceHandler(); alias void delegate( Throwable ) ExceptionHandler; - extern (C) void printThrowable(Throwable t); + extern (C) void _d_print_throwable(Throwable t); extern (C) void* thread_stackBottom(); @@ -396,7 +396,7 @@ extern (C) bool runModuleUnitTests() } catch( Throwable e ) { - printThrowable(e); + _d_print_throwable(e); failed++; } } diff --git a/src/rt/dmain2.d b/src/rt/dmain2.d index 323486086cd..e1310cc0fbf 100644 --- a/src/rt/dmain2.d +++ b/src/rt/dmain2.d @@ -175,7 +175,7 @@ extern (C) int rt_init() catch (Throwable t) { _initCount = 0; - printThrowable(t); + _d_print_throwable(t); } _STD_critical_term(); _STD_monitor_staticdtor(); @@ -201,7 +201,7 @@ extern (C) int rt_term() } catch (Throwable t) { - printThrowable(t); + _d_print_throwable(t); } finally { @@ -398,7 +398,7 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc) } catch (Throwable t) { - printThrowable(t); + _d_print_throwable(t); result = EXIT_FAILURE; } } @@ -460,7 +460,7 @@ private void formatThrowable(Throwable t, void delegate(in char[] s) nothrow sin } } -extern (C) void printThrowable(Throwable t) +extern (C) void _d_print_throwable(Throwable t) { // On Windows, a console may not be present to print the output to. // Show a message box instead.