Example #1
0
 def _handleBooleanExpr(line_number, line, output):
     """A parser for BOOLEAN_EXPR type keywords"""
     if output is None:
         output = []
     output.extend([s.strip() for s in line.split(',')])
     # Evaluate each expression to verify syntax.
     # We don't want any results, just the raised ValueError.
     for s in output:
         if s != '*':
             BooleanExpression.evaluate(s, [])
     return output
Example #2
0
    def isExpectedToFail(self):
        """
        isExpectedToFail() -> bool

        Check whether this test is expected to fail in the current
        configuration. This check relies on the test xfails property which by
        some test formats may not be computed until the test has first been
        executed.
        Throws ValueError if an XFAIL line has a syntax error.
        """

        features = self.config.available_features
        triple = getattr(self.suite.config, 'target_triple', "")

        # Check if any of the xfails match an available feature or the target.
        for item in self.xfails:
            # If this is the wildcard, it always fails.
            if item == '*':
                return True

            # If this is a True expression of features and target triple parts,
            # it fails.
            try:
                if BooleanExpression.evaluate(item, features, triple):
                    return True
            except ValueError as e:
                raise ValueError('Error in XFAIL list:\n%s' % str(e))

        return False
Example #3
0
    def isExpectedToFail(self):
        """
        isExpectedToFail() -> bool

        Check whether this test is expected to fail in the current
        configuration. This check relies on the test xfails property which by
        some test formats may not be computed until the test has first been
        executed.
        Throws ValueError if an XFAIL line has a syntax error.
        """

        features = self.config.available_features
        triple = getattr(self.suite.config, 'target_triple', "")

        # Check if any of the xfails match an available feature or the target.
        for item in self.xfails:
            # If this is the wildcard, it always fails.
            if item == '*':
                return True

            # If this is a True expression of features and target triple parts,
            # it fails.
            try:
                if BooleanExpression.evaluate(item, features, triple):
                    return True
            except ValueError as e:
                raise ValueError('Error in XFAIL list:\n%s' % str(e))

        return False
Example #4
0
 def getMissingRequiredFeaturesFromList(self, features):
     try:
         return [
             item for item in self.requires
             if not BooleanExpression.evaluate(item, features)
         ]
     except ValueError as e:
         raise ValueError('Error in REQUIRES list:\n%s' % str(e))
Example #5
0
    def getUnsupportedFeatures(self):
        """
        getUnsupportedFeatures() -> list of strings

        Returns a list of features from UNSUPPORTED that are present
        in the test configuration's features or target triple.
        Throws ValueError if an UNSUPPORTED line has a syntax error.
        """

        features = self.config.available_features
        triple = getattr(self.suite.config, 'target_triple', "")

        try:
            return [item for item in self.unsupported
                    if BooleanExpression.evaluate(item, features, triple)]
        except ValueError as e:
            raise ValueError('Error in UNSUPPORTED list:\n%s' % str(e))
Example #6
0
    def getUnsupportedFeatures(self):
        """
        getUnsupportedFeatures() -> list of strings

        Returns a list of features from UNSUPPORTED that are present
        in the test configuration's features or target triple.
        Throws ValueError if an UNSUPPORTED line has a syntax error.
        """

        features = self.config.available_features
        triple = getattr(self.suite.config, 'target_triple', "")

        try:
            return [item for item in self.unsupported
                    if BooleanExpression.evaluate(item, features, triple)]
        except ValueError as e:
            raise ValueError('Error in UNSUPPORTED list:\n%s' % str(e))
Example #7
0
    def getUsedFeatures(self):
        """
        getUsedFeatures() -> list of strings

        Returns a list of all features appearing in XFAIL, UNSUPPORTED and
        REQUIRES annotations for this test.
        """
        import lit.TestRunner
        parsed = lit.TestRunner._parseKeywords(self.getSourcePath(),
                                               require_script=False)
        feature_keywords = ('UNSUPPORTED:', 'REQUIRES:', 'XFAIL:')
        boolean_expressions = itertools.chain.from_iterable(
            parsed[k] or [] for k in feature_keywords)
        tokens = itertools.chain.from_iterable(
            BooleanExpression.tokenize(expr) for expr in boolean_expressions
            if expr != '*')
        identifiers = set(filter(BooleanExpression.isIdentifier, tokens))
        return identifiers
Example #8
0
 def getMissingRequiredFeaturesFromList(self, features):
     try:
         return [item for item in self.requires
                 if not BooleanExpression.evaluate(item, features)]
     except ValueError as e:
         raise ValueError('Error in REQUIRES list:\n%s' % str(e))