Example #1
0
File: test.py Project: nkhuyu/ufora
    def runTests():
        if args.timeout is not None:
            UnitTestCommon.startTimeoutThread(args.timeout[0])

        try:
            return executeTests(args)
        except:
            import traceback
            logging.error("executeTests() threw an exception: \n%s", traceback.format_exc())
            return 1
Example #2
0
File: test.py Project: ufora/ufora
    def runTests():
        if args.timeout is not None:
            UnitTestCommon.startTimeoutThread(args.timeout[0])

        try:
            return executeTests(args)
        except:
            import traceback
            logging.error("executeTests() threw an exception: \n%s", traceback.format_exc())
            return 1
Example #3
0
def UnitTestMainline(modulesToInitialize=None,
                     exit=True,
                     loginConfiguration=LoginConfiguration.LoginConfiguration.
                     defaultForTesting(),
                     disableLogCapture=False):
    """Helper function to call the unittest mainline

    Constructs a default Setup from the config. Calls
        x.initialize(setup)
    for all x in modulesToInitialize.
    """
    modulesToInitialize = modulesToInitialize or []
    import ufora.native

    argv = list(sys.argv)
    setup = Setup.defaultSetup()

    parser = Setup.defaultParser()

    unitTestOptions = parser.add_argument_group(
        title='UnitTestMainline options',
        description='options for the general UnitTest framework')
    addNoseVerbosityArgument(unitTestOptions)

    unitTestOptions.add_argument('testHarnessArguments',
                                 nargs=argparse.REMAINDER)

    parser.add_argument(
        '-timeout',
        type=float,
        nargs=1,
        help='fail test if not completed after TIMEOUT seconds',
        default=None)

    parsedArguments = parser.parse_args(argv[1:])

    if parsedArguments.timeout is not None:
        UnitTestCommon.startTimeoutThread(parsedArguments.timeout[0])

    setup.processArgs(parsedArguments)

    testHarnessArguments = ["dummy"] + parsedArguments.testHarnessArguments

    testHarnessArguments.append('--verbosity=0')

    if parsedArguments.testHarnessVerbose or disableLogCapture:
        testHarnessArguments.append('--nocaptureall')
    setup.config.configureLoggingForUserProgram()

    plugins = nose.plugins.manager.PluginManager([OutputCaptureNosePlugin()])

    config = nose.config.Config(plugins=plugins)
    config.configure(testHarnessArguments)

    with Setup.PushSetup(setup):
        result = None
        for toInitialize in modulesToInitialize:
            toInitialize.initialize(setup)

        result = nose.core.TestProgram(exit=False,
                                       defaultTest="__main__",
                                       config=config,
                                       argv=testHarnessArguments).success

        sys.stdout.flush()
        sys.stderr.flush()
        ufora.native.Tests.gcov_flush()

        if not exit:
            return 0 if result else 1
        else:
            os._exit(0 if result else 1)
Example #4
0
def UnitTestMainline(modulesToInitialize=None,
                     exit=True,
                     loginConfiguration=LoginConfiguration.LoginConfiguration.defaultForTesting(),
                     disableLogCapture=False):
    """Helper function to call the unittest mainline

    Constructs a default Setup from the config. Calls
        x.initialize(setup)
    for all x in modulesToInitialize.
    """
    modulesToInitialize = modulesToInitialize or []
    import ufora.native

    argv = list(sys.argv)
    setup = Setup.defaultSetup()

    parser = Setup.defaultParser()

    unitTestOptions = parser.add_argument_group(
        title='UnitTestMainline options',
        description='options for the general UnitTest framework'
        )
    addNoseVerbosityArgument(unitTestOptions)

    unitTestOptions.add_argument(
        'testHarnessArguments',
        nargs=argparse.REMAINDER
        )

    parser.add_argument('-timeout',
                        type=float,
                        nargs=1,
                        help='fail test if not completed after TIMEOUT seconds',
                        default=None)

    parsedArguments = parser.parse_args(argv[1:])

    if parsedArguments.timeout is not None:
        UnitTestCommon.startTimeoutThread(parsedArguments.timeout[0])

    setup.processArgs(parsedArguments)

    testHarnessArguments = ["dummy"] + parsedArguments.testHarnessArguments

    testHarnessArguments.append('--verbosity=0')

    if parsedArguments.testHarnessVerbose or disableLogCapture:
        testHarnessArguments.append('--nocaptureall')
    setup.config.configureLoggingForUserProgram()

    plugins = nose.plugins.manager.PluginManager([OutputCaptureNosePlugin()])


    config = nose.config.Config(plugins=plugins)
    config.configure(testHarnessArguments)

    with Setup.PushSetup(setup):
        result = None
        for toInitialize in modulesToInitialize:
            toInitialize.initialize(setup)

        result = nose.core.TestProgram(
            exit=False,
            defaultTest="__main__",
            config=config,
            argv=testHarnessArguments
            ).success

        sys.stdout.flush()
        sys.stderr.flush()
        ufora.native.Tests.gcov_flush()

        if not exit:
            return 0 if result else 1
        else:
            os._exit(0 if result else 1)