aboutsummaryrefslogtreecommitdiff
path: root/tests/default-options/testscript
blob: 41badf36d3b1fa0e459ae178d8d7f173741b2495 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# file      : tests/default-options/testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

# Note that when cross-testing the driver may not be able to run the command
# due to the meaningless program path.
#
+if ($test.target != $build.host)
  exit
end

: basic
:
{
  sys_dir = $canonicalize([dir_path] $~/build2)
  +mkdir -p $sys_dir/local

  +echo 'sys-foo' >=$sys_dir/foo
  +echo 'sys-bar' >=$sys_dir/bar
  +echo 'sys-local-foo' >=$sys_dir/local/foo
  +echo 'sys-local-bar' >=$sys_dir/local/bar

  home_dir = $canonicalize([dir_path] $~/home)
  +mkdir -p $home_dir/.build2/local/

  +echo 'home-foo'       >=$home_dir/.build2/foo
  +echo 'home-bar'       >=$home_dir/.build2/bar
  +echo 'home-local-foo' >=$home_dir/.build2/local/foo
  +echo 'home-local-bar' >=$home_dir/.build2/local/bar

  work_dir = $home_dir/work
  +mkdir -p $work_dir/.build2/local/

  d = $work_dir/.build2

  +echo 'work-foo'       >=$d/foo
  +echo 'work-bar'       >=$d/bar
  +echo 'work-local-foo' >=$d/local/foo
  +echo 'work-local-bar' >=$d/local/bar

  d = $work_dir/project/.build2
  +mkdir -p $d/local/

  +touch $work_dir/project/.git

  +echo 'project-foo'       >=$d/foo
  +echo 'project-bar'       >=$d/bar
  +echo 'project-local-foo' >=$d/local/foo
  +echo 'project-local-bar' >=$d/local/bar

  d = $work_dir/project/package/.build2
  +mkdir -p $d/local/

  +echo 'package-foo'       >=$d/foo
  +echo 'package-bar'       >=$d/bar
  +echo 'package-local-foo' >=$d/local/foo
  +echo 'package-local-bar' >=$d/local/bar

  +echo '--no-default-options' >=$d/local/baz

  start_dir = $canonicalize([dir_path] $work_dir/project/package)

  : entries
  :
  $* -e -t -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir >>/~%EOO%d 2>>/~%EOE%d
    %\.+/build2/foo,sys-foo,false%
    %\.+/build2/bar,sys-bar,false%
    %\.+/build2/local/foo,sys-local-foo,false%
    %\.+/build2/local/bar,sys-local-bar,false%
    %\.+/home/.build2/foo,home-foo,false%
    %\.+/home/.build2/bar,home-bar,false%
    %\.+/home/.build2/local/foo,home-local-foo,false%
    %\.+/home/.build2/local/bar,home-local-bar,false%
    %\.+/home/work/.build2/foo,work-foo,false%
    %\.+/home/work/.build2/bar,work-bar,false%
    %\.+/home/work/.build2/local/foo,work-local-foo,false%
    %\.+/home/work/.build2/local/bar,work-local-bar,false%
    %\.+/home/work/project/.build2/foo,project-foo,true%
    %\.+/home/work/project/.build2/bar,project-bar,true%
    %\.+/home/work/project/.build2/local/foo,project-local-foo,true%
    %\.+/home/work/project/.build2/local/bar,project-local-bar,true%
    %\.+/home/work/project/package/.build2/foo,package-foo,true%
    %\.+/home/work/project/package/.build2/bar,package-bar,true%
    %\.+/home/work/project/package/.build2/local/foo,package-local-foo,true%
    %\.+/home/work/project/package/.build2/local/bar,package-local-bar,true%
    EOO
    %loading local \.+/home/work/project/package/.build2/local/bar%
    %loading local \.+/home/work/project/package/.build2/local/foo%
    %loading local \.+/home/work/project/package/.build2/bar%
    %loading local \.+/home/work/project/package/.build2/foo%
    %overwriting remote \.+/home/work/project/package/.build2/local/bar%
    %overwriting remote \.+/home/work/project/package/.build2/local/foo%
    %overwriting remote \.+/home/work/project/package/.build2/bar%
    %overwriting remote \.+/home/work/project/package/.build2/foo%
    %loading remote \.+/home/work/project/.build2/local/bar%
    %loading remote \.+/home/work/project/.build2/local/foo%
    %loading remote \.+/home/work/project/.build2/bar%
    %loading remote \.+/home/work/project/.build2/foo%
    %loading local \.+/home/work/.build2/local/bar%
    %loading local \.+/home/work/.build2/local/foo%
    %loading local \.+/home/work/.build2/bar%
    %loading local \.+/home/work/.build2/foo%
    %loading local \.+/home/.build2/local/bar%
    %loading local \.+/home/.build2/local/foo%
    %loading local \.+/home/.build2/bar%
    %loading local \.+/home/.build2/foo%
    %loading local \.+/build2/local/bar%
    %loading local \.+/build2/local/foo%
    %loading local \.+/build2/bar%
    %loading local \.+/build2/foo%
    EOE

  : merged
  :
  $* -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir cmd-foo cmd-bar >>EOO
    sys-foo
    sys-bar
    sys-local-foo
    sys-local-bar
    home-foo
    home-bar
    home-local-foo
    home-local-bar
    work-foo
    work-bar
    work-local-foo
    work-local-bar
    project-foo
    project-bar
    project-local-foo
    project-local-bar
    package-foo
    package-bar
    package-local-foo
    package-local-bar
    cmd-foo
    cmd-bar
    EOO

  : no-default-options
  :
  $* -e -t -f foo -f baz -f bar -d $start_dir -s $sys_dir -h $home_dir >>/~%EOO%d 2>>/~%EOE%d
    %\.+/home/work/project/package/.build2/local/foo,package-local-foo,true%
    %\.+/home/work/project/package/.build2/local/baz,--no-default-options,true%
    %\.+/home/work/project/package/.build2/local/bar,package-local-bar,true%
    EOO
    %loading local \.+/home/work/project/package/.build2/local/bar%
    %loading local \.+/home/work/project/package/.build2/local/baz%
    %loading local \.+/home/work/project/package/.build2/local/foo%
    %overwriting remote \.+/home/work/project/package/.build2/local/bar%
    %overwriting remote \.+/home/work/project/package/.build2/local/baz%
    %overwriting remote \.+/home/work/project/package/.build2/local/foo%
    EOE
}

