mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 04:39:52 +08:00
e390ee12c2
This fails *a lot* on Travis, obscuring other tests. As far as we can tell, a newline is somehow sneaking in here. See #6693
61 lines
2.0 KiB
Fish
61 lines
2.0 KiB
Fish
# RUN: env fth=%fish_test_helper %fish %s
|
|
|
|
status job-control full
|
|
|
|
# Ensure that lots of nested jobs all end up in the same pgroup.
|
|
|
|
function save_pgroup -a var_name
|
|
$fth print_pgrp | read -g $var_name
|
|
end
|
|
|
|
# Here everything should live in the pgroup of the first fish_test_helper.
|
|
$fth print_pgrp | read -g global_group | save_pgroup g1 | begin
|
|
save_pgroup g2
|
|
end | begin
|
|
echo (save_pgroup g3) >/dev/null
|
|
end
|
|
|
|
[ "$global_group" -eq "$g1" ] && [ "$g1" -eq "$g2" ] && [ "$g2" -eq "$g3" ]
|
|
and echo "All pgroups agreed"
|
|
or echo "Pgroups disagreed. Should be in $global_group but found $g1, $g2, $g3"
|
|
# CHECK: All pgroups agreed
|
|
|
|
# Here everything should live in fish's pgroup.
|
|
# Unfortunately we don't know what fish's pgroup is (it may not be fish's pid).
|
|
# So run it twice and verify that everything agrees; this implies that it could
|
|
# not have used any of the pids of the child procs.
|
|
function nothing
|
|
end
|
|
nothing | $fth print_pgrp | read -g a0 | save_pgroup a1 | begin
|
|
save_pgroup a2
|
|
end
|
|
nothing | $fth print_pgrp | read -g b0 | save_pgroup b1 | begin
|
|
save_pgroup b2
|
|
end
|
|
|
|
[ "$a0" -eq "$a1" ] && [ "$a1" -eq "$a2" ] \
|
|
&& [ "$b0" -eq "$b1" ] && [ "$b1" -eq "$b2" ] \
|
|
&& [ "$a0" -eq "$b0" ]
|
|
and echo "All pgroups agreed"
|
|
or echo "Pgroups disagreed. Found $a0 $a1 $a2, and $b0 $b1 $b2"
|
|
# CHECK: All pgroups agreed
|
|
|
|
### DISABLED - this fails a lot on Travis
|
|
# Ensure that eval retains pgroups - #6806.
|
|
# Our regex will capture the first pgroup and use a positive lookahead on the second.
|
|
# $fth print_pgrp | tr \n ' ' 1>&2 | eval '$fth print_pgrp' 1>&2
|
|
## CHECKERR: {{(\d+) (?=\1)\d+}}
|
|
|
|
# Ensure that if a background job launches another background job, that they have different pgroups.
|
|
# The pipeline here will arrange for the two pgroups to be printed on the same line, like:
|
|
# 123 124
|
|
# Our regex will capture the first pgroup and use a negative lookahead on the second.
|
|
status job-control full
|
|
$fth print_pgrp | begin
|
|
tr \n ' '
|
|
$fth print_pgrp | tr \n ' ' &
|
|
end &
|
|
wait
|
|
echo
|
|
# CHECK: {{(\d+) (?!\1)\d+}}
|