[clang-tools-extra] [clang-doc] Refactor error handling to use ExitOnError (PR #141699)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Fri May 30 10:13:58 PDT 2025


================
@@ -0,0 +1,29 @@
+/// Invalid output path (%t is a file, not a directory).
+// RUN: rm -rf %t && touch %t
+// RUN: not clang-doc %s -output=%t/subdir 2>&1 | FileCheck %s
+// CHECK: clang-doc error:
+// CHECK: {{(Not a directory|no such file or directory)}}
+
+/// Invalid format option.
+// RUN: not clang-doc %s --output=%t.dir -format=badformat 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
+// BAD-FORMAT: clang-doc: for the --format option: Cannot find option named 'badformat'!
+
+/// Missing HTML asset directory (warning only).
+// RUN: clang-doc %s -format=html -asset=%t/nonexistent-assets 2>&1 | FileCheck %s --check-prefix=ASSET-WARN
+// ASSET-WARN: Asset path supply is not a directory
+// ASSET-WARN: falling back to default
+
+/// Mapping failure (with --ignore-map-errors=false).
+// RUN: not clang-doc %t/nonexistent.cpp -ignore-map-errors=false 2>&1 | FileCheck %s --check-prefix=MAP-FAIL
+// MAP-FAIL: clang-doc error: Failed to run action
+
+/// Mapping failure (with --ignore-map-errors=true).
+// RUN: clang-doc %t/nonexistent.cpp 2>&1 | FileCheck %s --check-prefix=MAP-WARN
+// MAP-WARN: Error mapping decls in files. Clang-doc will ignore these files and continue
+
+///Invalid executor type
+// RUN: not clang-doc --executor=invalid %s 2>&1 | FileCheck %s --check-prefix=EXECUTOR-FAIL
+// EXECUTOR-FAIL: clang-doc error:
+// EXECUTOR-FAIL: Executor "invalid" is not registered
----------------
ilovepi wrote:

hmm, unfortunate. Well, it was worth a shot. This should be fine for now.

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


More information about the cfe-commits mailing list