Repository navigation
fix(cli): apply duration, parallel, repoRef and forceRebuild from config - #163
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
Several options set in `expf.config.json` (or a file passed with `--config`) were silently replaced: - `duration`: the hard-coded `duration: 60` default was spread after the config, so a configured duration always became 60. - `repoRef` / `forceRebuild`: `bin/expf.mjs` always assigns the renamed flags, so when they weren't passed the keys held `undefined`, and spreading `_opts` overwrote the configured values. - `parallel`: the option was declared with `default: false`, so `parallel: false` was always passed and overrode the config. `load.mjs` now applies options in the order defaults, then config, then flags, and drops flags whose value is `undefined` (i.e. not passed). The `default: false` is removed from `--parallel`. An unset value is still falsy, which is all `@expressjs/perf-requests` checks for. Flags passed on the command line still take precedence over the config, and `duration` still defaults to 60. The README options table described `--config` as a "JSON string with package overrides". It now describes it as a path to a JSON config file, adds the missing `--[no-]parallel` row, and gets a short section on how the config file works. Tests cover config values reaching the runner when the flags are undefined, flags overriding the config, and the 60 second default duration. The mock runner now echoes the relevant options. Closes expressjs#162 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #162
Problem
Some
expf loadoptions set inexpf.config.jsonor a--configfile are silently replaced:duration:duration: 60was spread after...conf.repoRef/forceRebuild:bin/expf.mjsalways sets these keys, toundefinedwhen the flag isn't passed, and..._optsthen overwrites the config values.parallel:default: falseinparseArgsalways overrides the config.For example,
{ "parallel": true, "duration": 2 }still ran a 60 second test against only the first request.Changes
packages/cli/load.mjs: options are applied in the order defaults (includingduration: 60), then config, then flags. Flags that areundefinedare dropped first, so a flag that wasn't passed no longer hides the config value. Flags passed on the command line still take precedence.packages/cli/bin/expf.mjs: removeddefault: falsefrom--parallel. An unset value is still falsy, which is all@expressjs/perf-requestschecks for.load.ymlpasses--parallelexplicitly, so CI behaves the same.README.md: the options table described--configas a "JSON string with package overrides". It now describes it as a path to a JSON config file and adds the missing--[no-]parallelrow. A short "Configuration File" section explains keys, lookup and precedence.Testing
packages/cli/test/load.test.mjsuse a fixture config and a mock runner that echoes the options it receives. They cover config values passing through when the flags areundefined, flags overriding the config, and the 60 second default. The config test fails onmain.npm testinpackages/clipasses (5 tests) on Node 24.{ "parallel": true, "duration": 2, ... }:main, it printed "Using only the first request from the test set" and was still running after 15 seconds./,/foo,/bar,/bar/baz/).This PR and #161 both touch
load.mjs(in different hunks) and both append tests toload.test.mjs. I'll rebase whichever one merges second.