Skip to content

Commit 92caaf9

Browse files
committed
test(scaffold): close fixtures before cleanup
1 parent 12b0b95 commit 92caaf9

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

tests/unit/test_scaffold.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,13 @@ widget = "1.0.0"
363363
auto injected = mcpp::scaffold::inject_self_dependency(
364364
manifest, vars, {"gui"});
365365
ASSERT_TRUE(injected.has_value()) << injected.error();
366-
std::ifstream is(manifest);
367-
std::stringstream ss;
368-
ss << is.rdbuf();
369-
auto text = ss.str();
366+
std::string text;
367+
{
368+
std::ifstream is(manifest);
369+
std::stringstream ss;
370+
ss << is.rdbuf();
371+
text = ss.str();
372+
}
370373
EXPECT_NE(text.find("[dependencies.acme]\nwidget = { version = \"2.0.0\", features = [\"gui\"] }"),
371374
std::string::npos);
372375
EXPECT_NE(text.find("[dependencies.compat]\nwidget = \"1.0.0\""),
@@ -375,10 +378,12 @@ widget = "1.0.0"
375378
auto again = mcpp::scaffold::inject_self_dependency(
376379
manifest, vars, {"gui"});
377380
ASSERT_TRUE(again.has_value()) << again.error();
378-
std::ifstream is2(manifest);
379-
std::stringstream ss2;
380-
ss2 << is2.rdbuf();
381-
EXPECT_EQ(ss2.str(), text);
381+
{
382+
std::ifstream is(manifest);
383+
std::stringstream ss;
384+
ss << is.rdbuf();
385+
EXPECT_EQ(ss.str(), text);
386+
}
382387
std::filesystem::remove_all(root);
383388
}
384389

0 commit comments

Comments
 (0)