[clang-tools-extra] [clang-doc] Refactor error handling to use ExitOnError (PR #141699)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Thu May 29 20:29:52 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:
There are other ways to make the executor fail besides passing a bad executor flag. I'm pretty sure passing extra args is one way. Can you try this test with some nonese compiler flags passed through --extra_args (or whatever name we use...)? That may give us a nicer signal, and trigger the ExitOnError code in the tool.
https://github.com/llvm/llvm-project/pull/141699
More information about the cfe-commits
mailing list