Skip to content

Commit

Permalink
C: Guard file creation in tests
Browse files Browse the repository at this point in the history
Workaround for file access issue on Windows CI, and halves the test
runtime (from 0.17s to 0.07s!)
  • Loading branch information
ZedThree committed Jan 5, 2024
1 parent 23028e2 commit 026a65f
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 026a65f

Please sign in to comment.