[llvm-commits] [llvm] r97726 - in /llvm/trunk: test/lit.cfg utils/lit/lit/TestRunner.py utils/lit/lit/TestingConfig.py

Daniel Dunbar daniel at zuster.org
Thu Mar 4 05:13:49 PST 2010


Hi John,

I'm not sure I like this change. Do we really need this level of complexity?

It would be more in keeping with the current style to just have something like
   // REQUIRES: keyword1, keyword2, ...

There are also stylistic arguments against allowing conditional
functionality in tests. It is nice to say "foo passed" or "foo
failed", but if you allow parts of a test to be conditional then you
need to say "foo passed with options bla"...

 - Daniel

On Thu, Mar 4, 2010 at 1:36 AM, John McCall <rjmccall at apple.com> wrote:
> Author: rjmccall
> Date: Thu Mar  4 03:36:50 2010
> New Revision: 97726
>
> URL: http://llvm.org/viewvc/llvm-project?rev=97726&view=rev
> Log:
> Teach lit to honor conditional directives.  The syntax is:
>  IF(condition(value)):
> If the value satisfies the condition, the line is processed by lit;  otherwise
> it is skipped.  A test with no unignored directives is resolved as Unsupported.
>
> The test suite is responsible for defining conditions;  conditions are unary
> functions over strings.  I've defined two conditions in the LLVM test suite,
> TARGET (with values like those in TARGETS_TO_BUILD) and BINDING (with values
> like those in llvm_bindings).  So for example you can write:
>  IF(BINDING(ocaml)): RUN: %blah %s -o -
> and the RUN line will only execute if LLVM was configured with the ocaml
> bindings.
>
>
> Modified:
>    llvm/trunk/test/lit.cfg
>    llvm/trunk/utils/lit/lit/TestRunner.py
>    llvm/trunk/utils/lit/lit/TestingConfig.py
>
> Modified: llvm/trunk/test/lit.cfg
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=97726&r1=97725&r2=97726&view=diff
> ==============================================================================
> --- llvm/trunk/test/lit.cfg (original)
> +++ llvm/trunk/test/lit.cfg Thu Mar  4 03:36:50 2010
> @@ -144,6 +144,9 @@
>  def llvm_supports_binding(name):
>     return name in bindings
>
> +config.conditions["TARGET"] = llvm_supports_target
> +config.conditions["BINDING"] = llvm_supports_binding
> +
>  # Provide on_clone hook for reading 'dg.exp'.
>  import os
>  simpleLibData = re.compile(r"""load_lib llvm.exp
>
> Modified: llvm/trunk/utils/lit/lit/TestRunner.py
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=97726&r1=97725&r2=97726&view=diff
> ==============================================================================
> --- llvm/trunk/utils/lit/lit/TestRunner.py (original)
> +++ llvm/trunk/utils/lit/lit/TestRunner.py Thu Mar  4 03:36:50 2010
> @@ -385,7 +385,30 @@
>     script = []
>     xfails = []
>     xtargets = []
> +    ignoredAny = False
>     for ln in open(sourcepath):
> +        if 'IF(' in ln:
> +            # Required syntax here is IF(condition(value)):
> +            index = ln.index('IF(')
> +            ln = ln[index+3:]
> +            index = ln.index('(')
> +            if index is -1:
> +                return (Test.UNRESOLVED, "ill-formed IF at '"+ln[:10]+"'")
> +            condition = ln[:index]
> +            ln = ln[index+1:]
> +            index = ln.index(')')
> +            if index is -1 or ln[index:index+3] != ')):':
> +                return (Test.UNRESOLVED, "ill-formed IF at '"+ln[:10]+"'")
> +            value = ln[:index]
> +            ln = ln[index+3:]
> +
> +            # Actually test the condition.
> +            if condition not in test.config.conditions:
> +                return (Test.UNRESOLVED, "unknown condition '"+condition+"'")
> +            if not test.config.conditions[condition](value):
> +                ignoredAny = True
> +                continue
> +
>         if 'RUN:' in ln:
>             # Isolate the command to run.
>             index = ln.index('RUN:')
> @@ -422,6 +445,8 @@
>
>     # Verify the script contains a run line.
>     if not script:
> +        if ignoredAny:
> +            return (Test.UNSUPPORTED, "Test has only ignored run lines")
>         return (Test.UNRESOLVED, "Test has no run line!")
>
>     if script[-1][-1] == '\\':
>
> Modified: llvm/trunk/utils/lit/lit/TestingConfig.py
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestingConfig.py?rev=97726&r1=97725&r2=97726&view=diff
> ==============================================================================
> --- llvm/trunk/utils/lit/lit/TestingConfig.py (original)
> +++ llvm/trunk/utils/lit/lit/TestingConfig.py Thu Mar  4 03:36:50 2010
> @@ -27,7 +27,8 @@
>                                    on_clone = None,
>                                    test_exec_root = None,
>                                    test_source_root = None,
> -                                   excludes = [])
> +                                   excludes = [],
> +                                   conditions = {})
>
>         if os.path.exists(path):
>             # FIXME: Improve detection and error reporting of errors in the
> @@ -53,7 +54,7 @@
>
>     def __init__(self, parent, name, suffixes, test_format,
>                  environment, substitutions, unsupported, on_clone,
> -                 test_exec_root, test_source_root, excludes):
> +                 test_exec_root, test_source_root, excludes, conditions):
>         self.parent = parent
>         self.name = str(name)
>         self.suffixes = set(suffixes)
> @@ -65,6 +66,7 @@
>         self.test_exec_root = test_exec_root
>         self.test_source_root = test_source_root
>         self.excludes = set(excludes)
> +        self.conditions = dict(conditions)
>
>     def clone(self, path):
>         # FIXME: Chain implementations?
> @@ -74,7 +76,7 @@
>                             self.environment, self.substitutions,
>                             self.unsupported, self.on_clone,
>                             self.test_exec_root, self.test_source_root,
> -                            self.excludes)
> +                            self.excludes, self.conditions)
>         if cfg.on_clone:
>             cfg.on_clone(self, cfg, path)
>         return cfg
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list