diff options
author | Colin Ihrig <cjihrig@gmail.com> | 2022-04-15 20:37:28 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2022-04-28 07:56:10 +0300 |
commit | 78a860ae58bf332e9a8562233703a4eb4724f0db (patch) | |
tree | 364467d3294e38e7bb3791638823f6bcdf73a240 /src | |
parent | deb3cf49c74b637905244a50f8d9ebe7b5c5cb94 (diff) |
test_runner: add initial CLI runner
This commit introduces an initial version of a CLI-based
test runner.
PR-URL: https://github.com/nodejs/node/pull/42658
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 4 | ||||
-rw-r--r-- | src/node_options.cc | 21 | ||||
-rw-r--r-- | src/node_options.h | 1 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index 5ba03b75407..b43f915c5d5 100644 --- a/src/node.cc +++ b/src/node.cc @@ -517,6 +517,10 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) { return StartExecution(env, "internal/main/check_syntax"); } + if (env->options()->test_runner) { + return StartExecution(env, "internal/main/test_runner"); + } + if (!first_argv.empty() && first_argv != "-") { return StartExecution(env, "internal/main/run_main_module"); } diff --git a/src/node_options.cc b/src/node_options.cc index 313fb219294..b2b4c2c18c7 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -143,6 +143,24 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) { errors->push_back("--heap-snapshot-near-heap-limit must not be negative"); } + if (test_runner) { + if (syntax_check_only) { + errors->push_back("either --test or --check can be used, not both"); + } + + if (has_eval_string) { + errors->push_back("either --test or --eval can be used, not both"); + } + + if (force_repl) { + errors->push_back("either --test or --interactive can be used, not both"); + } + + if (debug_options_.inspector_enabled) { + errors->push_back("the inspector cannot be used with --test"); + } + } + #if HAVE_INSPECTOR if (!cpu_prof) { if (!cpu_prof_name.empty()) { @@ -498,6 +516,9 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "write warnings to file instead of stderr", &EnvironmentOptions::redirect_warnings, kAllowedInEnvironment); + AddOption("--test", + "launch test runner on startup", + &EnvironmentOptions::test_runner); AddOption("--test-only", "run tests with 'only' option set", &EnvironmentOptions::test_only, diff --git a/src/node_options.h b/src/node_options.h index 97e01a9435b..0757a767a16 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -148,6 +148,7 @@ class EnvironmentOptions : public Options { #endif // HAVE_INSPECTOR std::string redirect_warnings; std::string diagnostic_dir; + bool test_runner = false; bool test_only = false; bool test_udp_no_try_send = false; bool throw_deprecation = false; |