Exemplo n.º 1
0
def executeTests(args):
    anyFailed = False

    if args.profile is not None:
        ufora.native.TCMalloc.cpuProfilerStart(args.profile)

    #TODO FIX
    if not args.list:
        print "UFORA root is " + ufora.rootPythonPath
        print "Test arguments: ", args
        print
        print

    if args.py or args.lang or args.reasoning or args.native or args.localperf:
        FORA.initialize()

    if args.native and not args.list:
        print "Running C++ unit tests:"
        t0 = time.time()

        #see if native args had an optinal filter specified
        native_args = []
        if args.native is not True:
            native_args.append("--run_test=" + args.native)

        if ufora.native.Tests.test(
            (["--log_level=test_suite"] if args.testHarnessVerbose else []) +
                native_args):
            anyFailed = True

        print "took ", time.time() - t0
        print "\n\n"

    if args.py:
        filterFunc = None

        if args.modpair is not None:

            def testFilterFunc(tests):
                result = []
                for t in tests:
                    hashval = hexToInt(hashlib.sha1(repr(t)).hexdigest())
                    if hashval % args.modpair[1] == args.modpair[0]:
                        result.append(t)
                return result

            filterFunc = testFilterFunc

        if not args.list:
            print "Running python unit tests."
            print "nose version: ", nose.__version__
            print time.ctime(time.time())

        if runPythonUnitTests(args, filterFunc):
            anyFailed = True

        print "\n\n\n"

    if args.localperf:
        print "Running FORA local performance unit tests:"
        if LocalPerfTest.test(args.list, makeSemanticsTestFilter(args)):
            anyFailed = True
        print "\n\n\n"

    if args.lang:
        print "Running FORA language semantics unit tests:"
        if FORASemanticsTest.test(args.testHarnessVerbose,
                                  makeSemanticsTestFilter(args), False):
            anyFailed = True
        print "\n\n\n"

    if args.reasoning:
        print "Reasoning about FORA language semantics unit tests:"
        if FORASemanticsTest.test(args.testHarnessVerbose,
                                  makeSemanticsTestFilter(args), True):
            anyFailed = True
        print "\n\n\n"

    if args.multibox:
        print "Running multibox tests:"
        testRunner = MultiMachineTestRunner.createTestRunner(
            testDir=args.scriptPath or 'test_scripts/multibox',
            timeout=args.timeout[0] if args.timeout else None)
        if not testRunner.run():
            anyFailed = True
        print "\n\n\n"

    if args.scripts:
        defaultTimeout = args.timeout[0] if args.timeout else None
        print "Running script unit tests (timeout: %s sec):" % defaultTimeout
        scriptRunner = TestScriptRunner(testRoot=args.scriptPath
                                        or "test_scripts",
                                        defaultTimeout=defaultTimeout)
        if CodeCoverage.is_enabled():
            print 'With code coverage'
            if not scriptRunner.runWithCodeCoverage():
                anyFailed = True
        elif not scriptRunner.run():
            anyFailed = True
        print "\n\n\n"

    if args.node:
        print "Running node.js tests:"
        anyFailed = not runNodeTests() or anyFailed

    if args.browser:
        print "Running browser end-to-end test"
        browserRunner = TestScriptRunner(testRoot='ufora/web/relay/test/e2e')
        if not browserRunner.run():
            anyFailed = True
        print "\n\n\n"

    if anyFailed:
        print "Some unit tests failed!"
    else:
        print "All tests passed."

    import ufora.native.Tests as Tests
    Tests.gcov_flush()

    if args.profile is not None:
        ufora.native.TCMalloc.cpuProfilerStop()

    if anyFailed:
        return 1
    return 0
Exemplo n.º 2
0
 def runTests(self):
     scriptRunner = TestScriptRunner(testRoot=self.testDir, defaultTimeout=self.timeout)
     return scriptRunner.run()
Exemplo n.º 3
0
Arquivo: test.py Projeto: nkhuyu/ufora
def executeTests(args):
    anyFailed = False

    if args.profile is not None:
        ufora.native.TCMalloc.cpuProfilerStart(args.profile)

    #TODO FIX
    if not args.list:
        print "UFORA root is " + ufora.rootPythonPath
        print "Test arguments: ", args
        print
        print

    if args.py or args.lang or args.native or args.localperf:
        FORA.initialize()

    if args.native and not args.list:
        print "Running C++ unit tests:"
        t0 = time.time()

        #see if native args had an optinal filter specified
        native_args = []
        if args.native is not True:
            native_args.append("--run_test=" + args.native)

        if ufora.native.Tests.test( (["--log_level=test_suite"] if args.testHarnessVerbose else []) + native_args ):
            anyFailed = True

        print "took ", time.time() - t0
        print "\n\n"


    if args.py:
        filterFunc = None

        if args.modpair is not None:
            def testFilterFunc(tests):
                result = []
                for t in tests:
                    hashval = hexToInt(hashlib.sha1(repr(t)).hexdigest())
                    if hashval % args.modpair[1] == args.modpair[0]:
                        result.append(t)
                return result
            filterFunc = testFilterFunc

        if not args.list:
            print "Running python unit tests."
            print "nose version: ", nose.__version__
            print time.ctime(time.time())

        if runPythonUnitTests(args, filterFunc):
            anyFailed = True

        print "\n\n\n"

    if args.localperf:
        print "Running FORA local performance unit tests:"
        if LocalPerfTest.test(args.list, makeSemanticsTestFilter(args)):
            anyFailed = True
        print "\n\n\n"

    if args.lang:
        print "Running FORA language semantics unit tests:"
        if FORASemanticsTest.test(args.testHarnessVerbose, makeSemanticsTestFilter(args)):
            anyFailed = True
        print "\n\n\n"

    if args.multibox:
        print "Running multibox tests"
        testRunner = MultiMachineTestRunner.createTestRunner(
            testDir=args.scriptPath or 'test_scripts/multibox',
            timeout=args.timeout[0]
            )
        if not testRunner.run():
            anyFailed = True
        print "\n\n\n"

    if args.scripts:
        print "Running script unit tests:", args.timeout[0]
        scriptRunner = TestScriptRunner(testRoot=args.scriptPath or "test_scripts",
                                        defaultTimeout=args.timeout[0])
        if CodeCoverage.is_enabled():
            print 'With code coverage'
            if not scriptRunner.runWithCodeCoverage():
                anyFailed = True
        elif not scriptRunner.run():
            anyFailed = True
        print "\n\n\n"

    if args.node:
        print "Running node.js tests:"
        anyFailed = not runNodeTests() or anyFailed

    if args.browser:
        print "Running browser end-to-end test"
        browserRunner = TestScriptRunner(testRoot='ufora/web/relay/test/e2e')
        if not browserRunner.run():
            anyFailed = True
        print "\n\n\n"


    if anyFailed:
        print "Some unit tests failed!"
    else:
        print "All tests passed."


    import ufora.native.Tests as Tests
    Tests.gcov_flush()

    if args.profile is not None:
        ufora.native.TCMalloc.cpuProfilerStop()

    if anyFailed:
        return 1
    return 0
Exemplo n.º 4
0
 def runTests(self):
     scriptRunner = TestScriptRunner(testRoot=self.testDir,
                                     defaultTimeout=self.timeout)
     return scriptRunner.run()