[clang-tools-extra] [clang-doc] [test] Generalize error message patterns (PR #142373)

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 2 05:28:46 PDT 2025


https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/142373

On Windows, we hit the "no such file or directory" case, not the "Not a directory" one.

MS STL produces the "no such file or directory" message for `std::error_code(ENOENT, std::generic_category()).message()`, while libc++ and libstdc++ produce a similar message with a capital N.

Adjust the error message regex to match for either of them.

That said, this kind of test is very brittle with respect to portability.

>From 0689e9e08aa604fb2bd27228b0c97b985f271723 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Mon, 2 Jun 2025 15:13:44 +0300
Subject: [PATCH] [clang-doc] [test] Generalize error message patterns

On Windows, we hit the "no such file or directory" case, not the
"Not a directory" one.

MS STL produces the "no such file or directory" message for
`std::error_code(ENOENT, std::generic_category()).message()`,
while libc++ and libstdc++ produce a similar message with a capital
N.

Adjust the error message regex to match for either of them.

That said, this kind of test is very brittle with respect to
portability.
---
 clang-tools-extra/test/clang-doc/invalid-options.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/invalid-options.cpp b/clang-tools-extra/test/clang-doc/invalid-options.cpp
index c8a4cef8364eb..59a0944718e31 100644
--- a/clang-tools-extra/test/clang-doc/invalid-options.cpp
+++ b/clang-tools-extra/test/clang-doc/invalid-options.cpp
@@ -2,7 +2,7 @@
 // RUN: rm -rf %t && touch %t
 // RUN: not clang-doc %s -output=%t/subdir 2>&1 | FileCheck %s --check-prefix=OUTPUT-FAIL
 // OUTPUT-FAIL: clang-doc error:
-// OUTPUT-FAIL: {{(Not a directory|no such file or directory)}}
+// OUTPUT-FAIL: {{(Not a directory|[Nn]o such file or directory)}}
 
 /// Invalid format option.
 // RUN: rm -rf %t && mkdir %t && touch %t/file



More information about the cfe-commits mailing list