summaryrefslogtreecommitdiffstats
path: root/Test/Y07call_program.ztst
blob: 19eca8f9f6fecdb4fee2e0d0c086ef30ab7f5d12 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# tests for _call_program

%prep

  if ( zmodload -s zsh/zpty ); then
    source $ZTST_srcdir/comptest
    mkdir comp.tmp
    cd comp.tmp
    comptestinit -z $ZTST_testdir/../Src/zsh && {
      comptesteval '
        pp() { printf "<%s>" "$@"; print }
        compdef _tst tst
      '
      tst_call_program() {
        comptesteval "_tst() {
          [[ ${(q+)1} == -[lpqQ]#p[lpqQ]# ]] &&
          local -a _comp_priv_prefix=( print -r priv )
          local ret=\${ _call_program ${${(@q+)@}} }
          _message - \$ret
        }"
        comptest $'tst \t'
      }
    }
  else
    ZTST_unimplemented='the zsh/zpty module is not available'
  fi

%test

  tst_call_program tag pp a b c
  tst_call_program tag pp 'a b c'
  tst_call_program tag pp '"a b c"'
0:basic command arguments
>line: {tst }{}
>MESSAGE:{<a><b><c>}
>line: {tst }{}
>MESSAGE:{<a><b><c>}
>line: {tst }{}
>MESSAGE:{<a b c>}

  for 1 in -q -Q; do
    tst_call_program $1 tag pp $1 a b c
    tst_call_program $1 tag pp $1 'a b c'
    tst_call_program $1 tag pp $1 '"a b c"'
  done
0:-qQ: argument quoting
>line: {tst }{}
>MESSAGE:{<-q><a><b><c>}
>line: {tst }{}
>MESSAGE:{<-q><a b c>}
>line: {tst }{}
>MESSAGE:{<-q><"a b c">}
>line: {tst }{}
>MESSAGE:{<-Q><a><b><c>}
>line: {tst }{}
>MESSAGE:{<-Q><a b c>}
>line: {tst }{}
>MESSAGE:{<-Q><"a b c">}

  tst_call_program    tag '"pp"' a b c
  tst_call_program -q tag '"pp"' a b c
  tst_call_program -Q tag '"pp"' a b c
0:-qQ: command-name quoting
>line: {tst }{}
>MESSAGE:{<a><b><c>}
>line: {tst }{}
>MESSAGE:{}
>line: {tst }{}
>MESSAGE:{<a><b><c>}

  if [[ -z ${lc::=${ ZTST_find_UTF8 }} ]]; then
    ZTST_skip='no utf8 locale'
  else
    comptesteval "old_LC_ALL=\$LC_ALL; LC_ALL=${(q+)lc}"
    for 1 in '' -l; do
      tst_call_program $1 tag '
        local -a arr=( z e é )
        print -r - ${(o)arr}
      '
    done
    comptesteval 'LC_ALL=$old_LC_ALL'
  fi
0:-l
>line: {tst }{}
>MESSAGE:{e z é}
>line: {tst }{}
>MESSAGE:{e é z}

  tst_call_program    tag print a b c
  tst_call_program -p tag print a b c
  comptesteval 'zstyle ":completion:*" gain-privileges yes'
  tst_call_program    tag print a b c
  tst_call_program -p tag print a b c
  comptesteval 'zstyle -d ":completion:*" gain-privileges'
0:-p
>line: {tst }{}
>MESSAGE:{a b c}
>line: {tst }{}
>MESSAGE:{a b c}
>line: {tst }{}
>MESSAGE:{a b c}
>line: {tst }{}
>MESSAGE:{priv print a b c}

%clean

  zmodload -ui zsh/zpty