<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 5, 2013 at 1:07 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Feb 5, 2013 at 1:03 PM, Daniel Dunbar <<a href="mailto:daniel@zuster.org">daniel@zuster.org</a>> wrote:<br>

> Author: ddunbar<br>
> Date: Tue Feb  5 15:03:25 2013<br>
> New Revision: 174440<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=174440&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=174440&view=rev</a><br>
> Log:<br>
> [tests] Add support for REQUIRES and XFAIL lines in libc++ tests.<br>
><br>
>  - We parse up to the first non-empty non-comment (C++ style) line, otherwise<br>
>    the format and semantics match what is used for LLVM/Clang tests.<br>
<br>
</div>Any particular reason for the difference?<br></blockquote><div><br></div><div style>Most tests don't have metadata and we don't have a legacy requirement, this saves parsing time.</div><div style><br></div>
<div style> - Daniel</div><div style><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
>  - For now, the only interesting thing to test against is a user supplied<br>
>    target_triple test parameter.<br>
><br>
> Modified:<br>
>     libcxx/trunk/test/lit.cfg<br>
><br>
> Modified: libcxx/trunk/test/lit.cfg<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=174440&r1=174439&r2=174440&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=174440&r1=174439&r2=174440&view=diff</a><br>

> ==============================================================================<br>
> --- libcxx/trunk/test/lit.cfg (original)<br>
> +++ libcxx/trunk/test/lit.cfg Tue Feb  5 15:03:25 2013<br>
> @@ -11,6 +11,26 @@ import subprocess<br>
>  import errno<br>
>  import time<br>
><br>
> +# FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a<br>
> +# dependency there. What we more ideally would like to do is lift the "xfail"<br>
> +# and "requires" handling to be a core lit framework feature.<br>
> +def isExpectedFail(test, xfails):<br>
> +    # Check if any of the xfails match an available feature or the target.<br>
> +    for item in xfails:<br>
> +        # If this is the wildcard, it always fails.<br>
> +        if item == '*':<br>
> +            return True<br>
> +<br>
> +        # If this is an exact match for one of the features, it fails.<br>
> +        if item in test.config.available_features:<br>
> +            return True<br>
> +<br>
> +        # If this is a part of the target triple, it fails.<br>
> +        if item in test.suite.config.target_triple:<br>
> +            return True<br>
> +<br>
> +    return False<br>
> +<br>
>  class LibcxxTestFormat(lit.formats.FileBasedTest):<br>
>      """<br>
>      Custom test format handler for use with the test format use by libc++.<br>
> @@ -55,6 +75,52 @@ class LibcxxTestFormat(lit.formats.FileB<br>
>                  time.sleep(0.1)<br>
><br>
>      def _execute(self, test, lit_config):<br>
> +        # Extract test metadata from the test file.<br>
> +        xfails = []<br>
> +        requires = []<br>
> +        with open(test.getSourcePath()) as f:<br>
> +            for ln in f:<br>
> +                if 'XFAIL:' in ln:<br>
> +                    items = ln[ln.index('XFAIL:') + 6:].split(',')<br>
> +                    xfails.extend([s.strip() for s in items])<br>
> +                elif 'REQUIRES:' in ln:<br>
> +                    items = ln[ln.index('REQUIRES:') + 9:].split(',')<br>
> +                    requires.extend([s.strip() for s in items])<br>
> +                elif not ln.startswith("//") and ln.strip():<br>
> +                    # Stop at the first non-empty line that is not a C++<br>
> +                    # comment.<br>
> +                    break<br>
> +<br>
> +        # Check that we have the required features.<br>
> +        #<br>
> +        # FIXME: For now, this is cribbed from lit.TestRunner, to avoid<br>
> +        # introducing a dependency there. What we more ideally would like to do<br>
> +        # is lift the "xfail" and "requires" handling to be a core lit framework<br>
> +        # feature.<br>
> +        missing_required_features = [f for f in requires<br>
> +                                     if f not in test.config.available_features]<br>
> +        if missing_required_features:<br>
> +            return (lit.Test.UNSUPPORTED,<br>
> +                    "Test requires the following features: %s" % (<br>
> +                      ', '.join(missing_required_features),))<br>
> +<br>
> +        # Determine if this test is an expected failure.<br>
> +        isXFail = isExpectedFail(test, xfails)<br>
> +<br>
> +        # Evaluate the test.<br>
> +        result, report = self._evaluate_test(test, lit_config)<br>
> +<br>
> +        # Convert the test result based on whether this is an expected failure.<br>
> +        if isXFail:<br>
> +            if result != lit.Test.FAIL:<br>
> +                report += "\n\nTest was expected to FAIL, but did not.\n"<br>
> +                result = lit.Test.XPASS<br>
> +            else:<br>
> +                result = lit.Test.XFAIL<br>
> +<br>
> +        return result, report<br>
> +<br>
> +    def _evaluate_test(self, test, lit_config):<br>
>          name = test.path_in_suite[-1]<br>
>          source_path = test.getSourcePath()<br>
>          source_dir = os.path.dirname(source_path)<br>
> @@ -210,4 +276,5 @@ config.test_format = LibcxxTestFormat(<br>
>      ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries,<br>
>      exec_env = exec_env)<br>
><br>
> -config.target_triple = None<br>
> +config.target_triple = lit.params.get(<br>
> +    'target_triple', 'unknown-unknown-unknown')<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>