当前位置: 首页>>代码示例>>Python>>正文


Python TestRunner类代码示例

本文整理汇总了Python中TestRunner的典型用法代码示例。如果您正苦于以下问题:Python TestRunner类的具体用法?Python TestRunner怎么用?Python TestRunner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestRunner类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    ''' main test logic '''
    print("TestRunner.py - main")

    if Configuration.DEBUG == True:
        print("Debug messaging is ON")
        logLevel = logging.DEBUG
    else:
        print("Debug messaging is OFF")
        logLevel = logging.INFO

    # setup logger
    if not logFileFromBAT == None:
        Configuration.Logger = UnitTestUtilities.initializeLogger(logFileFromBAT, logLevel)
    else:
        Configuration.GetLogger(logLevel)

    print("Logging results to: " + str(Configuration.LoggerFile))
    UnitTestUtilities.setUpLogFileHeader()

    result = runTestSuite()

    TestRunner.logTestResults(result)

    return result.wasSuccessful()
开发者ID:Esri,项目名称:solutions-geoprocessing-toolbox,代码行数:25,代码来源:MilitaryFeaturesTestRunner.py

示例2: handleUpdate

    def handleUpdate(self, index, tr):
        if self.progressBar:
            if tr.failed():
                self.progressBar.clear()
            else:
                # Force monotonicity
                self.progress = max(self.progress, float(index)/self.numTests)
                self.progressBar.update(self.progress, tr.path)
                return
        elif self.opts.succinct:
            if not tr.failed():
                sys.stdout.write('.')
                sys.stdout.flush()
                return
            else:
                sys.stdout.write('\n')

        extra = ''
        if tr.code==TestStatus.Invalid:
            extra = ' - (Invalid test)'
        elif tr.code==TestStatus.NoRunLine:
            extra = ' - (No RUN line)'
        elif tr.failed():
            extra = ' - %s'%(TestStatus.getName(tr.code).upper(),)
        print '%*d/%*d - %s%s'%(self.digits, index+1, self.digits, 
                              self.numTests, tr.path, extra)

        if tr.failed() and self.opts.showOutput:
            TestRunner.cat(tr.testResults, sys.stdout)
开发者ID:aosm,项目名称:clang,代码行数:29,代码来源:MultiTestRunner.py

示例3: execute

    def execute(self, test, litConfig):
        if test.config.unsupported:
            return (Test.UNSUPPORTED, 'Test is unsupported')

        cmd = list(self.command)

        # If using temp input, create a temporary file and hand it to the
        # subclass.
        if self.useTempInput:
            tmp = tempfile.NamedTemporaryFile(suffix='.cpp')
            self.createTempInput(tmp, test)
            tmp.flush()
            cmd.append(tmp.name)
        elif hasattr(test, 'source_path'):
            cmd.append(test.source_path)
        else:
            cmd.append(test.getSourcePath())

        out, err, exitCode = TestRunner.executeCommand(cmd)

        diags = out + err
        if not exitCode and not diags.strip():
            return Test.PASS,''

        # Try to include some useful information.
        report = """Command: %s\n""" % ' '.join(["'%s'" % a
                                                 for a in cmd])
        if self.useTempInput:
            report += """Temporary File: %s\n""" % tmp.name
            report += "--\n%s--\n""" % open(tmp.name).read()
        report += """Output:\n--\n%s--""" % diags

        return Test.FAIL, report
开发者ID:dmlap,项目名称:llvm-js-backend,代码行数:33,代码来源:TestFormats.py

示例4: handleUpdate

    def handleUpdate(self, index, tr):
        if self.progressBar:
            if tr.failed():
                self.progressBar.clear()
            else:
                # Force monotonicity
                self.progress = max(self.progress, float(index)/self.numTests)
                self.progressBar.update(self.progress, tr.path)
                return
        elif self.opts.succinct:
            if not tr.failed():
                sys.stdout.write('.')
                sys.stdout.flush()
                return
            else:
                sys.stdout.write('\n')

        extra = ''
        if tr.code==TestStatus.Invalid:
            extra = ' - (Invalid test)'
        elif tr.code==TestStatus.NoRunLine:
            extra = ' - (No RUN line)'
        elif tr.failed():
            extra = ' - %s'%(TestStatus.getName(tr.code).upper(),)
        print '%*d/%*d - %s%s'%(self.digits, index+1, self.digits, 
                              self.numTests, tr.path, extra)

        if tr.failed():
            msgs = []
            if tr.warnings:
                msgs.append('%d warnings'%(len(tr.warnings),))
            if tr.errors:
                msgs.append('%d errors'%(len(tr.errors),))
            if tr.assertions:
                msgs.append('%d assertions'%(len(tr.assertions),))
            
            if msgs:
                print '\tFAIL (%s)'%(', '.join(msgs))
            for i,error in enumerate(set([e for (_,_,_,e) in tr.errors])):
                print '\t\tERROR: %s'%(error,)
                if i>20:
                    print '\t\t\t(too many errors, skipping)'
                    break
            for assertion in set(tr.assertions):
                print '\t\tASSERTION: %s'%(assertion,)
            if self.opts.showOutput:
                TestRunner.cat(tr.testResults, sys.stdout)
