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

enable the ability to manage processes that do not close #19

Closed
1 of 5 tasks
thescientist13 opened this issue Jul 19, 2021 · 0 comments · Fixed by #20
Closed
1 of 5 tasks

enable the ability to manage processes that do not close #19

thescientist13 opened this issue Jul 19, 2021 · 0 comments · Fixed by #20
Assignees
Labels
0.4.0 documentation Improvements or additions to documentation feature

Comments

@thescientist13
Copy link
Owner

Type of Change

  • New Feature Request
  • Improvement / Suggestion
  • Documentation
  • Bug
  • Other (please clarify below)

Summary

As part of working on trying to test command line applications that spin up servers (like say a livereload server), there is a particular line of code in runner.js that will never resolve() in this case (since a live reload server will never close), thus causing a test runner to hang.

before(async function() {
  await runner.setup(outputPath);
  await runner.runCommand(cliPath, 'develop');
  console.debug('gets here?'); // never gets here and test runner never advances
});

Details

Specifically, this block isn't getting called, thus never fulfilling the Promise

npm.on('close', code => {
  if (code !== 0) {
    reject(err);
    return;
  }
  resolve();
});

So a couple options are:

  1. find another event to call resolve() in
  2. add a new method to explicitly be able to kill the child process, e.g.
    close() {
      console.debug('manually force close!');
      this.npm.kill();
    }

Leaning towards option 2, which would still require a little boilerplate from the user I believe

before(async function() {
  await runner.setup(outputPath);
      
  return new Promise(async (resolve) => {
    // notice we call it _without_ using await
    runner.runCommand(cliPath, 'develop');
        
     setTimeout(() => {
       resolve();
     }, 3000);
  });
});

...

after(function() {
  runner.close();
});
@thescientist13 thescientist13 added the enhancement New feature or request label Jul 19, 2021
@thescientist13 thescientist13 self-assigned this Jul 19, 2021
@thescientist13 thescientist13 added the documentation Improvements or additions to documentation label Jul 19, 2021
@thescientist13 thescientist13 changed the title enable the ability to manipulate and work around processes that do not close enable the ability to manage processes that do not close Jul 21, 2021
@thescientist13 thescientist13 added feature and removed enhancement New feature or request labels Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.4.0 documentation Improvements or additions to documentation feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant