File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,51 +40,40 @@ namespace fbcpp::test
4040
4141 namespace
4242 {
43- class TempDir
43+ fs::path tempDir;
44+
45+ struct GlobalFixture
4446 {
45- public:
46- explicit TempDir ()
47+ GlobalFixture ()
4748 {
48- fs::path tempPath = fs::temp_directory_path ();
49+ fs::path prefix = fs::temp_directory_path ();
4950
5051 auto now = std::chrono::system_clock::now ();
5152 auto time = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch ()).count ();
5253
5354 std::ostringstream oss;
5455 oss << " fbcpp-test-" << time;
5556
56- path = tempPath / oss.str ();
57+ tempDir = prefix / oss.str ();
5758
58- fs::create_directory (path );
59+ fs::create_directory (tempDir );
5960 }
6061
61- ~TempDir ()
62+ ~GlobalFixture ()
6263 {
6364 std::error_code ec;
64- fs::remove (path, ec);
65- }
66-
67- public:
68- auto get () const
69- {
70- return path;
71- }
65+ fs::remove (tempDir, ec);
7266
73- private:
74- fs::path path;
75- } tempDir;
76-
77- struct ClientCleanup final
78- {
79- ~ClientCleanup ()
80- {
8167 CLIENT .shutdown ();
8268 }
83- } clientCleanup ;
69+ };
8470 } // namespace
8571
8672 std::string getTempFile (const std::string_view name)
8773 {
88- return (tempDir. get () / name).string ();
74+ return (tempDir / name).string ();
8975 }
9076} // namespace fbcpp::test
77+
78+
79+ BOOST_GLOBAL_FIXTURE (GlobalFixture);
You can’t perform that action at this time.
0 commit comments