[lit] Fix tests on Windows
authorJulian Lettner <julian.lettner@apple.com>
Sat, 11 Apr 2020 00:12:54 +0000 (17:12 -0700)
committerJulian Lettner <julian.lettner@apple.com>
Sat, 11 Apr 2020 00:33:49 +0000 (17:33 -0700)
max-time.py:
  Windows does not have a native `sleep` command, use `time.sleep()` in
  Python instead.

max-failures.py:
  The max-failure test reused the shtest-shell test inputs instead of
  defining its own "test domain".  However, the output of this
  shtest-shell "test domain" is slightly different on Windows, which now
  bites us since we made the max-failures test stricter.  Let's define
  our own "max failures" test domain.

llvm/utils/lit/tests/Inputs/max-failures/fail1.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/max-failures/fail2.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/max-failures/fail3.txt [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/max-failures/lit.cfg
llvm/utils/lit/tests/Inputs/max-time/lit.cfg
llvm/utils/lit/tests/Inputs/max-time/slow.py [new file with mode: 0644]
llvm/utils/lit/tests/Inputs/max-time/slow.txt [deleted file]
llvm/utils/lit/tests/max-failures.py

diff --git a/llvm/utils/lit/tests/Inputs/max-failures/fail1.txt b/llvm/utils/lit/tests/Inputs/max-failures/fail1.txt
new file mode 100644 (file)
index 0000000..15eb81a
--- /dev/null
@@ -0,0 +1 @@
+RUN: false
diff --git a/llvm/utils/lit/tests/Inputs/max-failures/fail2.txt b/llvm/utils/lit/tests/Inputs/max-failures/fail2.txt
new file mode 100644 (file)
index 0000000..15eb81a
--- /dev/null
@@ -0,0 +1 @@
+RUN: false
diff --git a/llvm/utils/lit/tests/Inputs/max-failures/fail3.txt b/llvm/utils/lit/tests/Inputs/max-failures/fail3.txt
new file mode 100644 (file)
index 0000000..15eb81a
--- /dev/null
@@ -0,0 +1 @@
+RUN: false
index 605bd72..f0f7649 100644 (file)
@@ -1,2 +1,6 @@
-lit_config.load_config(config, os.path.dirname(__file__) + "/../shtest-shell/lit.cfg")
-config.test_source_root = os.path.dirname(__file__) + '/../shtest-shell'
+import lit.formats
+config.name = 'max-failures'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
index 724adfe..0178445 100644 (file)
@@ -1,6 +1,7 @@
 import lit.formats
-config.name = 'lit-time'
-config.suffixes = ['.txt']
+config.name = 'max-time'
+config.suffixes = ['.txt', '.py']
 config.test_format = lit.formats.ShTest()
 config.test_source_root = None
 config.test_exec_root = None
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/max-time/slow.py b/llvm/utils/lit/tests/Inputs/max-time/slow.py
new file mode 100644 (file)
index 0000000..ca4d5d3
--- /dev/null
@@ -0,0 +1,7 @@
+# 'sleep 60' in Python because Windows does not have a native sleep command.
+#
+# RUN: %{python} %s
+
+import time
+
+time.sleep(60)
diff --git a/llvm/utils/lit/tests/Inputs/max-time/slow.txt b/llvm/utils/lit/tests/Inputs/max-time/slow.txt
deleted file mode 100644 (file)
index 6127504..0000000
+++ /dev/null
@@ -1 +0,0 @@
-RUN: sleep 60
index cdfe546..4d4c897 100644 (file)
@@ -6,18 +6,17 @@
 # RUN: not %{lit} --max-failures=0 -j 1 %{inputs}/max-failures 2>> %t.out
 # RUN: FileCheck < %t.out %s
 #
-# END.
 
 # CHECK-NOT: reached maximum number of test failures
 # CHECK-NOT: Skipped Tests
-# CHECK: Unexpected Failures: 35
+# CHECK: Unexpected Failures: 3
 
 # CHECK: reached maximum number of test failures, skipping remaining tests
-# CHECK: Skipped Tests      : 41
-# CHECK: Unexpected Failures:  1
+# CHECK: Skipped Tests      : 2
+# CHECK: Unexpected Failures: 1
 
 # CHECK: reached maximum number of test failures, skipping remaining tests
-# CHECK: Skipped Tests      : 40
-# CHECK: Unexpected Failures:  2
+# CHECK: Skipped Tests      : 1
+# CHECK: Unexpected Failures: 2
 
 # CHECK: error: argument --max-failures: requires positive integer, but found '0'