Skip to content
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

Call the finishUp() function upon SIGINT #9

Open
WesCossick opened this issue Mar 2, 2021 · 2 comments
Open

Call the finishUp() function upon SIGINT #9

WesCossick opened this issue Mar 2, 2021 · 2 comments

Comments

@WesCossick
Copy link
Member

WesCossick commented Mar 2, 2021

If a SIGINT signal is received, we should call the finishUp() function to help ensure test projects are reset properly.

@WesCossick WesCossick added this to the v1.0.0 milestone Mar 2, 2021
@WesCossick WesCossick self-assigned this Mar 2, 2021
@WesCossick WesCossick changed the title Call the finishUp() function upon SIGTERM Call the finishUp() function upon SIGINT Mar 3, 2021
@WesCossick WesCossick removed this from the v1.0.0 milestone Mar 3, 2021
@WesCossick WesCossick removed their assignment Mar 3, 2021
@WesCossick
Copy link
Member Author

This is actually a little more difficult than expected. If you add...

process.on('SIGINT', async () => {
	console.log();
	await finishUp();
	process.exit();
});

...then it kind of works, but you encounter some quirks.

First, Yarn doesn't seem to exit when the running script exits. So even though Rugged is actually exiting, Yarn just hangs and you need to send another SIGINT to get it to exit:

Screen Recording 2021-03-03 at 10 21 07 AM

You can see that this isn't the case whenever you run Rugged directly (not through yarn test):

Screen Recording 2021-03-03 at 10 22 14 AM

The more problematic quirk is that Listr doesn't seem to cancel the currently running list, and there's no way to do so manually using its API. So sometimes the list can be printed twice, which isn't too bad:

Screen Shot 2021-03-03 at 10 23 13 AM

But other times, it can look like this:

Screen Recording 2021-03-03 at 10 24 09 AM

Notice that it not only flashed funny, but also continued on to the next Listr and started testing the test projects.

@pbelbin
Copy link
Collaborator

pbelbin commented Mar 3, 2021

Notice that it not only flashed funny, but also continued on to the next Listr and started testing the test projects.

The 'flashing' reminds me of some of the computer graphics style used in 2001: A Space Odyssey.

Might be cool if it didn't repeat the information in some cases! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants