-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abort old tests and start new ones after a code change in watch mode #518
Comments
Would have to restart the old tests as well as any new ones. Are there any concerns around cleanup code not running when tests are aborted? |
I would say yes. We could make it configurable. That would mean watch support now adds three cli flags - which seems a lot. Or - the keyboard command could trigger the immediate rerun. I like this one I think. I only care about this on projects with really long running test suites. |
Cleanup code should be in the after/afterEach hooks, so why not run them when tests are cancelled? |
Exactly what should be done. I imagine sending "abort" event to forked process, which would prevent execution of next steps and run the after hooks. |
If you have all concurrent tests then this behavior is essentially useless. Tests will have begun by the time you send an abort. So if we follow up with afterEach then after its really no different than a standard test run. |
At least that's more or less equivalent to sending a SIGINT and restarting manually. |
@jamestalmage I think you misunderstood my idea. Say we have long-running tests, does not matter how much. Inagine each of them takes at least a second. When in watch mode, after I make a change, I don't need to see the test results from the old test run, I want to see new tests immediately starting. So we need to abort & clean up the previous tests, in order to start new ones asap. |
I think I know what you are asking, and I am not objecting to the concept in general, I am just saying I don't see a practical way of accomplishing it as currently proposed. How are you planning on "aborting"? What do you do when you receive the "abort" message from the parent process? You can't interrupt tests that are already launched. You could elect not to execute the next hook, but so far everyone seems to be saying they want IMO the easiest way to get at your basic request ("I want to see new tests immediately starting") is to just kill the child processes. This is problematic if there is cleanup code in That's how I came to the conclusion that we should allow either:
or
|
What I meant in terms of implementation is much simpler and does not need to kill the process, add one more config option and other mess. Simply notify forked process, that no more tests should be run. Let the currently running tests and their hooks finish to properly clean up everything, but don't run the next concurrent/serial test. |
There is no such thing as a "next concurrent test". Every concurrent test in the file is launched in a single turn of the event loop, once you have kicked off the "run the concurrent tests" phase, there is no turning back. Any Things are a bit different if they've got a lot of |
James, you are right about concurrent tests, can't believe I actually suggested that. As for serial tests, example of such test suite is Ghost blogging software, almost all their tests rely on database state, so they have to clean it before each new test. Their test suite takes 11m to run. If we wouldn't abort old tests on new code update, watch mode becomes useless in that case. |
What I was thinking is that even though we have started the concurrent tests we can still choose to ignore their result and pretty much unref / mark them as aborted, and ignore. Like an unref'd/detached child process, it still runs to completion, but the parent process don't care and have no communication with it anymore. |
@sindresorhus yes, I think this is the best we can do in that situation, great idea! |
That would work as long as there are no implicit assumptions that test files are not executed concurrently. If a test file resets a static database table whilst cleaning up that may break a concurrent run of that same test file. |
@novemberborn Yes, but the idea is that the |
While the tests themselves are still running? That'd be fine for reads (they'll fail but their output is discarded) but not for writes, which will no longer be cleaned up. |
Our |
Follow up from #502 (comment).
The text was updated successfully, but these errors were encountered: