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)
def main(argv): t0 = time.time() Runtime.initialize(Setup.defaultSetup()) runtime = Runtime.getMainRuntime() handler = runtime.getInterpreterTraceHandler() handler.replayTracesFromFile(argv[1]) print "took ", time.time() - t0
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)
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
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)
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ rebuildAxiomSearchFunction Generate appropriate axiom build functions after we've built the project successfully. """ import os import ufora import ufora.config.Setup as Setup import ufora.FORA.python.Runtime as Runtime Runtime.initialize(Setup.defaultSetup()) axioms = Runtime.getMainRuntime().getAxioms() implvalCode, jovtCode = axioms.getCppWrapperCode() uforaDir = os.path.split(os.path.abspath(ufora.__file__))[0] with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, implvalCode with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch2.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, jovtCode
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ rebuildAxiomSearchFunction Generate appropriate axiom build functions after we've built the project successfully. """ import os import ufora import ufora.config.Setup as Setup import ufora.FORA.python.Runtime as Runtime Runtime.initialize(Setup.defaultSetup()) axioms = Runtime.getMainRuntime().getAxioms() implvalCode, jovtCode = axioms.getCppWrapperCode() uforaDir = os.path.split(os.path.abspath(ufora.__file__))[0] with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py" print >> f, implvalCode with open(os.path.join(uforaDir, "FORA", "Axioms", "AxiomSearch2.cpp"), "w") as f: print >> f, "//generated by ufora/scripts/rebuildAxiomSearchFunction.py"
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)