[llvm] [flang-rt] Fix test isolation, fixture usage, and other issues in Stop.cpp tests (PR #188155)
Eugene Epshteyn via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 23 21:04:58 PDT 2026
================
@@ -52,48 +57,73 @@ TEST(TestProgramEnd, StopMessageTest) {
testing::ExitedWithCode(EXIT_FAILURE), "");
}
-TEST(TestProgramEnd, NoStopMessageTest) {
- putenv(const_cast<char *>("NO_STOP_MESSAGE=1"));
- Fortran::runtime::executionEnvironment.Configure(
- 0, nullptr, nullptr, nullptr);
+TEST_F(TestProgramEnd, NoStopMessageTest) {
static const char *message{"bye bye"};
- EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
- /*isErrorStop=*/false, /*quiet=*/false),
+ EXPECT_EXIT(
+ {
+ static char noStopMessage[] = "NO_STOP_MESSAGE=1";
+ putenv(noStopMessage);
+ Fortran::runtime::executionEnvironment.Configure(
+ 0, nullptr, nullptr, nullptr);
+ RTNAME(StopStatementText)(message, std::strlen(message),
+ /*isErrorStop=*/false, /*quiet=*/false);
+ },
testing::ExitedWithCode(EXIT_SUCCESS), "bye bye");
- EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
- /*isErrorStop=*/false, /*quiet=*/true),
+ EXPECT_EXIT(
+ {
+ static char noStopMessage[] = "NO_STOP_MESSAGE=1";
+ putenv(noStopMessage);
+ Fortran::runtime::executionEnvironment.Configure(
+ 0, nullptr, nullptr, nullptr);
+ RTNAME(StopStatementText)(message, std::strlen(message),
+ /*isErrorStop=*/false, /*quiet=*/true);
+ },
testing::ExitedWithCode(EXIT_SUCCESS), "");
- EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
- /*isErrorStop=*/true, /*quiet=*/false),
+ EXPECT_EXIT(
+ {
+ static char noStopMessage[] = "NO_STOP_MESSAGE=1";
+ putenv(noStopMessage);
+ Fortran::runtime::executionEnvironment.Configure(
+ 0, nullptr, nullptr, nullptr);
+ RTNAME(StopStatementText)(message, std::strlen(message),
+ /*isErrorStop=*/true, /*quiet=*/false);
+ },
testing::ExitedWithCode(EXIT_FAILURE), "Fortran ERROR STOP: bye bye");
- EXPECT_EXIT(RTNAME(StopStatementText)(message, std::strlen(message),
- /*isErrorStop=*/true, /*quiet=*/true),
+ EXPECT_EXIT(
+ {
+ static char noStopMessage[] = "NO_STOP_MESSAGE=1";
+ putenv(noStopMessage);
+ Fortran::runtime::executionEnvironment.Configure(
+ 0, nullptr, nullptr, nullptr);
+ RTNAME(StopStatementText)(message, std::strlen(message),
+ /*isErrorStop=*/true, /*quiet=*/true);
+ },
testing::ExitedWithCode(EXIT_FAILURE), "");
}
-TEST(TestProgramEnd, FailImageTest) {
+TEST_F(TestProgramEnd, FailImageTest) {
EXPECT_EXIT(
RTNAME(FailImageStatement)(), testing::ExitedWithCode(EXIT_FAILURE), "");
}
-TEST(TestProgramEnd, ExitTest) {
+TEST_F(TestProgramEnd, ExitTest) {
EXPECT_EXIT(RTNAME(Exit)(), testing::ExitedWithCode(EXIT_SUCCESS), "");
EXPECT_EXIT(
RTNAME(Exit)(EXIT_FAILURE), testing::ExitedWithCode(EXIT_FAILURE), "");
}
-TEST(TestProgramEnd, AbortTest) { EXPECT_DEATH(RTNAME(Abort)(), ""); }
+TEST_F(TestProgramEnd, AbortTest) { EXPECT_DEATH(RTNAME(Abort)(), ""); }
-TEST(TestProgramEnd, CrashTest) {
+TEST_F(TestProgramEnd, CrashTest) {
----------------
eugeneepshteyn wrote:
This test was failing, because it was being tested as non-fixture test, but in one ARM buildbot it was somehow tested as a fixture test. Use `TEST_F` to force fixture based testing and updated the messages accordingly.
https://github.com/llvm/llvm-project/pull/188155
More information about the llvm-commits
mailing list