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


Python Logger.fail方法代码示例

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


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

示例1: MatchFiles

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def MatchFiles(checkerFile, c1File, targetArch, debuggableMode):
  for testCase in checkerFile.testCases:
    if testCase.testArch not in [None, targetArch]:
      continue
    if testCase.forDebuggable != debuggableMode:
      continue

    # TODO: Currently does not handle multiple occurrences of the same group
    # name, e.g. when a pass is run multiple times. It will always try to
    # match a check group against the first output group of the same name.
    c1Pass = c1File.findPass(testCase.name)
    if c1Pass is None:
      Logger.fail("Test case \"{}\" not found in the CFG file".format(testCase.name),
                  testCase.fileName, testCase.startLineNo)

    Logger.startTest(testCase.name)
    try:
      MatchTestCase(testCase, c1Pass)
      Logger.testPassed()
    except MatchFailedException as e:
      lineNo = c1Pass.startLineNo + e.lineNo
      if e.assertion.variant == TestAssertion.Variant.Not:
        msg = "NOT assertion matched line {}"
      else:
        msg = "Assertion could not be matched starting from line {}"
      msg = msg.format(lineNo)
      Logger.testFailed(msg, e.assertion, e.variables)
开发者ID:Lingcc,项目名称:AndroidArt,代码行数:29,代码来源:file.py

示例2: addAssertion

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
 def addAssertion(self, new_assertion):
   if new_assertion.variant == TestAssertion.Variant.NextLine:
     if not self.assertions or \
        (self.assertions[-1].variant != TestAssertion.Variant.InOrder and \
         self.assertions[-1].variant != TestAssertion.Variant.NextLine):
       Logger.fail("A next-line assertion can only be placed after an "
                   "in-order assertion or another next-line assertion.",
                   new_assertion.fileName, new_assertion.lineNo)
   self.assertions.append(new_assertion)
开发者ID:AOSP-JF,项目名称:platform_art,代码行数:11,代码来源:struct.py

示例3: DumpPass

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def DumpPass(outputFilename, passName):
  c1File = ParseC1visualizerStream(os.path.basename(outputFilename), open(outputFilename, "r"))
  compiler_pass = c1File.findPass(passName)
  if compiler_pass:
    maxLineNo = compiler_pass.startLineNo + len(compiler_pass.body)
    lenLineNo = len(str(maxLineNo)) + 2
    curLineNo = compiler_pass.startLineNo
    for line in compiler_pass.body:
      Logger.log((str(curLineNo) + ":").ljust(lenLineNo) + line)
      curLineNo += 1
  else:
    Logger.fail("Pass \"" + passName + "\" not found in the output")
开发者ID:BenzoRoms,项目名称:art,代码行数:14,代码来源:checker.py

示例4: __init__

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
    def __init__(self, parent, name, body, startLineNo):
        self.parent = parent
        self.name = name
        self.body = body
        self.startLineNo = startLineNo

        if not self.name:
            Logger.fail("C1visualizer pass does not have a name", self.fileName, self.startLineNo)
        if not self.body:
            Logger.fail("C1visualizer pass does not have a body", self.fileName, self.startLineNo)

        self.parent.addPass(self)
开发者ID:RadonX-MM,项目名称:platform_art,代码行数:14,代码来源:struct.py

示例5: __init__

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
  def __init__(self, parent, name, startLineNo, testArch = None):
    assert isinstance(parent, CheckerFile)

    self.parent = parent
    self.name = name
    self.assertions = []
    self.startLineNo = startLineNo
    self.testArch = testArch

    if not self.name:
      Logger.fail("Test case does not have a name", self.fileName, self.startLineNo)

    self.parent.addTestCase(self)
开发者ID:AOSP-JF,项目名称:platform_art,代码行数:15,代码来源:struct.py

示例6: __processLine

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def __processLine(line, lineNo, prefix, fileName):
  """ This function is invoked on each line of the check file and returns a triplet
      which instructs the parser how the line should be handled. If the line is
      to be included in the current check group, it is returned in the first
      value. If the line starts a new check group, the name of the group is
      returned in the second value. The third value indicates whether the line
      contained an architecture-specific suffix.
  """
  if not __isCheckerLine(line):
    return None, None, None

  # Lines beginning with 'CHECK-START' start a new test case.
  # We currently only consider the architecture suffix in "CHECK-START" lines.
  for debuggable in [True, False]:
    for arch in [None] + archs_list:
      startLine = __extractLine(prefix + "-START", line, arch, debuggable)
      if startLine is not None:
        return None, startLine, (arch, debuggable)

  # Lines starting only with 'CHECK' are matched in order.
  plainLine = __extractLine(prefix, line)
  if plainLine is not None:
    return (plainLine, TestAssertion.Variant.InOrder, lineNo), None, None

  # 'CHECK-NEXT' lines are in-order but must match the very next line.
  nextLine = __extractLine(prefix + "-NEXT", line)
  if nextLine is not None:
    return (nextLine, TestAssertion.Variant.NextLine, lineNo), None, None

  # 'CHECK-DAG' lines are no-order assertions.
  dagLine = __extractLine(prefix + "-DAG", line)
  if dagLine is not None:
    return (dagLine, TestAssertion.Variant.DAG, lineNo), None, None

  # 'CHECK-NOT' lines are no-order negative assertions.
  notLine = __extractLine(prefix + "-NOT", line)
  if notLine is not None:
    return (notLine, TestAssertion.Variant.Not, lineNo), None, None

  # 'CHECK-EVAL' lines evaluate a Python expression.
  evalLine = __extractLine(prefix + "-EVAL", line)
  if evalLine is not None:
    return (evalLine, TestAssertion.Variant.Eval, lineNo), None, None

  Logger.fail("Checker assertion could not be parsed: '" + line + "'", fileName, lineNo)
