blob: 05f48a1abc9900197e34a7c2892f7904371e979c (
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# file : tests/bash/testscript
# license : MIT; see accompanying LICENSE file
# Only native testing on non-Windows platforms
#
: dummy
:
if ($test.target == $build.host && $build.host.class != 'windows')
{
buildfile = true
test.arguments =
.include ../common.testscript
+cat <<EOI >+build/bootstrap.build
subprojects = sub.bash
using test
using install
EOI
+cat <<EOI >=build/root.build
using bash
test/bash{*}: install.subdirs = true
exe{*}: test = true
EOI
# Setup a subproject that we can import a module from.
#
# Note: used by multiple tests so should be static.
#
+mkdir -p sub.bash/build
+cat <<EOI >=sub.bash/build/bootstrap.build
project = sub.bash
using install
EOI
+cat <<EOI >=sub.bash/build/root.build
using bash
EOI
+cat <<EOI >=sub.bash/build/export.build
$out_root/
{
include sub/
}
export $src_root/sub/bash{foo}
EOI
+cat <<EOI >=sub.bash/buildfile
./: dir{*/ -build/}
EOI
+mkdir sub.bash/sub
+cat <<EOI >=sub.bash/sub/foo.bash
echo sub
EOI
+cat <<EOI >=sub.bash/sub/buildfile
./: bash{foo}
EOI
# This scopes creates the test/ subdirectory corresponding to our project in
# the import path. A bit of a hack but the alternative would be creating a
# project for each test.
#
: test
:
{
: basics
:
{
cat <<EOI >=hello.bash;
function hello () { echo "Hello, $@!"; }
EOI
cat <<EOI >=hello.in;
#!/usr/bin/env bash
if [[ "$OSTYPE" == darwin* ]]; then
function readlink ()
{
if [ "$1" != -f ]; then
command readlink "$@"
else
echo "$2"
fi
}
fi
@import test/basics/hello@
hello "$@"
EOI
cat <<EOI >=buildfile;
exe{hello}: in{hello} bash{hello}
exe{hello}: test.arguments = 'World'
EOI
$* test >'Hello, World!';
$* install config.install.root=tmp;
tmp/bin/hello 'John' >'Hello, John!';
$* uninstall config.install.root=tmp;
$* clean
}
: import
:
{
cat <<EOI >=driver.in;
#!/usr/bin/env bash
if [[ "$OSTYPE" == darwin* ]]; then
function readlink ()
{
if [ "$1" != -f ]; then
command readlink "$@"
else
echo "$2"
fi
}
fi
@import sub.bash/foo@
EOI
cat <<EOI >=buildfile;
import mods = sub.bash%bash{foo}
exe{driver}: in{driver} $mods
EOI
$* test >'sub';
$* install config.install.root=tmp;
tmp/bin/driver >'sub';
$* uninstall config.install.root=tmp;
$* clean
}
: recursive
:
{
cat <<EOI >=test.bash.in;
@import sub.bash/foo@
EOI
cat <<EOI >=driver.in;
#!/usr/bin/env bash
if [[ "$OSTYPE" == darwin* ]]; then
function readlink ()
{
if [ "$1" != -f ]; then
command readlink "$@"
else
local r="$2"
if test -L "$r"; then
r="$(command readlink "$r")"
if [[ "$r" != /* ]]; then
r="$(dirname "$2")/$r"
fi
fi
echo "$r"
fi
}
fi
@import test/recursive/test@
EOI
cat <<EOI >=buildfile;
import mods = sub.bash%bash{foo}
exe{driver}: in{driver} bash{test}
bash{test}: in{test} $mods
EOI
$* test >'sub';
$* install config.install.root=tmp;
tmp/bin/driver >'sub';
# Test execution via symlink.
#
mkdir bin;
ln -s ../tmp/bin/driver bin/driver;
bin/driver >'sub';
# Test execution via PATH.
#
#@@ TODO: add $~/bin to the PATH environment variable.
#driver >'sub';
$* uninstall config.install.root=tmp;
$* clean
}
#\
: import-installed
:
{
# Note that here we import the project as sub, not sub.bash in order
# to avoid importing as a subproject.
#
cat <<EOI >=driver.in;
#!/usr/bin/env bash
@import sub/foo@
EOI
cat <<EOI >=buildfile;
import mods = sub%bash{foo}
exe{driver}: in{driver} $mods
EOI
$* 'install(../../sub.bash/)' config.install.root=tmp;
#@@ TODO: add $~/tmp/bin to the PATH environment variable.
$* test clean >'sub';
$* clean;
$* 'uninstall(../../sub.bash/)' config.install.root=tmp
}
#\
}
}
|