开发者ID:,项目名称:,代码行数:47,代码来源:

示例5: generateFortranModules

def generateFortranModules(cmd, srcPath, OutputDir):
    # Fortran 90 code often fails to compile because it needs modules defined by
    # other files in the same directory.  If this seems to be happening then try
    # to generate all of the required modules by compiling every Fortran file in
    # the same directory.
    srcDir,srcBase = os.path.split(srcPath)
    cmd = cmd + ['-I', srcDir, '-fsyntax-only']

    # If the file compiles OK or isn't failing because of lacking modules then
    # there is no point in trying to generate modules.
    out,err,exitCode = TestRunner.executeCommand(cmd + [srcPath], OutputDir)
    if exitCode == 0 or err is None or "Can't open module file" not in err:
        return

    # Drat, it fails to compile.  Generate modules for every Fortran file in the
    # source directory.
    fortranSuffixes = DEUtils.getSuffixesForLanguage('fortran')
    filesToCompile = []
    for filename in os.listdir(srcDir):
        filepath = os.path.join(srcDir, filename)
        if not os.path.isdir(filepath):
            base,ext = os.path.splitext(filename)
            if ext in fortranSuffixes:
                filesToCompile.append(filepath)

    # Compile every file, returning triumphantly once the original file manages
    # to compile, or giving up miserably if no progress is being made.
    newFilesToCompile = []
    while filesToCompile != newFilesToCompile:
        newFilesToCompile = []
        # Compile each file in turn.
        for path in filesToCompile:
            out,err,exitCode = TestRunner.executeCommand(cmd + [path], OutputDir)
            if exitCode != 0 and err is not None and "Can't open module file" in err:
                # It failed to compile due to a missing module.  Remember it for
                # the next round.
                newFilesToCompile.append(path);
            elif path == srcPath:
                # The original file compiled, or at least didn't fail to compile
                # due to a lacking module.  Return triumphantly!
                return
        # Arrange for the next iteration to compile the files that were missing
        # modules this time round.
        filesToCompile, newFilesToCompile = newFilesToCompile, filesToCompile

    # The set of files missing modules didn't change, give up miserably.
    return
开发者ID:aleguna,项目名称:llvm-project,代码行数:47,代码来源:DETestRunner.py

示例6: isLanguageSupported

def isLanguageSupported(language, compiler):
  # How to run the compiler.  Additional arguments are added below.
  args = [compiler, '-S', '-o', os.devnull]

  if language == 'java':
    # GCC can't compile Java source by itself, it can only compile class files.
    script_dir = os.path.dirname(os.path.realpath(__file__))
    source = os.path.join(script_dir, 'e.class')
    # Java is supported if the class file compiles without error.
    out,err,exitCode = TestRunner.executeCommand(args +
                                                 [source, '-fuse-boehm-gc'])
    return exitCode == 0

  if language == 'ada':
    suffix='.ads'
  elif language == 'c':
    suffix='.c'
  elif language == 'c++':
    suffix='.cpp'
  elif language == 'fortran':
    suffix='.f'
  elif language == 'go':
    suffix='.go'
  elif language == 'objective-c':
    suffix='.m'
  elif language == 'objective-c++':
    suffix='.mm'
  else:
    return False

  # For most languages it suffices to try compiling an empty file however for
  # Ada and Go an empty file is not a valid compilation unit.
  source = tempfile.NamedTemporaryFile(mode='w+t', suffix=suffix)

  if language == 'ada':
    # Use an obscure package name, as if the package is called XYZ and a file
    # called XYZ.adb exists then the test will fail.
    source.write('package U5TE4J886W is end;\n')
  elif language == 'go':
    source.write('package main\n')

  # If something was written then ensure it is visible to the compiler process.
  source.flush()

  # The language is supported if the file compiles without error.
  out,err,exitCode = TestRunner.executeCommand(args + [source.name])
  return exitCode == 0
