Merge pull request #5007 from akva2/fix_loghelper_test_logger

fixed: we need to initialize logger before parsing
This commit is contained in:
Bård Skaflestad 2023-11-20 16:30:58 +01:00 committed by GitHub
commit 518df3fa7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,6 +108,11 @@ BOOST_AUTO_TEST_CASE(Cumulative)
:--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------: :--------:-----------:--------:----:------------:----------:-----------:-----------:------------:----------:-----------:-----------:
)"; )";
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::Parser parser; Opm::Parser parser;
auto python = std::make_shared<Opm::Python>(); auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseString(input); auto deck = parser.parseString(input);
@ -157,10 +162,6 @@ BOOST_AUTO_TEST_CASE(Cumulative)
st.set(p.first, p.second * 1e3); st.set(p.first, p.second * 1e3);
} }
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::LogOutputHelper<double> helper(eclState, schedule, st); Opm::LogOutputHelper<double> helper(eclState, schedule, st);
helper.cumulative(0, [](const std::string&) { return false; }); helper.cumulative(0, [](const std::string&) { return false; });
std::string data = trimStream(str); std::string data = trimStream(str);
@ -173,6 +174,10 @@ BOOST_AUTO_TEST_CASE(Error)
Finding the dew point pressure failed for 3 cells [(5,1,1), (6,1,1), (7,1,1)] Finding the dew point pressure failed for 3 cells [(5,1,1), (6,1,1), (7,1,1)]
)"; )";
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Warning));
Opm::Parser parser; Opm::Parser parser;
auto python = std::make_shared<Opm::Python>(); auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseString(input); auto deck = parser.parseString(input);
@ -183,13 +188,10 @@ Finding the dew point pressure failed for 3 cells [(5,1,1), (6,1,1), (7,1,1)]
Opm::Schedule schedule(deck, grid, fp, runspec, python); Opm::Schedule schedule(deck, grid, fp, runspec, python);
Opm::EclipseState eclState(deck); Opm::EclipseState eclState(deck);
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Warning));
Opm::SummaryState st; Opm::SummaryState st;
Opm::LogOutputHelper<double> helper(eclState, schedule, st); Opm::LogOutputHelper<double> helper(eclState, schedule, st);
str.str(""); // clear out parser errors
helper.error({1,20,30}, {4,5,6}); helper.error({1,20,30}, {4,5,6});
std::string data = trimStream(str); std::string data = trimStream(str);
BOOST_CHECK_EQUAL(data, reference); BOOST_CHECK_EQUAL(data, reference);
@ -225,6 +227,10 @@ FIPNUM report region 1 pressure dependent pore volume = 50 RB
:========================:==========================================:================:==========================================: :========================:==========================================:================:==========================================:
)"; )";
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::Parser parser; Opm::Parser parser;
auto python = std::make_shared<Opm::Python>(); auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseString(input); auto deck = parser.parseString(input);
@ -237,10 +243,6 @@ FIPNUM report region 1 pressure dependent pore volume = 50 RB
Opm::EclipseState eclState(deck); Opm::EclipseState eclState(deck);
Opm::SummaryState st; Opm::SummaryState st;
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::LogOutputHelper<double> helper(eclState, schedule, st); Opm::LogOutputHelper<double> helper(eclState, schedule, st);
Opm::Inplace initial, current; Opm::Inplace initial, current;
const auto& phases = current.phases(); const auto& phases = current.phases();
@ -288,6 +290,10 @@ BOOST_AUTO_TEST_CASE(FipResv)
:---------:---------------:---------------:---------------:---------------:---------------: :---------:---------------:---------------:---------------:---------------:---------------:
)"; )";
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::Parser parser; Opm::Parser parser;
auto python = std::make_shared<Opm::Python>(); auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseString(input); auto deck = parser.parseString(input);
@ -300,10 +306,6 @@ BOOST_AUTO_TEST_CASE(FipResv)
Opm::EclipseState eclState(deck); Opm::EclipseState eclState(deck);
Opm::SummaryState st; Opm::SummaryState st;
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::LogOutputHelper<double> helper(eclState, schedule, st); Opm::LogOutputHelper<double> helper(eclState, schedule, st);
Opm::Inplace current; Opm::Inplace current;
const auto& phases = current.phases(); const auto& phases = current.phases();
@ -340,6 +342,10 @@ BOOST_AUTO_TEST_CASE(Injection)
:--------:-----------:------:------:------:------------:----------:-----------:-----------:--------:--------: :--------:-----------:------:------:------:------------:----------:-----------:-----------:--------:--------:
)"; )";
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::Parser parser; Opm::Parser parser;
auto python = std::make_shared<Opm::Python>(); auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseString(input); auto deck = parser.parseString(input);
@ -371,10 +377,6 @@ BOOST_AUTO_TEST_CASE(Injection)
st.set(p.first, p.second); st.set(p.first, p.second);
} }
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::LogOutputHelper<double> helper(eclState, schedule, st); Opm::LogOutputHelper<double> helper(eclState, schedule, st);
helper.injection(0, [](const std::string&) { return false; }); helper.injection(0, [](const std::string&) { return false; });
std::string data = trimStream(str); std::string data = trimStream(str);
@ -396,6 +398,10 @@ BOOST_AUTO_TEST_CASE(Production)
:--------:-----------:----:-----------:-----------:-----------:-----------:-----------:----------:------------:--------:--------: :--------:-----------:----:-----------:-----------:-----------:-----------:-----------:----------:------------:--------:--------:
)"; )";
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::Parser parser; Opm::Parser parser;
auto python = std::make_shared<Opm::Python>(); auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseString(input); auto deck = parser.parseString(input);
@ -433,10 +439,6 @@ BOOST_AUTO_TEST_CASE(Production)
st.set(p.first, p.second); st.set(p.first, p.second);
} }
std::stringstream str;
Opm::OpmLog::addBackend("stream",
std::make_shared<Opm::StreamLog>(str, Opm::Log::MessageType::Note));
Opm::LogOutputHelper<double> helper(eclState, schedule, st); Opm::LogOutputHelper<double> helper(eclState, schedule, st);
helper.production(0, [](const std::string&) { return false; }); helper.production(0, [](const std::string&) { return false; });
std::string data = trimStream(str); std::string data = trimStream(str);