You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CTest: File IO tests fail because tmp directory isn't cleaned up #731
If you run the file_io tests once, they pass, but on the second time they fail because there are some asserts in there that the file being created doesn't already exist. It looks like ctest isn't cleaning up its temp directories
Oh actually we're just assuming TEST_TMPDIR exists, which it totally doesn't in ctest. Duh... Ok I think that's also why the CLI smoke tests are failing.
So I've been looking into how to do this and it seems weirdly hard to have cmake tests execute in temporary directories that it cleans up. There doesn't even seem to be a native facility for executing a command before or after each test.
We could, of course, solve this locally by making each test responsible for its own setup and teardown. That pushes a lot of responsibility onto the test though and will just result in weird failures if people forget (which they're likely to, since it's not the standard, at least with bazel).
Using a script probably gives you much more flexibility than ctest could :-) The only question remaining is, if we really want to create a test directory for every test or if we should only create those for tests making use of it.
Yeah unless the cost becomes an issue, I'd prefer to let each test (binary, not method) assume it gets a writable scratch directory that is initially empty.
Activity
GMNGeoffrey commentedon Feb 11, 2020
Oh actually we're just assuming TEST_TMPDIR exists, which it totally doesn't in ctest. Duh... Ok I think that's also why the CLI smoke tests are failing.
Fail File IO tests on undefined env var
GMNGeoffrey commentedon Feb 11, 2020
So I've been looking into how to do this and it seems weirdly hard to have cmake tests execute in temporary directories that it cleans up. There doesn't even seem to be a native facility for executing a command before or after each test.
We could, of course, solve this locally by making each test responsible for its own setup and teardown. That pushes a lot of responsibility onto the test though and will just result in weird failures if people forget (which they're likely to, since it's not the standard, at least with bazel).
Avenues I've explored:
@marbre do you have any experience with doing this in cmake?
GMNGeoffrey commentedon Feb 11, 2020
Currently exploring
marbre commentedon Feb 12, 2020
You actually solved it with #741 the way I always handled it, except that I used python scripts :)
GMNGeoffrey commentedon Feb 12, 2020
Good to hear :-) My mistake was assuming that this should be supported natively in the test runner. The actual script is not bad at all.
marbre commentedon Feb 12, 2020
Using a script probably gives you much more flexibility than ctest could :-) The only question remaining is, if we really want to create a test directory for every test or if we should only create those for tests making use of it.
ScottTodd commentedon Feb 12, 2020
It also generally seems like Bazel takes more opinions than ctest on the role of a test runner and build system (see https://docs.bazel.build/versions/2.0.0/test-encyclopedia.html).
GMNGeoffrey commentedon Feb 12, 2020
Yeah unless the cost becomes an issue, I'd prefer to let each test (binary, not method) assume it gets a writable scratch directory that is initially empty.