[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 18:16:17 PDT 2024


================
@@ -0,0 +1,274 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/index_json.js -check-prefix=JSON-INDEX
+// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX
+// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.html -check-prefix=HTML-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html -check-prefix=HTML-NESTED-CLASS
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.html -check-prefix=HTML-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX
+// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.md -check-prefix=MD-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md -check-prefix=MD-NESTED-CLASS
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
+// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
+
+// MD-ANON-INDEX: # namespace @nonymous_namespace
+// MD-ANON-INDEX:  Anonymous Namespace
+// MD-ANON-INDEX: ## Records
+// MD-ANON-INDEX: * [AnonClass](AnonClass.md)
+// MD-ANON-INDEX: ## Functions
+// MD-ANON-INDEX: ### anonFunction
+// MD-ANON-INDEX: *void anonFunction()*
+// MD-ANON-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE+15]]*
+
+// HTML-ANON-INDEX: <h1>namespace @nonymous_namespace</h1>
+// HTML-ANON-INDEX: <p> Anonymous Namespace</p>
+// HTML-ANON-INDEX: <h2 id="Records">Records</h2>
+// HTML-ANON-INDEX: <a href="AnonClass.html">AnonClass</a>
+// HTML-ANON-INDEX: <h2 id="Functions">Functions</h2>
+// HTML-ANON-INDEX: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3>
+// HTML-ANON-INDEX: <p>void anonFunction()</p>
+// HTML-ANON-INDEX: <p>Defined at line [[@LINE+6]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
----------------
ilovepi wrote:

As mentioned in your other PR, lets check these right after the line they're checking, and use a `*-LINE` tag to check these w/ `--check-prefixes`.  That should prevent instability in the test due to more test checks getting added. Once that's done for all these tests, this will probably be good to go, modulo some nits.

https://github.com/llvm/llvm-project/pull/97681


More information about the cfe-commits mailing list