Skip to content

Commit 134768c

Browse files
szedergitster
authored andcommitted
test-lib: prevent '--stress-jobs=X' from being ignored
'./t1234-foo.sh --stress-jobs=X ...' is supposed to run that test script in X parallel jobs, but the number of jobs specified on the command line is entirely ignored if other '--stress'-related options follow. I.e. both './t1234-foo.sh --stress-jobs=X --stress-limit=Y' and './t1234-foo.sh --stress-jobs=X --stress' fall back to using twice the number of CPUs parallel jobs instead. The former has been broken since commit de69e6f (tests: let --stress-limit=<N> imply --stress, 2019-03-03) [1], which started to unconditionally overwrite the $stress variable holding the specified number of jobs in its effort to imply '--stress'. The latter has been broken since f545737 (tests: introduce --stress-jobs=<N>, 2019-03-03), because it didn't consider that handling '--stress' will overwrite that variable as well. We could fix this by being more careful about (over)writing that $stress variable and checking first whether it has already been set. But I think it's cleaner to use a dedicated variable to hold the number of specified parallel jobs, so let's do that instead. [1] In de69e6f there was no '--stress-jobs=X' option yet, the number of parallel jobs had to be specified via '--stress=X', so, strictly speaking, de69e6f broke './t1234-foo.sh --stress=X --stress-limit=Y'. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e636282 commit 134768c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/test-lib.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ parse_option () {
163163
;;
164164
--stress-jobs=*)
165165
stress=t;
166-
stress=${opt#--*=}
167-
case "$stress" in
166+
stress_jobs=${opt#--*=}
167+
case "$stress_jobs" in
168168
*[!0-9]*|0*|"")
169169
echo "error: --stress-jobs=<N> requires the number of jobs to run" >&2
170170
exit 1
@@ -262,9 +262,9 @@ then
262262
: # Don't stress test again.
263263
elif test -n "$stress"
264264
then
265-
if test "$stress" != t
265+
if test -n "$stress_jobs"
266266
then
267-
job_count=$stress
267+
job_count=$stress_jobs
268268
elif test -n "$GIT_TEST_STRESS_LOAD"
269269
then
270270
job_count="$GIT_TEST_STRESS_LOAD"

0 commit comments

Comments
 (0)