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

Launch a separate subprocess to run tests #31

Merged
merged 1 commit into from
Aug 15, 2020
Merged

Conversation

ptomato
Copy link
Owner

@ptomato ptomato commented Aug 15, 2020

Since introducing the feature that makes it possible to use the config
file to control the environment in which the tests are run, it has been
necessary to run the actual tests in a subprocess. Previously, Jasmine
would run itself as the subprocess. This was not so great, for several
reasons:

  • The config file was read in twice, and printed two messages to that
    effect.

  • Jasmine would only run a subprocess if you did want to modify the
    environment, so in some situations your tests would be run in a sub-
    process and in some situations they wouldn't.

This commit changes things so that the tests are always run in a
subprocess. The "jasmine" script is a launcher that reads the config file
and launches the subprocess, which is a "jasmine-runner" script in the
package's libexec directory.

All the config-file parsing code now belongs to the launcher. The runner
does not know about the config file; it is purely configured by the
arguments the launcher passes on its command line. The options.js module
is the only code loaded by both the launcher and the runner, because they
both need to parse command line options.

In addition, the config.js module now doesn't import any other modules.
The code has been made more testable in this and a few other ways.

Since introducing the feature that makes it possible to use the config
file to control the environment in which the tests are run, it has been
necessary to run the actual tests in a subprocess. Previously, Jasmine
would run itself as the subprocess. This was not so great, for several
reasons:

- The config file was read in twice, and printed two messages to that
  effect.

- Jasmine would only run a subprocess if you did want to modify the
  environment, so in some situations your tests would be run in a sub-
  process and in some situations they wouldn't.

This commit changes things so that the tests are always run in a
subprocess. The "jasmine" script is a launcher that reads the config file
and launches the subprocess, which is a "jasmine-runner" script in the
package's libexec directory.

All the config-file parsing code now belongs to the launcher. The runner
does not know about the config file; it is purely configured by the
arguments the launcher passes on its command line. The options.js module
is the only code loaded by both the launcher and the runner, because they
both need to parse command line options.

In addition, the config.js module now doesn't import any other modules.
The code has been made more testable in this and a few other ways.
@ptomato ptomato merged commit 2fba93e into master Aug 15, 2020
@ptomato ptomato deleted the launcher-subprocess branch August 15, 2020 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant