Toggle event processing through the filesystem #30
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.
(See the readme for details on how to use the feature)
I'm a bit torn on the testing side of this. The feature watches for creation / deletion of a
pause
file relative to the cwd. If we simply create apause
file in one of our tests, other tests detect it as well because they all share the same cwd (and if an unrelated test detects thepause
file, it stops processing events and fails).The straightforward solution is to use
std::env::set_current_dir
in the test that exercises this feature, setting it to a unique directory so we can create thepause
file without affecting other tests. However, cargo runs all tests in a single multi-threaded process, so changing the cwd will by default also change it for everyone else (failing to achieve the isolation we want). Fortunately, we can uselibc::unshare(libc::CLONE_FS)
to makestd::env::set_current_dir
affect only the current test's thread, finally giving us isolation (it works!). The problem is thatlibc::unshare
is not a portable solution (it doesn't exist on MacOS or Windows, so anyone who wants to contribute and uses a non-Linux system would fail to build the tests locally).I'm inclined to keep the code as is and maybe add a
#[cfg(...)]
attribute to avoid compiling this specific test on platforms other than Linux. What do you think?Here are some alternative options:
pause
file is provided through configuration, then ensure that each test gets a unique path. I'm not a fan of this, because we don't really want to configure the path. It feels like introducing complexity in the production code for the sake of testing.Side note: it looks like the build already fails on Windows, due to a bencher.dev issue 😢.
Closes #23