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


Python TestRunner.executeCommand方法代码示例

本文整理汇总了Python中TestRunner.executeCommand方法的典型用法代码示例。如果您正苦于以下问题:Python TestRunner.executeCommand方法的具体用法?Python TestRunner.executeCommand怎么用?Python TestRunner.executeCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestRunner的用法示例。


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

示例1: execute

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
    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,代码行数:35,代码来源:TestFormats.py

示例2: generateFortranModules

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
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,代码行数:49,代码来源:DETestRunner.py

示例3: isLanguageSupported

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
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,代码行数:49,代码来源:DEUtils.py

示例4: execute

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
    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:,项目名称:,代码行数:17,代码来源:

示例5: execute

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
    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)

        if not exitCode and (self.allowStdout or not out.strip()) and \
                            (self.allowStderr or not err.strip()):
            status = Test.PASS
        else:
            status = Test.FAIL

        if status == Test.FAIL or litConfig.showAllOutput:
            # 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 += """Command Output (stdout):\n--\n%s--\n""" % out
            report += """Command Output (stderr):\n--\n%s--\n""" % err
        else:
            report = ""

        return status, report
开发者ID:tongche,项目名称:llvm,代码行数:41,代码来源:TestFormats.py

示例6: execute

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
    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,代码行数:26,代码来源:TestFormats.py

示例7: executeOne

# 需要导入模块: import TestRunner [as 别名]
# 或者: from TestRunner import executeCommand [as 别名]
 def executeOne(cmd):
     return TestRunner.executeCommand(cmd + args, cwd)
开发者ID:aleguna,项目名称:llvm-project,代码行数:4,代码来源:DETestRunner.py


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