當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。