Skip to content

Commit

Permalink
Added uncaught NSException handler to test runner.
Browse files Browse the repository at this point in the history
	Change on 2017/02/02 by tball <tball@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146427056
  • Loading branch information
tomball authored and kstanger committed Feb 3, 2017
1 parent 6965953 commit ba9bd24
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion testing/junit_ext/src/objc/TestRunnerMain.m
@@ -1,6 +1,7 @@

#import "com/google/j2objc/testing/JUnitTestRunner.h"

#include "java/lang/Thread.h"
#include <errno.h>
#include <execinfo.h>
#include <signal.h>
Expand Down Expand Up @@ -51,5 +52,16 @@ - (void)runTestsAndExit {

int main(int argc, char *argv[]) {
installSignalHandler();
UIApplicationMain(argc, argv, nil, @"TestRunnerAppDelegate");
@autoreleasepool {
@try {
UIApplicationMain(argc, argv, nil, @"TestRunnerAppDelegate");
}
@catch (NSException *e) {
JavaLangThread *currentThread = JavaLangThread_currentThread();
id uncaughtHandler = [currentThread getUncaughtExceptionHandler];
[uncaughtHandler uncaughtExceptionWithJavaLangThread:currentThread withNSException:e];
return 1;
}
}
return 0;
}

0 comments on commit ba9bd24

Please sign in to comment.