Fix unit_test fail doesn't result in error in CI (#270)

This commit is contained in:
ykiko
2025-10-03 14:50:38 +08:00
committed by GitHub
parent 9569988509
commit 4a184a26ce
6 changed files with 62 additions and 48 deletions

View File

@@ -205,10 +205,10 @@ struct DenseMapInfo<llvm::ArrayRef<const char*>> {
template <>
struct std::formatter<clice::CompilationDatabase::QueryDriverError> :
std::formatter<llvm::StringRef> {
std::formatter<std::string_view> {
template <typename FormatContext>
auto format(clice::CompilationDatabase::QueryDriverError& e, FormatContext& ctx) const {
auto format(const clice::CompilationDatabase::QueryDriverError& e, FormatContext& ctx) const {
return std::format_to(ctx.out(), "{} {}", e.kind.name(), e.detail);
}
};

View File

@@ -103,6 +103,7 @@ constexpr inline struct {
std::source_location location = std::source_location::current()) const {
bool failed = false;
std::string expression = "false";
std::string message;
if constexpr(is_expr_v<TExpr>) {
auto result = expr();
@@ -115,10 +116,20 @@ constexpr inline struct {
} else {
if(!static_cast<bool>(expr)) {
failed = true;
if constexpr(requires { expr.error(); }) {
message = std::format("{}", expr.error());
}
}
}
return may_failure{failed, false, expression, location};
return may_failure{
failed,
false,
std::move(expression),
location,
std::move(message),
};
}
} expect;