[libcxx-commits] [libcxx] 35bbf3b - [libc++] Add .verify.cpp tests to the new format

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 14 11:50:13 PDT 2020


Author: Louis Dionne
Date: 2020-04-14T14:49:51-04:00
New Revision: 35bbf3bb7168a3d8062500b63af87079f6519794

URL: https://github.com/llvm/llvm-project/commit/35bbf3bb7168a3d8062500b63af87079f6519794
DIFF: https://github.com/llvm/llvm-project/commit/35bbf3bb7168a3d8062500b63af87079f6519794.diff

LOG: [libc++] Add .verify.cpp tests to the new format

With this patch, .verify.cpp tests explicitly require clang-verify, but
no other test types require clang-verify out of the box. This will allow
making several .fail.cpp tests that don't have any clang-verify markup
to be just .compile.fail.cpp tests, which in turn should allow removing
a long standing workaround that requires parsing tests to detect whether
they have any clang-verify markup in them.

Added: 
    libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics-unmarked.verify.cpp
    libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics.verify.cpp
    libcxx/test/libcxx/selftest/newformat/verify.cpp/right-diagnostic.verify.cpp
    libcxx/test/libcxx/selftest/newformat/verify.cpp/wrong-diagnostic.verify.cpp

Modified: 
    libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/compile-error.compile.fail.cpp
    libcxx/utils/libcxx/test/newformat.py

Removed: 
    libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/wrong-expected.compile.fail.cpp


################################################################################
diff  --git a/libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/compile-error.compile.fail.cpp b/libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/compile-error.compile.fail.cpp
index e54b8572a3ff..bd1e0af8d639 100644
--- a/libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/compile-error.compile.fail.cpp
+++ b/libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/compile-error.compile.fail.cpp
@@ -6,11 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: verify-support
-
 // Make sure the test passes if it fails at compile-time
 
 struct Foo { };
-typedef Foo::x x; // expected-error{{no type named 'x' in 'Foo'}}
+typedef Foo::x x;
 
 int main() { }

diff  --git a/libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics-unmarked.verify.cpp b/libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics-unmarked.verify.cpp
new file mode 100644
index 000000000000..e0ca921f3438
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics-unmarked.verify.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: verify-support
+
+// XFAIL: *
+
+// Make sure the test DOES NOT pass if there are no diagnostics, but we didn't
+// use the 'expected-no-diagnostics' markup.
+//
+// Note: For the purpose of this test, make sure the file would otherwise
+//       compile to make sure we really fail due to a lack of markup.
+
+int main() { }

diff  --git a/libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics.verify.cpp b/libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics.verify.cpp
new file mode 100644
index 000000000000..1f6124cf8dd9
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/newformat/verify.cpp/no-diagnostics.verify.cpp
@@ -0,0 +1,13 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: verify-support
+
+// Make sure the test passes if we expected no diagnostics
+
+// expected-no-diagnostics

diff  --git a/libcxx/test/libcxx/selftest/newformat/verify.cpp/right-diagnostic.verify.cpp b/libcxx/test/libcxx/selftest/newformat/verify.cpp/right-diagnostic.verify.cpp
new file mode 100644
index 000000000000..d3afd9745761
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/newformat/verify.cpp/right-diagnostic.verify.cpp
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: verify-support
+
+// Make sure the test passes if the expected diagnostic is correct.
+
+struct Foo { };
+typedef Foo::x x; // expected-error{{no type named 'x' in 'Foo'}}

diff  --git a/libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/wrong-expected.compile.fail.cpp b/libcxx/test/libcxx/selftest/newformat/verify.cpp/wrong-diagnostic.verify.cpp
similarity index 80%
rename from libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/wrong-expected.compile.fail.cpp
rename to libcxx/test/libcxx/selftest/newformat/verify.cpp/wrong-diagnostic.verify.cpp
index 8b02098e4c73..02f9353cf18a 100644
--- a/libcxx/test/libcxx/selftest/newformat/compile.fail.cpp/wrong-expected.compile.fail.cpp
+++ b/libcxx/test/libcxx/selftest/newformat/verify.cpp/wrong-diagnostic.verify.cpp
@@ -6,12 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+// REQUIRES: verify-support
+
 // XFAIL: *
 
