Ejemplo n.º 1
0
def main(args):
    print "ufora-worker starting"
    setup = defaultSetup()
    with Setup.PushSetup(setup):
        setup.config.configureLoggingForBackgroundProgram()

        worker = createService(args)
        worker.startService(None)

        def signal_handler(sig, _):
            signal_name = '(unknown)'
            if sig == signal.SIGINT:
                signal_name = 'SIGINT'
            elif sig == signal.SIGTERM:
                signal_name = 'SIGTERM'

            print 'Received ', signal_name, 'signal. Exiting.'

            worker.stopService()
            sys.exit(0)

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)
        print "Press Ctrl+C to exit."
        signal.pause()
Ejemplo n.º 2
0
def UserFacingMainline(main, argv, modulesToInitialize=None, parser=None):
    """Helper function that initializes some modules and then calls main.

    Used to centralize error handling for common initialization routines and to set up the
    initial component hosts.
    """
    if parser is None:
        parser = Setup.defaultParser()

    setup = Setup.defaultSetup()

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

    setup.config.configureLoggingForUserProgram()

    with Setup.PushSetup(setup):
        initializeModules(modulesToInitialize)

        result = main(parsedArguments)

        if result is None:
            result = 0

        sys.stdout.flush()
        sys.stderr.flush()

        os._exit(result)
Ejemplo n.º 3
0
def executeTestAsMain():
    with Setup.PushSetup(Setup.defaultSetup()):
        #tests = ['testKeys', 'testMutableDefaults', 'testProperty', 'testChangeMutable', 'testLocationAccess', 'testFunction', 'testInitializer', 'testCached', 'testNotCached', 'testRootProperty']
        #tests = ['testProperty']
        tests = ['testTemp']
        #tests = ['testOrphan']
        #tests = ['testLocKey2']
        #tests = ['testKeys']
        #tests = ['testCreate']
        suite = unittest.TestSuite(map(ComputedGraphTest, tests))
        unittest.TextTestRunner().run(suite)
Ejemplo n.º 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)
Ejemplo n.º 5
0
        for filename in foraFiles:
            foraModule = FORA.importModule(os.path.join(testPath, filename))
            moduleMembersAndMetadataDict = FORA.objectMembers(foraModule)

            for memberName, memberMetadata in moduleMembersAndMetadataDict.iteritems():
                if self.isPerfTestCase(memberMetadata):
                    if filename not in perfTestCases:
                        perfTestCases[filename] = set()
                    perfTestCases[filename].add(memberName)
                    metadataForPerfTestCases[(filename, memberName)] = memberMetadata.outer

        return perfTestCases, metadataForPerfTestCases

if __name__ == "__main__":
    setup = Setup.defaultSetup()
    with Setup.PushSetup(setup):
        Setup.config().configureLoggingForUserProgram()

        FORA.initialize()

        langfilter = None
        listOnly = False

        try:
            result = test()
        except:
            logging.critical(traceback.format_exc())
            result = 1