: common-start
:
{
  home_dir = $canonicalize([dir_path] $~/home)

  work_dir = $home_dir/work
  +mkdir -p $work_dir/.build2

  cfg1 = $canonicalize([dir_path] $work_dir/cfg1)
  cfg2 = $canonicalize([dir_path] $work_dir/cfg2)
  cfg3 = $canonicalize([dir_path] $cfg2/cfg3)

  +mkdir -p $work_dir/.build2 $cfg1/.build2 $cfg2/.build2 $cfg3/.build2

  +echo 'work' >=$work_dir/.build2/ops
  +echo 'cfg1' >=$cfg1/.build2/ops
  +echo 'cfg2' >=$cfg2/.build2/ops
  +echo 'cfg3' >=$cfg3/.build2/ops

  : exists
  :
  {
    : single
    :
    $* -f ops -d $cfg3 -h $home_dir >>EOO
      work
      cfg2
      cfg3
      EOO

    : same
    :
    $* -f ops -d $cfg1 -d $cfg1 -h $home_dir >>EOO
      work
      cfg1
      EOO

    : adjacent
    :
    $* -f ops -d $cfg1 -d $cfg2 -h $home_dir >>EOO
      work
      EOO

    : nested
    :
    $* -f ops -d $cfg2 -d $cfg3 -h $home_dir >>EOO
      work
      cfg2
      EOO
  }

  : not-exists
  :
  {
    : home-reached
    :
    $* -f ops -d $cfg1 -d $cfg2 -h $work_dir >>EOO
      work
      EOO

    : root-reached
    :
    if ($cxx.target.class != 'windows')
    {
      $* -f ops -d $cfg1 -d /non-existent-directory/cfg2
    }
  }
}

: extra-dir
:
{
  : after-traversal
  :
  {
    home_dir = $canonicalize([dir_path] $~/home);
    mkdir -p $home_dir/.build2;
    echo 'home' >=$home_dir/.build2/ops;

    extra_dir = $canonicalize([dir_path] $home_dir/extra);
    mkdir -p $extra_dir;
    echo 'extra' >=$extra_dir/ops;

    start_dir = $canonicalize([dir_path] $home_dir/start);
    mkdir -p $start_dir/.build2;
    echo 'start' >=$start_dir/.build2/ops;

    $* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d
      %\.+/home/.build2/ops,home,false%
      %\.+/home/extra/ops,extra,false%
      %\.+/home/start/.build2/ops,start,false%
      EOO
  }

  : inside-traversal
  :
  {
    home_dir = $canonicalize([dir_path] $~/home);
    mkdir -p $home_dir/.build2;
    echo 'home' >=$home_dir/.build2/ops;

    d = $home_dir/project/.build2;
    mkdir -p $d;
    echo 'project' >=$d/ops;

    touch $home_dir/project/.git;

    d = $home_dir/project/package/.build2;
    mkdir -p $d;
    echo 'package' >=$d/ops;

    extra_dir = $canonicalize([dir_path] $home_dir/project/package/extra1);
    mkdir -p $extra_dir;
    echo 'extra1' >=$extra_dir/ops;

    start_dir = $canonicalize([dir_path] $home_dir/project/package);

    $* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d;
      %\.+/home/.build2/ops,home,false%
      %\.+/home/project/.build2/ops,project,true%
      %\.+/home/project/package/.build2/ops,package,true%
      %\.+/home/project/package/extra1/ops,extra1,false%
      EOO

    extra_dir = $canonicalize([dir_path] $home_dir/project/package/.build2);

    $* -e -f ops -d $start_dir -h $home_dir -x $extra_dir/ >>/~%EOO%d;
      %\.+/home/.build2/ops,home,false%
      %\.+/home/project/.build2/ops,project,true%
      %\.+/home/project/package/.build2/ops,package,false%
      EOO

    extra_dir = $canonicalize([dir_path] $home_dir/project/extra2);
    mkdir -p $extra_dir;
    echo 'extra2' >=$extra_dir/ops;

    $* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d;
      %\.+/home/.build2/ops,home,false%
      %\.+/home/project/.build2/ops,project,true%
      %\.+/home/project/extra2/ops,extra2,false%
      %\.+/home/project/package/.build2/ops,package,true%
      EOO

    extra_dir = $canonicalize([dir_path] $home_dir/project/.build2);

    $* -e -f ops -d $start_dir -h $home_dir -x $extra_dir/ >>/~%EOO%d
      %\.+/home/.build2/ops,home,false%
      %\.+/home/project/.build2/ops,project,false%
      %\.+/home/project/package/.build2/ops,package,true%
      EOO
  }
}