开发者ID:aleguna,项目名称:llvm-project,代码行数:47,代码来源:DEUtils.py

示例7: execute

    def execute(self, test, litConfig):
        testPath, testName = os.path.split(test.getSourcePath())
        while not os.path.exists(testPath):
            # Handle GTest parametrized and typed tests, whose name includes
            # some '/'s.
            testPath, namePrefix = os.path.split(testPath)
            testName = os.path.join(namePrefix, testName)

        cmd = [testPath, "--gtest_filter=" + testName]
        out, err, exitCode = TestRunner.executeCommand(cmd)

        if not exitCode:
            return Test.PASS, ""

        return Test.FAIL, out + err
开发者ID:,项目名称:,代码行数:15,代码来源:

示例8: execute

    def execute(self, test, litConfig):
        execdir = os.path.dirname(test.getExecPath())
        tmpBase  = self.getTmpBase(test, litConfig)

        res = self.getTestScript(test, litConfig, self.default_script)
        if len(res) == 2:
            return res
        s, script, isXFail = res

        script = self.applyScriptSubstitutions(test, litConfig, script,
                tmpBase, normalize_slashes=self.execute_external)

        return TestRunner.executeShTest(test, litConfig, script,
                                        isXFail, tmpBase, execdir,
                                        self.execute_external)
开发者ID:tongche,项目名称:llvm,代码行数:15,代码来源:TestFormats.py

示例9: execute

    def execute(self, test, litConfig):
        testPath,testName = os.path.split(test.getSourcePath())
        while not os.path.exists(testPath):
            # Handle GTest parametrized and typed tests, whose name includes
            # some '/'s.
            testPath, namePrefix = os.path.split(testPath)
            testName = os.path.join(namePrefix, testName)

        cmd = [testPath, '--gtest_filter=' + testName]
        if litConfig.useValgrind:
            valgrindArgs = ['valgrind', '-q',
                            '--tool=memcheck', '--trace-children=yes',
                            '--error-exitcode=123']
            valgrindArgs.extend(litConfig.valgrindArgs)

            cmd = valgrindArgs + cmd

        out, err, exitCode = TestRunner.executeCommand(
            cmd, env=test.config.environment)
            
        if not exitCode:
            return Test.PASS,''

        return Test.FAIL, out + err
开发者ID:ericmckean,项目名称:nacl-llvm-branches.llvm-trunk,代码行数:24,代码来源:TestFormats.py

示例10: execute

 def execute(self, test, litConfig):
     litConfig.ignoreStdErr = self.ignoreStdErr
     return TestRunner.executeTclTest(test, litConfig)
开发者ID:32bitmicro,项目名称:llvm,代码行数:3,代码来源:TestFormats.py

示例11: in

            parser.error(e.args[0])

    cfg = TestingConfig.frompath(opts.config)

    # Update the configuration based on the command line arguments.
    for name in ('PATH','SYSTEMROOT'):
        if name in cfg.environment:
            parser.error("'%s' should not be set in configuration!" % name)

    cfg.root = opts.root
    cfg.environment['PATH'] = os.pathsep.join(opts.path + 
                                                 [os.environ.get('PATH','')])
    cfg.environment['SYSTEMROOT'] = os.environ.get('SYSTEMROOT','')

    if opts.clang is None:
        opts.clang = TestRunner.inferClang(cfg)
    if opts.clangcc is None:
        opts.clangcc = TestRunner.inferClangCC(cfg, opts.clang)

    cfg.clang = opts.clang
    cfg.clangcc = opts.clangcc
    cfg.useValgrind = opts.useValgrind
    cfg.useExternalShell = opts.useExternalShell

    # FIXME: It could be worth loading these in parallel with testing.
    allTests = list(getTests(cfg, args))
    allTests.sort()
    
    tests = allTests
    if opts.shuffle:
        random.shuffle(tests)
开发者ID:,项目名称:,代码行数:31,代码来源:

示例12: executeOne

 def executeOne(cmd):
     return TestRunner.executeCommand(cmd + args, cwd)
开发者ID:aleguna,项目名称:llvm-project,代码行数:2,代码来源:DETestRunner.py


注:本文中的TestRunner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。