[PATCH] [LIT] Add SuffixDispatchTest for use in libc++ and libc++abi tests.

Jonathan Roelofs jonathan at codesourcery.com
Thu Nov 13 12:15:34 PST 2014


================
Comment at: utils/lit/lit/formats/suffixdispatchtest.py:106
@@ +105,3 @@
+        test_runner = None
+        for suffix_test in self.suffix_tests:
+            if name.endswith(suffix_test[0]):
----------------
danalbert wrote:
> danalbert wrote:
> > EricWF wrote:
> > > danalbert wrote:
> > > > EricWF wrote:
> > > > > jroelofs wrote:
> > > > > > I think you can do this in python....
> > > > > > 
> > > > > >   for (suffix, test) in self.suffix_tests:
> > > > > >     if name.endswith(suffix):
> > > > > >       test_runner = test
> > > > > >       break
> > > > > Cool! That's so much cleaner. Thanks.
> > > > You wanted a dict.
> > > > 
> > > >     test_runners = {
> > > >         ".pass": PassRunner(),
> > > >         ".fail": FailRunner()
> > > >     }
> > > > 
> > > > This block would become `test_runner = test_runners[suffix]`.
> > > I disagree. The problem is that I don't know how to split the filename into name + suffix. For example a `test.fail.cpp`. How do you know where to split the test name?
> > What's wrong with `testname.split('.')[-2]`?
> > jroelofs: That assumes test suffixes have at most two '.'s in them...
> 
> No, it assumes it has at _least_ that many. Given `'foo.bar.baz.buzz.qux.cpp'`, this will still choose `qux`, which aiui is the desired behavior (and lets us move to a data structure that actually cleanly represents this data).
What I really meant is that this limits us to test suffixes with at most two '.'s in them. I.e. given `foo.bar.baz.buzz.qux.cpp`, then this wouldn't work:

```
test_format.add_suffix_test('.buzz.qux.cpp', FailTestHandler(...))
```

================
Comment at: utils/lit/lit/util.py:159
@@ -158,3 +172,1 @@
 
-    def to_string(bytes):
-        if isinstance(bytes, str):
----------------
danalbert wrote:
> Oh, I see it wasn't you that added it. Still confused that we needed it...
Uhgreed.

http://reviews.llvm.org/D6206






More information about the llvm-commits mailing list