-
Notifications
You must be signed in to change notification settings - Fork 53
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
Implement infinite loop detection of child process #98
Comments
You mean per test or per file? |
There is QUnit.config.testTimeout but I didn't expose this setting to be configurable via runner api. Currently its accessible within tests. What is your use case? |
I would like to try the code mutation methods provided by https://github.com/shybyte/grunt-mutation-testing on some JavaScript project. I would then test the mutated code with node-qunit. Mutated code could produce non terminating runs, but in this case a non terminating run would mean that the mutated code is buggy and thus that the test was successful since mutated code is not supposed to pass all the tests. |
I am not sure I understand you. If its an async code and callback never gets called, qunit will trigger a timeout error anyways. |
Maybe just give me an example of your code and test you would have ... and a concrete problem with the current version. |
Concrete problem is that I don't know how to set a timeout on this testrun.js script (see code below).
How much time will qunit wait? lib.js
infinite-loop.js
runtest.js
|
http://api.qunitjs.com/QUnit.config/ Just found out that the default number is undefined, so it will not, I was wrong. And we have currently no api to pass it. Do you want to submit a pull request for this? |
Basically we can allow setting any of this options. |
But also you can set it as I said within the test file itself, thats why I am trying to understand what you do. |
You have a direct access to QUnit within your test file via QUnit namespace. |
You mean putting |
yes, every test file is runnning in own spawned process, so you need to do that in every test file then. |
Well, putting |
you also used an asyncTest or stopped the test? |
|
lol dude, you blocked completely that process. In this case there needs to be a per process timeout in testrunner or blocked loop detector. |
yes :) |
so, lots of things can be done, I personally never needed them, but you seem to. I still don't really understand your usecase and which of all possible fixes you require. |
So, of course I'm not writing obviously failing tests containing infinite loops. What I want to do is
The point is that the mutated lib code can make the test code run into an infinite loop, and if it does so it means that the test succeeded since the mutated code is supposed to fail at least one of the tests. |
infinite loop would block all tests in that file .... basically all tests will fail .... |
we can add this infinite loop detection but I am not sure it will help you |
If they all fail then that's no problem because I don't want to know where it failed. The only information I want is when a mutant passes all the tests. |
If you are willing to implement the fix we can talk abut details. Are you? |
I could trigger a pull request when I have time, and then we discuss? Or we discuss before? |
We need to agree on basic technics. How would you do that detection? |
Mmh like this ? |
So you are talking about a global timeout for the whole file, which you do in testrunner, not in the child right? The downside of this is you need to know how long file could run, this can variate between different needs, so the default would be very high, like 5 minutes or so ? The other approach could be a ping tiime setting defined in testrunner and passed to the child, child sends a ping every X ms and if it doesn't happen it means process is blocked ... so we could have a way faster time period for the block detection. f..e. 20sec |
For my use case there is no difference between global or local timeout setup. So global is fine.
Default behaviour could be no timeout. No?
Does that mean the user would have to make a ping call every <20 seconds? I'm not sure I completely understand. |
Yeah, no timeout by default would be also an option.
No child process would send a ping message to the parrent every X seconds automatically. So that parent knows the child is not blocked. |
I believe having this kind of detector by default is a valuable feature in some edge cases. Will probably save some people a bit of pain. |
ah, understood |
Yep everything crystal clear |
great, don'f forget to write tests for this feature ;) |
OK |
Old tests seem to pass with current draft implementation. What kind of scenario should I consider in the new tests for this feature? |
Ideally a test with code which has an infinite loop and test runner exists with an error f.e. https://github.com/kof/node-qunit/blob/master/test/testrunner.js#L146 |
Each child takes some time to start up. This can cause problems with really short |
we can just have a higher value for maxBlockDuration, f.e. 5000ms ... how much time does it take on your machine, 100ms? |
I get a ~510ms delay. Implementing this start event would ensure it works with all (> 0) |
wow pretty slow, but ok, lets do that with start event. |
There seems to be a huge delay between the moment the child stops executing the interval code that sends the ping and the moment the parent receives the |
not sure what you mean, you don't need to wait for done event in master if ping is not received at time, you just kill the child and pass an error along. |
What I mean is that when using a very small
The So it looks like the child interval stops some time before the |
I need to see what you do. Maybe you start sending ping before requiring all dependencies, which is sync and blocks the process. I don't think anything in qunit with just some simple dummy test would block for that period of time. |
child.js
testrunner.js
|
and there is a |
try to find which calls in child takes this time. f.e. you are sending start event before requiring dependencies which blocks the process, but actually shouldn't take that much time. |
Adding
which doesn't make it look like something takes time to load.. |
could you explain me why you need to debounce the |
I believe there are cases where the callback has been called more than once. |
There seems to be some kind of inherent limit on the minimum |
…equire call in child.js, set ping period to half the check period (qunitjs#98)
Voilà -> https://github.com/aureooms/node-qunit. If it's ok then I'll clean the |
up? |
ok did it, everything considered, works also with very small maxBlockDuration. Starting child process takes 400ms on my machine, 113ms just the child, the rest javascript libs. Checkout the new version, its already published. |
It is not very clear as if there is a way to limit the execution time of a test run. It would be useful for example if the tested code contains an infinite loop.
The text was updated successfully, but these errors were encountered: