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
Adding a watcher test #137
Conversation
Ok, PR triggered somewhat builds in AppVeyor. |
You broke the build machines 😄 |
@pana-cc I also have tried various combinations, using a line queue and such. My solution to this would be to extend the watcher to accept yet another option (for testing purposes), that will terminate the watcher after N compilation runs. This in place, one can then inject another source file into the watched project and wait for the watcher to terminate, which requires a spawnSync() instead of just a spawn(). After which one could compare the stdout of the watch process with some existing test fixture. |
I’ll give it a few more attempts. I hope the line events are fired at different times and the subscribe/unsubscribe approach I used let some notifications slip while unsubscribed. The watcher supports interrupts of the current execution so I will need to trigger file changes after certain output from the watcher. For proper tests I really need to be able to do asserts / changes the way they are in the test. |
Some of the machines actually executed the tests now. <3 I wish they were picking them up quicker. How should we release the next version now? I think to bump the minor version and publish a preview. The master contains small breaking changes related to the custom test ui right? |
It seems the tests passed but the .kill SIGINT interrupt didn’t kill properly the process. I need to simulate “Ctrl + C” sent to the child process. |
4ea52dc
to
7e6f1a8
Compare
The kill SIGINT should be enough to stop the child process, but it doesn't get killed, it doesn't raise "exit", it will turn out to be something stupid like travis' CI shell asking "yes / no"... |
84e994f
to
27d0fb7
Compare
@pana-cc I think that would be the best idea, making this a release candidate / preview release first. |
@pana-cc I think I found the reason for the seemingly erratic behaviour. There is a stdl standard readline from process.stdin. This remains open and will not cause the process to quit. Perhaps we should drop that for now as it is not being used? |
@pana-cc otherwise I have here a solution that lets us run the watcher with spawn sync for a defined number of times, say 2:
This can be called with In the test then we can use spawnSync and get stdout/stderr and compare that to a fixture for example. |
b5ac51b
to
1464a24
Compare
terminate seems to exit the watcher processes on travis (linux?) now something is wrong with the line reader on appveyor (windows?). |
e8da54c
to
4921c88
Compare
I am about to set up a dedicated windoze machine for testing windoze related issues. Dunno when I am done with that, though, because windoze is giving me a bad time since the latest not-a-win-win-situation-10-update. |
We have a similar problem over at node-tmp: raszi/node-tmp#159 Node on the Windows platform does not support required signals. There is a work around using a Power?Shell script, see nodejs/node#12378 (comment) |
@pana-cc any progress on this? |
@params({ fixture: "watcher", installTypesMocha: false }, "can run watcher") | ||
@params({ fixture: "watcher", installTypesMocha: true }, "can run watcher with @types/mocha") | ||
runTest(params: PackageTestParams) { | ||
async runTest(params: PackageTestParams) { | ||
super.runTest(params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that you need to call super here as the watcher will run the same tests from the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to be sure that if it fails it will be because of the watcher issues, not because of issues with mocha-typescript. Further the watcher will need the dependencies installed I think that's handled in the super call.
assert((await this.line()).includes("1 failing")); | ||
} | ||
|
||
line(): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this looks nice, I think it is also the cause for some race conditions, where multiple line events will be send and get lost while awaiting the next line(). Especially on the much slower vms over at appveyor or the much faster ones on travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last version attaches a single listener for the linereader events and the promises will either resolve if the lines queue is not empty or will wait for a line event but should handle the racing.
class WatcherPackage extends AbstractPackageITBase { | ||
|
||
watch: ChildProcess; | ||
readline: readline.Interface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be readline.ReadLine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ReadLine = Interface; // type forwarded for backwards compatiblity
I think the "modern stuff" is Interface.
I gave up signaling node processes for windows, probably I can just throw a "quit[enter]" in the std in but that would be next year. |
Add watcher test Add some whitespace, trigger AppVeyor Run only the watcher test on build machines with some more logs Add queue with lines Run all tests
…nding based on platform
@pana-cc I will have a look into this during the weekend. I cannot believe that signalling an external process is that difficult with node on windows. But you never know... |
That would be awesome, either try to run the test for windows or just skip it under win32 and let's prepare the package for v2.0.0 removing the custom ui. |
sry, I did not run the tests on a dedicated windows machine yet. |
I've skipped the watcher test for windows. |
@pana-cc very good. I will take a look at how lerna implemented their system that watches over external processes and terminate them if they do not exit in a timely manner. |
I think we are good for v2 release? I was thinking of RC version but we don’t have a newsletter to announce it so nobody would try an RC anyway. Do you want to bump the package to v2 and npm publish? |
To be honest, I still have no clue on how to do a publish on npm for a package where I am only a contributor for. Let me have a look at the available documentation and I will come back to you tomorrow. |
Not ready for PR yet, but I want to check what will happen with the build machines.