diff options
| author | Reid Kleckner <rnk@google.com> | 2017-07-28 01:05:55 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2017-07-28 01:05:55 +0000 |
| commit | 4ca8d21ef371fc7caacd32fbd6af81dfea3f23c9 (patch) | |
| tree | 7b2d8595cb0c0f676a0bfd75422ef30681a74dab /llvm/utils | |
| parent | e70a472bad63666ce16a68947352806d07294015 (diff) | |
| download | bcm5719-llvm-4ca8d21ef371fc7caacd32fbd6af81dfea3f23c9.tar.gz bcm5719-llvm-4ca8d21ef371fc7caacd32fbd6af81dfea3f23c9.zip | |
[lit] Port googletest lit tests to Windows
Summary:
The technique of directly calling subprocess.Popen on a python script
doesn't work on Windows. The executable path of the command must refer
to a valid win32 executable.
Instead, rename all the python scripts masquerading as gtest executables
to have .py extensions, so we can easily detect then and call the python
executable for them. Do this on Linux as well as Windows for
consistency.
The test suite directory names also come out in lower-case on Windows.
We can consider removing that in a later patch. This change just updates
the FileCheck lines to match on Windows.
Fixes PR33933
Reviewers: modocache, mgorny
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D35909
llvm-svn: 309347
Diffstat (limited to 'llvm/utils')
| -rw-r--r-- | llvm/utils/lit/lit/formats/googletest.py | 25 | ||||
| -rw-r--r--[-rwxr-xr-x] | llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest.py (renamed from llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest) | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest.py (renamed from llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest) | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py (renamed from llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest) | 0 | ||||
| -rw-r--r-- | llvm/utils/lit/tests/googletest-format.py | 13 | ||||
| -rw-r--r-- | llvm/utils/lit/tests/googletest-timeout.py | 9 | ||||
| -rw-r--r-- | llvm/utils/lit/tests/googletest-upstream-format.py | 13 |
7 files changed, 34 insertions, 26 deletions
diff --git a/llvm/utils/lit/lit/formats/googletest.py b/llvm/utils/lit/lit/formats/googletest.py index 9c55e71d233..6696fabc4f5 100644 --- a/llvm/utils/lit/lit/formats/googletest.py +++ b/llvm/utils/lit/lit/formats/googletest.py @@ -13,11 +13,14 @@ kIsWindows = sys.platform in ['win32', 'cygwin'] class GoogleTest(TestFormat): def __init__(self, test_sub_dirs, test_suffix): self.test_sub_dirs = os.path.normcase(str(test_sub_dirs)).split(';') - self.test_suffix = str(test_suffix) # On Windows, assume tests will also end in '.exe'. + exe_suffix = str(test_suffix) if kIsWindows: - self.test_suffix += '.exe' + exe_suffix += '.exe' + + # Also check for .py files for testing purposes. + self.test_suffixes = {exe_suffix, test_suffix + '.py'} def getGTestTests(self, path, litConfig, localConfig): """getGTestTests(path) - [name] @@ -29,8 +32,10 @@ class GoogleTest(TestFormat): litConfig: LitConfig instance localConfig: TestingConfig instance""" + list_test_cmd = self.maybeAddPythonToCmd([path, '--gtest_list_tests']) + try: - output = subprocess.check_output([path, '--gtest_list_tests'], + output = subprocess.check_output(list_test_cmd, env=localConfig.environment) except subprocess.CalledProcessError as exc: litConfig.warning( @@ -82,7 +87,7 @@ class GoogleTest(TestFormat): if not os.path.isdir(dir_path): continue for fn in lit.util.listdir_files(dir_path, - suffixes={self.test_suffix}): + suffixes=self.test_suffixes): # Discover the tests in this executable. execpath = os.path.join(source_path, subdir, fn) testnames = self.getGTestTests(execpath, litConfig, localConfig) @@ -100,6 +105,7 @@ class GoogleTest(TestFormat): testName = namePrefix + '/' + testName cmd = [testPath, '--gtest_filter=' + testName] + cmd = self.maybeAddPythonToCmd(cmd) if litConfig.useValgrind: cmd = litConfig.valgrindArgs + cmd @@ -126,3 +132,14 @@ class GoogleTest(TestFormat): return lit.Test.UNRESOLVED, msg return lit.Test.PASS,'' + + def maybeAddPythonToCmd(self, cmd): + """Insert the python exe into the command if cmd[0] ends in .py + + We cannot rely on the system to interpret shebang lines for us on + Windows, so add the python executable to the command if this is a .py + script. + """ + if cmd[0].endswith('.py'): + return [sys.executable] + cmd + return cmd diff --git a/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest b/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest.py index dd49f025b1f..dd49f025b1f 100755..100644 --- a/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest +++ b/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest.py diff --git a/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest b/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest.py index f3a90ff4cd6..f3a90ff4cd6 100755..100644 --- a/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest +++ b/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest.py diff --git a/llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest b/llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py index d7bc5968f26..d7bc5968f26 100755..100644 --- a/llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest +++ b/llvm/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py diff --git a/llvm/utils/lit/tests/googletest-format.py b/llvm/utils/lit/tests/googletest-format.py index a8e96d9695a..be25c66e92b 100644 --- a/llvm/utils/lit/tests/googletest-format.py +++ b/llvm/utils/lit/tests/googletest-format.py @@ -1,22 +1,19 @@ # Check the various features of the GoogleTest format. # -# PR33933 -# XFAIL: windows -# # RUN: not %{lit} -j 1 -v %{inputs}/googletest-format > %t.out # RUN: FileCheck < %t.out %s # # END. # CHECK: -- Testing: -# CHECK: PASS: googletest-format :: DummySubDir/OneTest/FirstTest.subTestA -# CHECK: FAIL: googletest-format :: DummySubDir/OneTest/FirstTest.subTestB -# CHECK-NEXT: *** TEST 'googletest-format :: DummySubDir/OneTest/FirstTest.subTestB' FAILED *** +# CHECK: PASS: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestA +# CHECK: FAIL: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB +# CHECK-NEXT: *** TEST 'googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB' FAILED *** # CHECK-NEXT: I am subTest B, I FAIL # CHECK-NEXT: And I have two lines of output # CHECK: *** -# CHECK: PASS: googletest-format :: DummySubDir/OneTest/ParameterizedTest/0.subTest -# CHECK: PASS: googletest-format :: DummySubDir/OneTest/ParameterizedTest/1.subTest +# CHECK: PASS: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/0.subTest +# CHECK: PASS: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/1.subTest # CHECK: Failing Tests (1) # CHECK: Expected Passes : 3 # CHECK: Unexpected Failures: 1 diff --git a/llvm/utils/lit/tests/googletest-timeout.py b/llvm/utils/lit/tests/googletest-timeout.py index 7d5721ea3d1..8b7d10fc1f0 100644 --- a/llvm/utils/lit/tests/googletest-timeout.py +++ b/llvm/utils/lit/tests/googletest-timeout.py @@ -1,8 +1,5 @@ # REQUIRES: python-psutil -# PR33934 -# XFAIL: windows - # Check that the per test timeout is enforced when running GTest tests. # # RUN: not %{lit} -j 1 -v %{inputs}/googletest-timeout --timeout=1 > %t.cmd.out @@ -16,9 +13,9 @@ # RUN: FileCheck < %t.cfgset.out %s # CHECK: -- Testing: -# CHECK: PASS: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestA -# CHECK: TIMEOUT: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestB -# CHECK: TIMEOUT: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestC +# CHECK: PASS: googletest-timeout :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestA +# CHECK: TIMEOUT: googletest-timeout :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB +# CHECK: TIMEOUT: googletest-timeout :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestC # CHECK: Expected Passes : 1 # CHECK: Individual Timeouts: 2 diff --git a/llvm/utils/lit/tests/googletest-upstream-format.py b/llvm/utils/lit/tests/googletest-upstream-format.py index 425b528aaeb..938740d80e7 100644 --- a/llvm/utils/lit/tests/googletest-upstream-format.py +++ b/llvm/utils/lit/tests/googletest-upstream-format.py @@ -1,23 +1,20 @@ # Check the various features of the GoogleTest format. # -# PR33935 -# XFAIL: windows -# # RUN: not %{lit} -j 1 -v %{inputs}/googletest-upstream-format > %t.out # RUN: FileCheck < %t.out %s # # END. # CHECK: -- Testing: -# CHECK: PASS: googletest-upstream-format :: DummySubDir/OneTest/FirstTest.subTestA -# CHECK: FAIL: googletest-upstream-format :: DummySubDir/OneTest/FirstTest.subTestB -# CHECK-NEXT: *** TEST 'googletest-upstream-format :: DummySubDir/OneTest/FirstTest.subTestB' FAILED *** +# CHECK: PASS: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestA +# CHECK: FAIL: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB +# CHECK-NEXT: *** TEST 'googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB' FAILED *** # CHECK-NEXT: Running main() from gtest_main.cc # CHECK-NEXT: I am subTest B, I FAIL # CHECK-NEXT: And I have two lines of output # CHECK: *** -# CHECK: PASS: googletest-upstream-format :: DummySubDir/OneTest/ParameterizedTest/0.subTest -# CHECK: PASS: googletest-upstream-format :: DummySubDir/OneTest/ParameterizedTest/1.subTest +# CHECK: PASS: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/0.subTest +# CHECK: PASS: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/1.subTest # CHECK: Failing Tests (1) # CHECK: Expected Passes : 3 # CHECK: Unexpected Failures: 1 |

