aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/runner/redirect.test
blob: e8d57c153eda474543a5dadd9b0b1238777a72ec (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# file      : tests/test/script/runner/redirect.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

# @@ Needs conversion to cat & build (then adjust buildfile).

$* -o foo >-                        : out-null
$* -e foo 2>-                       : err-null
$* -i 0 <foo                        : in-str
$* -o foo >foo                      : out-str
$* -e foo 2>foo                     : err-str
$* -i 1 <foo >foo                   : inout-str
$* -i 2 <foo 2>foo                  : inerr-str
$* -i 1 -e bar <foo 1>foo 2>bar     : inout-err-str

: in-doc
:
$* -i 0 <<EOO
foo
bar
EOO

: out-doc
:
$* -o foo -o bar >>EOO
foo
bar
EOO

: err-doc
:
$* -e foo -e bar 2>>EOO
foo
bar
EOO

: inout-doc
:
$* -i 1 <<EOI >>EOO
foo
bar
EOI
foo
bar
EOO

: inerr-doc
:
$* -i 2 <<EOI 2>>EOE
foo
bar
EOI
foo
bar
EOE

: empty-str-doc
:
$* -i 1 -e "" <<EOI >>EOO 2>""
EOI
EOO

: nl-containing-doc
:
$* -i 1 <<EOI >>EOO

EOI

EOO

# No-newline tests.
#
# @@ TMP Need does not compare test.
#
: no-newline-str
:
$* -i 1 <:"foo" >:"foo"

#\
$* -i 1 <:"foo" >!"foo"                              # no-newline-str-fail1
$* -i 1 <"foo"  >:!"foo"                             # no-newline-str-fail2
#\

: no-newline-doc
:
$* -i 1 <<:EOI >>:EOO
foo
EOI
foo
EOO

#\
$* -i 1 <<:EOI >>!EOO                                # no-newline-doc-fail1
foo
EOI
foo
EOO

$* -i 1 <<EOI >>:!EOO                                # no-newline-doc-fail2
foo
EOI
foo
EOO
#\

: no-newline-empty-str-doc
:
$* -i 1 <<:EOI >>:EOO 2>:""
EOI
EOO

: no-newline-nl-cont-doc
:
$* -i 1 <<:EOI >>:EOO

EOI

EOO

: file
:
$* -o foo >>>out;
$* -e bar 2>>>&out;
$* -i 1 <<<out >>EOO
foo
bar
EOO

: merge-str
:
$* -o foo -e bar 2>>EOE 1>&2
foo
bar
EOE

: merge-doc
:
$* -i 1 <<EOI -e baz >>EOO 2>&1
foo
bar
EOI
foo
bar
baz
EOO

: merge-file
:
$* -o foo -e bar 2>&1 >>>out;
$* -e baz -o biz 1>&2 2>>>&out;
$* -i 1 <<<out >>EOO
foo
bar
baz
biz
EOO

# Builtins redirects.
#
# @@ That will probably become redundant when builtins and process obtain file
#    descriptors uniformly.
#
: builtins
:
{
  echo "abc" >-                     : out-null
  echo "abc" 1>&2 2>-               : err-null
  echo <foo 1>-                     : in-str
  echo "foo" >foo                   : out-str
  echo "foo" 2>foo 1>&2             : err-str
  cat <foo >foo                     : inout-str
  cat <foo 2>foo 1>&2               : inerr-str
}