-// Make sure the test DOES NOT pass if it fails at compile-time, but the
-// expected-error is wrong.
+// Make sure the test DOES NOT pass if the expected diagnostic is wrong.
 
 struct Foo { };
 typedef Foo::x x; // expected-error{{this is not found in the errors}}
-
-int main() { }

diff  --git a/libcxx/utils/libcxx/test/newformat.py b/libcxx/utils/libcxx/test/newformat.py
index 88aa29fbb2d5..5abfde5a8d58 100644
--- a/libcxx/utils/libcxx/test/newformat.py
+++ b/libcxx/utils/libcxx/test/newformat.py
@@ -24,8 +24,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
     FOO.run.fail.cpp        - Compiles and links successfully, but fails at runtime
 
     FOO.compile.pass.cpp    - Compiles successfully, link and run not attempted
-    FOO.compile.fail.cpp    - Does not compile successfully. These tests run with
-                              clang-verify.
+    FOO.compile.fail.cpp    - Does not compile successfully
 
     FOO.link.pass.cpp       - Compiles and links successfully, run not attempted
     FOO.link.fail.cpp       - Compiles successfully, but fails to link
@@ -33,6 +32,8 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
     FOO.sh.cpp              - A builtin lit Shell test
     FOO.sh.s                - A builtin lit Shell test
 
+    FOO.verify.cpp          - Compiles with clang-verify
+
     FOO.fail.cpp            - Does not compile successfully -- run with clang-verify
                               if any expected-meow appears in the file, otherwise
                               just test that compilation fails. This is supported
@@ -77,7 +78,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
 
     Design note:
     This test format never implicitly disables a type of test. For example,
-    we could be tempted to automatically mark `.compile.fail.cpp` tests as
+    we could be tempted to automatically mark `.verify.cpp` tests as
     UNSUPPORTED when clang-verify isn't supported by the compiler. However,
     this sort of logic has been known to cause tests to be ignored in the
     past, so we favour having tests mark themselves as unsupported explicitly.
@@ -86,11 +87,11 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
         - It is unknown how well it works on Windows yet.
     """
     def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
-        SUPPORTED_SUFFIXES = ['.pass.cpp', '.run.fail.cpp',
-                              '.pass.mm',
+        SUPPORTED_SUFFIXES = ['.pass.cpp', '.pass.mm', '.run.fail.cpp',
                               '.compile.pass.cpp', '.compile.fail.cpp',
                               '.link.pass.cpp', '.link.fail.cpp',
                               '.sh.cpp', '.sh.s',
+                              '.verify.cpp',
                               '.fail.cpp']
         sourcePath = testSuite.getSourcePath(pathInSuite)
         for filename in os.listdir(sourcePath):
@@ -156,7 +157,7 @@ def execute(self, test, litConfig):
             return self._executeShTest(test, litConfig, steps)
         elif filename.endswith('.compile.fail.cpp'):
             steps = [
-                "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
+                "%dbg(COMPILED WITH) ! %{cxx} %s %{flags} %{compile_flags} -fsyntax-only"
             ]
             return self._executeShTest(test, litConfig, steps)
         elif filename.endswith('.link.pass.cpp'):
@@ -176,6 +177,11 @@ def execute(self, test, litConfig):
                 "%dbg(EXECUTED AS) %{exec} ! %t.exe"
             ]
             return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
+        elif filename.endswith('.verify.cpp'):
+            steps = [
+                "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
+            ]
+            return self._executeShTest(test, litConfig, steps)
         # Make sure to check these ones last, since they will match other
         # suffixes above too.
         elif filename.endswith('.pass.cpp') or filename.endswith('.pass.mm'):
@@ -184,8 +190,9 @@ def execute(self, test, litConfig):
                 "%dbg(EXECUTED AS) %{exec} %t.exe"
             ]
             return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
-        # This is the same as .compile.fail.cpp, provided for backwards
-        # compatibility with the test suite.
+        # This is like a .verify.cpp test when clang-verify is supported,
+        # otherwise it's like a .compile.fail.cpp test. This is only provided
+        # for backwards compatibility with the test suite.
         elif filename.endswith('.fail.cpp'):
             if self._useVerify(test, litConfig):
                 steps = [


        


More information about the libcxx-commits mailing list