| 39 | namespace colmap { |
| 40 | |
| 41 | std::filesystem::path CreateTestDir() { |
| 42 | const testing::TestInfo* test_info = THROW_CHECK_NOTNULL( |
| 43 | testing::UnitTest::GetInstance()->current_test_info()); |
| 44 | std::ostringstream test_name_stream; |
| 45 | test_name_stream << test_info->test_suite_name() << "." << test_info->name(); |
| 46 | const std::string test_name = test_name_stream.str(); |
| 47 | |
| 48 | const std::filesystem::path test_dir = |
| 49 | std::filesystem::temp_directory_path() / "colmap_test_data" / test_name; |
| 50 | LOG(INFO) << "Creating test directory: " << test_dir; |
| 51 | |
| 52 | // Create directory once. Cleanup artifacts from previous test runs. |
| 53 | static std::mutex mutex; |
| 54 | std::lock_guard<std::mutex> lock(mutex); |
| 55 | static std::set<std::string> existing_test_names; |
| 56 | if (existing_test_names.count(test_name) == 0) { |
| 57 | if (std::filesystem::is_directory(test_dir)) { |
| 58 | std::filesystem::remove_all(test_dir); |
| 59 | } |
| 60 | std::filesystem::create_directories(test_dir); |
| 61 | } |
| 62 | existing_test_names.insert(test_name); |
| 63 | |
| 64 | return test_dir; |
| 65 | } |
| 66 | |
| 67 | } // namespace colmap |
no outgoing calls
no test coverage detected