[PATCH] D18647: [lit][googletest] Don't choke on non-executables

Brian Gesiak via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 08:09:45 PDT 2016


modocache created this revision.
modocache added reviewers: ddunbar, abdulras.
modocache added subscribers: llvm-commits, kastiglione.

lit is usually forgiving when it comes to files that aren't tests, but
happen to match the test suffix being searched for. For example, even if I
specify a suffix of ".py", lit will not fail the test suite if it finds
a Python file that doesn't contain any lit commands.

lit's googletest format, on the other hand, is not as forgiving. If a
normal, non-executable file matching the test suffix is found, lit
attempts to execute it:

```
NotATest --gtest_list_tests
```

This fails, and causes lit to fail the test suite.

To mirror the lit's lenient behavior with other test formats, instead
of failing the test, have lit simply emit a warning instead. Add a test
that verifies the new behavior.

http://reviews.llvm.org/D18647

Files:
  utils/lit/lit/formats/googletest.py
  utils/lit/tests/Inputs/googletest-format/DummySubDir/NotAGoogleTest

Index: utils/lit/tests/Inputs/googletest-format/DummySubDir/NotAGoogleTest
===================================================================
--- /dev/null
+++ utils/lit/tests/Inputs/googletest-format/DummySubDir/NotAGoogleTest
@@ -0,0 +1,3 @@
+This file is not an executable, but it happens to have the same test suffix as
+as the googletest executables in this directory. lit should emit a warning in
+this case, but it should not fail the test suite.
Index: utils/lit/lit/formats/googletest.py
===================================================================
--- utils/lit/lit/formats/googletest.py
+++ utils/lit/lit/formats/googletest.py
@@ -35,8 +35,8 @@
               lines = lines.replace('\r', '')
             lines = lines.split('\n')
         except:
-            litConfig.error("unable to discover google-tests in %r" % path)
-            raise StopIteration
+            litConfig.warning("unable to discover google-tests in %r" % path)
+            lines = []
 
         nested_tests = []
         for ln in lines:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18647.52210.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160331/9467a43c/attachment.bin>


More information about the llvm-commits mailing list