Skip to content

Commit

Permalink
guard file creation in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed Jan 5, 2024
1 parent 05fa209 commit 99c7cf3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 99c7cf3

Please sign in to comment.