[llvm-bugs] [Bug 49557] New: StencilTest.cpp has an un-executed EXPECT_THAT test

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 12 07:25:24 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49557

            Bug ID: 49557
           Summary: StencilTest.cpp has an un-executed EXPECT_THAT test
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Tooling
          Assignee: unassignedclangbugs at nondot.org
          Reporter: paul_robinson at playstation.sony.com
                CC: llvm-bugs at lists.llvm.org

clang/unittests/Tooling/StencilTest.cpp has a test "CatOfInvalidRangeFails"
that ends with this code:

  Expected<std::string> Result = S->eval(StmtMatch->Result);
  ASSERT_THAT_EXPECTED(Result, Failed<StringError>());
  llvm::handleAllErrors(Result.takeError(), [](const llvm::StringError &E) {
    EXPECT_THAT(E.getMessage(), AllOf(HasSubstr("selected range"),
                                      HasSubstr("macro expansion")));
  });

However, the EXPECT_THAT is never executed (replacing it with an assert
or llvm_unreachable does not fire).

ASSERT_THAT_EXPECTED calls TakeExpected, which calls takeError(), and you
can't call takeError() twice on an Expected<T>.


Found by the Rotten Green Tests project.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210312/51b0ae57/attachment.html>


More information about the llvm-bugs mailing list