@@ -725,6 +725,14 @@ void ResetStdio() {
725725#endif // __POSIX__
726726}
727727
728+ // Validates the benchmark runner options of the global (per-process) options
729+ // once every option source has been parsed. See
730+ // EnvironmentOptions::CheckBenchOptions().
731+ static void CheckGlobalBenchOptions (std::vector<std::string>* errors) {
732+ Mutex::ScopedLock lock (per_process::cli_options_mutex);
733+ per_process::cli_options->per_isolate ->per_env ->CheckBenchOptions (errors);
734+ }
735+
728736static ExitCode ProcessGlobalArgsInternal (std::vector<std::string>* args,
729737 std::vector<std::string>* exec_args,
730738 std::vector<std::string>* errors,
@@ -834,8 +842,16 @@ int ProcessGlobalArgs(std::vector<std::string>* args,
834842 std::vector<std::string>* exec_args,
835843 std::vector<std::string>* errors,
836844 OptionEnvvarSettings settings) {
837- return static_cast <int >(
838- ProcessGlobalArgsInternal (args, exec_args, errors, settings));
845+ const ExitCode exit_code =
846+ ProcessGlobalArgsInternal (args, exec_args, errors, settings);
847+ if (exit_code != ExitCode::kNoFailure ) return static_cast <int >(exit_code);
848+ // Embedders parse every option source in a single pass, so the benchmark
849+ // options can be validated right away.
850+ CheckGlobalBenchOptions (errors);
851+ if (!errors->empty ()) {
852+ return static_cast <int >(ExitCode::kInvalidCommandLineArgument );
853+ }
854+ return static_cast <int >(ExitCode::kNoFailure );
839855}
840856
841857static std::atomic_bool init_called{false };
@@ -1016,6 +1032,11 @@ static ExitCode InitializeNodeWithArgsInternal(
10161032 if (exit_code != ExitCode::kNoFailure ) return exit_code;
10171033 }
10181034
1035+ // Every option source has now been parsed, so cross-source option
1036+ // constraints can finally be validated.
1037+ CheckGlobalBenchOptions (errors);
1038+ if (!errors->empty ()) return ExitCode::kInvalidCommandLineArgument ;
1039+
10191040 // Set the process.title immediately after processing argv if --title is set.
10201041 if (!per_process::cli_options->title .empty ())
10211042 uv_set_process_title (per_process::cli_options->title .c_str ());
0 commit comments