From 99c7cf3031e96fef7cffd73644d3fe68f84f4247 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 5 Jan 2024 16:23:23 +0000 Subject: [PATCH] guard file creation in tests --- tests/test_c_api.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_c_api.cpp b/tests/test_c_api.cpp index 13bee5b..3e64077 100644 --- a/tests/test_c_api.cpp +++ b/tests/test_c_api.cpp @@ -207,9 +207,14 @@ TEST_CASE("Read test file") { const auto test_file = test_directory() / "test_read.nc"; - if (const auto res = create_file(test_file)) { - const std::string error = nc_strerror(res); - throw std::runtime_error("Couldn't create file: "s + error); + // Only create the file for the first test case + static bool first_run = true; + if (first_run) { + if (const auto res = create_file(test_file)) { + const std::string error = nc_strerror(res); + throw std::runtime_error("Couldn't create file: "s + error); + } + first_run = false; } int ncid = 0;