Skip to content

Commit 8cf0768

Browse files
committed
ts: mask Cygwin fish snippet killing other fish processes
Cygwin's fish package ships a /etc/fish/conf.d/01_fish_variables.fish configuration snippet that runs "pgrep fish | grep -v ^$fish_pid$ | xargs -r kill" when executed. When test files run concurrently, a fish process started by one of them kills the fish processes started by the others, which makes the source-sh and sh-to-mod tests relying on fish fail or hang nondeterministically on Cygwin. Mask this snippet with an empty file of the same name in a user configuration directory set in the testsuite directory, which becomes the home directory of tests. fish sources a single snippet per file name and looks at the user configuration directory first. The fish checks run at testsuite initialization, prior to the home directory change, are pointed at this configuration directory too. This snippet is also what made the fish test of source-sh fail on Cygwin, so this test is not expected to fail there anymore. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent 31d65bd commit 8cf0768

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎testsuite/modules.00-init/005-init_ts.exp‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,28 @@ unset test_perms_file
216216
unset orig_perms
217217
unset new_perms
218218

219+
# fish package on Cygwin ships a /etc/fish/conf.d/01_fish_variables.fish
220+
# snippet that kills the other running fish processes when executed, which
221+
# breaks fish-based tests of test files run concurrently: mask this snippet
222+
# with an empty file of the same name in a user configuration directory set
223+
# in testsuite directory, as fish only sources the first snippet found for a
224+
# given file name (testsuite directory becomes home directory of tests)
225+
set fish_check_cmd [list $env(TESTSUITEDIR)/is_func_defined.fish]
226+
if {$os_name eq {cygwin}} {
227+
set fish_confd $env(TESTSUITEDIR)/.config/fish/conf.d
228+
file mkdir $fish_confd
229+
close [open $fish_confd/01_fish_variables.fish w]
230+
set fish_check_cmd [list env XDG_CONFIG_HOME=$env(TESTSUITEDIR)/.config\
231+
{*}$fish_check_cmd]
232+
}
233+
219234
# check if module command is defined prior running tests
220235
set is_modules_defined [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined module}]}]
221-
set is_modules_defined_fish [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined.fish module}]}]
236+
set is_modules_defined_fish [expr {![catch {exec {*}$fish_check_cmd module}]}]
222237
send_user "\tModules is defined in SH env prior tests: $is_modules_defined\n"
223238
send_user "\tModules is defined in FISH env prior tests: $is_modules_defined_fish\n"
224239
set is_mogui_defined [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined mogui}]}]
225-
set is_mogui_defined_fish [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined.fish mogui}]}]
240+
set is_mogui_defined_fish [expr {![catch {exec {*}$fish_check_cmd mogui}]}]
226241
send_user "\tMoGui is defined in SH env prior tests: $is_mogui_defined\n"
227242
send_user "\tMoGui is defined in FISH env prior tests: $is_mogui_defined_fish\n"
228243

‎testsuite/modules.00-init/010-environ.exp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ set ORIG_PATH $env(PATH)
213213
setenv_var HOME $env(TESTSUITEDIR)
214214
set ORIG_HOME $env(HOME)
215215

216+
# make fish use the user configuration directory set in home directory, where
217+
# the snippet of Cygwin package killing other fish processes is masked
218+
if {$os_name eq {cygwin}} {
219+
unsetenv_var XDG_CONFIG_HOME
220+
}
221+
216222
set ORIG_MODULECMD $MODULECMD
217223

218224
unsetenv_var testsuite

‎testsuite/modules.50-cmds/400-source-sh.exp‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,7 @@ lappend ans [list out {complete -e -c mycmd;}]
14221422
lappend ans [list out {complete -c mycmd --exclusive --short-option 'h' --description 'Command help';}]
14231423
}
14241424
lappend ans [list chdir $mp]
1425-
# following test is expected to fail on CYGWIN due to a packaging issue:
1426-
# fish shell initialization script uses pgrep utility which is not available
1427-
# see https://cygwin.com/pipermail/cygwin/2024-January/255154.html
1428-
testouterr_cmd fish {load source-sh/7.2} $ans {} [expr {$os_name eq {cygwin} ? {xfail} : {}}]
1425+
testouterr_cmd fish {load source-sh/7.2} $ans {}
14291426

14301427
if {[info exists fish_version_ge31] && $fish_version_ge31} {
14311428
set tserr_disp72 "-------------------------------------------------------------------

0 commit comments

Comments
 (0)