port = host.port_factory.get(options.platform, options)
    except NotImplementedError, e:
        # FIXME: is this the best way to handle unsupported port names?
        print >> stderr, str(e)
        return test_run_results.UNEXPECTED_ERROR_EXIT_STATUS

    try:
        run_details = run_tests(port, options, args, stderr)
        if ((run_details.exit_code not in test_run_results.ERROR_CODES or
             run_details.exit_code == test_run_results.EARLY_EXIT_STATUS) and
            not run_details.initial_results.keyboard_interrupted):
            bot_printer = buildbot_results.BuildBotPrinter(stdout, options.debug_rwt_logging)
            bot_printer.print_results(run_details)

        if options.enable_versioned_results:
            gen_dash_board = GenerateDashBoard(port)
            gen_dash_board.generate()

        return run_details.exit_code

    # We need to still handle KeyboardInterrupt, atleast for webkitpy unittest cases.
    except KeyboardInterrupt:
        return test_run_results.INTERRUPTED_EXIT_STATUS
    except test_run_results.TestRunException as e:
        print >> stderr, e.msg
        return e.code
    except BaseException as e:
        if isinstance(e, Exception):
            print >> stderr, '\n%s raised: %s' % (e.__class__.__name__, str(e))
            traceback.print_exc(file=stderr)
        return test_run_results.UNEXPECTED_ERROR_EXIT_STATUS
    except NotImplementedError, e:
        # FIXME: is this the best way to handle unsupported port names?
        print >> stderr, str(e)
        return test_run_results.UNEXPECTED_ERROR_EXIT_STATUS

    try:
        run_details = run_tests(port, options, args, stderr)
        if ((run_details.exit_code not in test_run_results.ERROR_CODES
             or run_details.exit_code == test_run_results.EARLY_EXIT_STATUS)
                and not run_details.initial_results.keyboard_interrupted):
            bot_printer = buildbot_results.BuildBotPrinter(
                stdout, options.debug_rwt_logging)
            bot_printer.print_results(run_details)

        if options.enable_versioned_results:
            gen_dash_board = GenerateDashBoard(port)
            gen_dash_board.generate()

        return run_details.exit_code

    # We need to still handle KeyboardInterrupt, atleast for webkitpy unittest cases.
    except KeyboardInterrupt:
        return test_run_results.INTERRUPTED_EXIT_STATUS
    except test_run_results.TestRunException as e:
        print >> stderr, e.msg
        return e.code
    except BaseException as e:
        if isinstance(e, Exception):
            print >> stderr, '\n%s raised: %s' % (e.__class__.__name__, str(e))
            traceback.print_exc(file=stderr)
        return test_run_results.UNEXPECTED_ERROR_EXIT_STATUS