开发者ID:BenzoRoms,项目名称:art,代码行数:47,代码来源:parser.py

示例7: FindCheckerFiles

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def FindCheckerFiles(path):
  """ Returns a list of files to scan for check annotations in the given path.
      Path to a file is returned as a single-element list, directories are
      recursively traversed and all '.java' and '.smali' files returned.
  """
  if not path:
    Logger.fail("No source path provided")
  elif os.path.isfile(path):
    return [ path ]
  elif os.path.isdir(path):
    foundFiles = []
    for root, dirs, files in os.walk(path):
      for file in files:
        extension = os.path.splitext(file)[1]
        if extension in [".java", ".smali"]:
          foundFiles.append(os.path.join(root, file))
    return foundFiles
  else:
    Logger.fail("Source path \"" + path + "\" not found")
开发者ID:BenzoRoms,项目名称:art,代码行数:21,代码来源:checker.py

示例8: ParseC1visualizerStream

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def ParseC1visualizerStream(fileName, stream):
  c1File = C1visualizerFile(fileName)
  state = C1ParserState()
  fnProcessLine = lambda line, lineNo: __parseC1Line(line, lineNo, state, fileName)
  fnLineOutsideChunk = lambda line, lineNo: \
      Logger.fail("C1visualizer line not inside a group", fileName, lineNo)
  for passName, passLines, startLineNo, testArch in \
      SplitStream(stream, fnProcessLine, fnLineOutsideChunk):
    C1visualizerPass(c1File, passName, passLines, startLineNo + 1)
  return c1File
开发者ID:BenzoRoms,项目名称:art,代码行数:12,代码来源:parser.py

示例9: __parseC1Line

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def __parseC1Line(line, lineNo, state, fileName):
  """ This function is invoked on each line of the output file and returns
      a triplet which instructs the parser how the line should be handled. If the
      line is to be included in the current group, it is returned in the first
      value. If the line starts a new output group, the name of the group is
      returned in the second value. The third value is only here to make the
      function prototype compatible with `SplitStream` and is always set to
      `None` here.
  """
  if state.currentState == C1ParserState.StartingCfgBlock:
    # Previous line started a new 'cfg' block which means that this one must
    # contain the name of the pass (this is enforced by C1visualizer).
    if re.match("name\s+\"[^\"]+\"", line):
      # Extract the pass name, prepend it with the name of the method and
      # return as the beginning of a new group.
      state.currentState = C1ParserState.InsideCfgBlock
      return (None, state.lastMethodName + " " + line.split("\"")[1], None)
    else:
      Logger.fail("Expected output group name", fileName, lineNo)

  elif state.currentState == C1ParserState.InsideCfgBlock:
    if line == "end_cfg":
      state.currentState = C1ParserState.OutsideBlock
      return (None, None, None)
    else:
      return (line, None, None)

  elif state.currentState == C1ParserState.InsideCompilationBlock:
    # Search for the method's name. Format: method "<name>"
    if re.match("method\s+\"[^\"]*\"", line):
      methodName = line.split("\"")[1].strip()
      if not methodName:
        Logger.fail("Empty method name in output", fileName, lineNo)
      state.lastMethodName = methodName
    elif line == "end_compilation":
      state.currentState = C1ParserState.OutsideBlock
    return (None, None, None)

  else:
    assert state.currentState == C1ParserState.OutsideBlock
    if line == "begin_cfg":
      # The line starts a new group but we'll wait until the next line from
      # which we can extract the name of the pass.
      if state.lastMethodName is None:
        Logger.fail("Expected method header", fileName, lineNo)
      state.currentState = C1ParserState.StartingCfgBlock
      return (None, None, None)
    elif line == "begin_compilation":
      state.currentState = C1ParserState.InsideCompilationBlock
      return (None, None, None)
    else:
      Logger.fail("C1visualizer line not inside a group", fileName, lineNo)
开发者ID:BenzoRoms,项目名称:art,代码行数:54,代码来源:parser.py

示例10: ParseCheckerStream

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
def ParseCheckerStream(fileName, prefix, stream):
  checkerFile = CheckerFile(fileName)
  fnProcessLine = lambda line, lineNo: __processLine(line, lineNo, prefix, fileName)
  fnLineOutsideChunk = lambda line, lineNo: \
      Logger.fail("Checker line not inside a group", fileName, lineNo)
  for caseName, caseLines, startLineNo, testArch in \
      SplitStream(stream, fnProcessLine, fnLineOutsideChunk):
    testCase = TestCase(checkerFile, caseName, startLineNo, testArch)
    for caseLine in caseLines:
      ParseCheckerAssertion(testCase, caseLine[0], caseLine[1], caseLine[2])
  return checkerFile
开发者ID:hhhaiai,项目名称:android_art,代码行数:13,代码来源:parser.py

示例11: addExpression

# 需要导入模块: from common.logger import Logger [as 别名]
# 或者: from common.logger.Logger import fail [as 别名]
 def addExpression(self, new_expression):
     assert isinstance(new_expression, TestExpression)
     if self.variant == TestAssertion.Variant.Not:
         if new_expression.variant == TestExpression.Variant.VarDef:
             Logger.fail("CHECK-NOT lines cannot define variables", self.fileName, self.lineNo)
     self.expressions.append(new_expression)
开发者ID:RadonX-MM,项目名称:platform_art,代码行数:8,代码来源:struct.py


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