CI: Another attempt to fix windows ci.. #2086
Merged
+7
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Seeing how it failed again, I dug a bit deeper into what could cause it.
Flushing the
std::ofstream
seems to only guarantee synchronization for the current application. The OS has to decide what to actually do, where Windows seems to have some trouble, as we spawn a separate process withstd::system
.From what I found, there are two solutions, one being a hacky one that someone suggested on SO:
https://stackoverflow.com/a/9667875
which essentially just opens a new stream, which seems to force windows to actually finalize the write to disk.
There might be a better solution though, looking at the spec of
std::system
itself:https://en.cppreference.com/w/cpp/utility/program/system
Talk about fine print..
Anyways, I've reverted the
ofs
to what it was before, but added astd::cout.flush()
right before we do the clangd-formatting step. If this doesn't work, the reopening of the ofs in append mode or a separate std::ifstream seems like a good solution.