blob: a6f7a09b1e6cb097b028092875934da3d139e7dd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# Tests for interactive job control with parameter state
%prep
if zmodload zsh/zpty 2> /dev/null; then
zpty_start() {
export PS1= PS2=
zpty -d
zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
}
zpty_input() {
zpty -w zsh "${(F)@}" $'\n'
}
zpty_line() {
local REPLY
integer i
for (( i = 0; i < ${1:-1}; ++i )); do
zpty -r zsh REPLY
print -r -- ${REPLY%%($'\r\n'|$'\n')}
done
}
zpty_stop() {
# exit twice in case of check_jobs
zpty -w zsh $'exit\nexit\n'
# zpty gives no output when piped without these braces (?)
{ zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;'
zpty -d
:
}
if ! zmodload zsh/parameter 2> /dev/null; then
ZTST_unimplemented='the zsh/parameter module is not available'
fi
else
ZTST_unimplemented='the zsh/zpty module is not available'
fi
%test
zpty_start
zpty_input "MODULE_PATH=${(q)MODULE_PATH}"
zpty_input 'sleep 3 &'
zpty_input 'print $jobstates'
zpty_input '(print $jobstates)'
zpty_input 'jobs -s'
zpty_stop
0:$jobstate for running job in main shell and subshell
*>\[1] [0-9]##
*>running:+:*=running
*>running:+:*=running
*>zsh:*SIGHUPed*
# $jobstates refers to a job started in the main shell unless
# one has been started in the subshell. In the latter case,
# the subshell has no job control so the job is not marked as current.
zpty_start
zpty_input "MODULE_PATH=${(q)MODULE_PATH}"
zpty_input 'sleep 3 &'
zpty_input '(print main; print $jobstates; sleep 2& print sub; print $jobstates)'
zpty_input 'jobs -s'
zpty_stop
0:$jobstate shows one job started in main shell or one started in subshell
*>\[1] [0-9]##
>main
*>running:+:*=running
>sub
*>running::*=running
*>zsh:*SIGHUPed*
# output from zpty removes empty lines
zpty_start
zpty_input "MODULE_PATH=${(q)MODULE_PATH}"
zpty_input '(print main; print $jobstates; sleep 2& print sub; print $jobstates)'
zpty_input 'jobs -s'
zpty_stop
0:$jobstate shows no job started in main shell but one started in subshell
>main
>sub
*>running::*=running
|