aboutsummaryrefslogtreecommitdiff
path: root/tests/rep-remove.test
blob: 98d566f3d528b1890bb540ff5737a6b1146ecb68 (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
# file      : tests/rep-remove.test
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include common.test config.test remote.test remote-git.test

# Source repository:
#
# rep-remove
# |-- extra                     -> stable (prerequisite)
# |   |-- libbar-1.1.0+1.tar.gz
# |   `-- repositories.manifest
# |
# |-- math                      -> extra (prerequisite)
# |   |-- libbar-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# |-- stable                    -> math (prerequisite)
# |   |-- libfoo-1.0.0.tar.gz
# |   `-- repositories.manifest
# |
# `-- testing                   -> stable (complement), extra (prerequisite)
# |   |-- libbar-2.0.0.tar.gz
# |   `-- repositories.manifest
# |
# `-- alpha
# |   |-- libbar-2.0.0.tar.gz
# |   `-- repositories.manifest
# |
# `-- git
#     `-- style-basic.git

# Prepare repositories used by tests if running in the local mode.
#
+if ($remote != true)
  cp -r $src/extra   $out/extra
  cp -r $src/math    $out/math
  cp -r $src/stable  $out/stable
  cp -r $src/testing $out/testing
  cp -r $src/alpha   $out/alpha

  c = $rep_create 2>!

  $c $out/extra   &$out/extra/packages.manifest
  $c $out/math    &$out/math/packages.manifest
  $c $out/stable  &$out/stable/packages.manifest
  $c $out/testing &$out/testing/packages.manifest
  $c $out/alpha   &$out/alpha/packages.manifest

  # Create git repositories.
  #
  $git_extract $src/git/style-basic.tar &$out_git/state0/***
end

rep_add    += -d cfg 2>!
rep_fetch  += -d cfg --auth all --trust-yes 2>!
rep_list   += -d cfg --prerequisites --complements
pkg_status += -d cfg

: invalid-args
:
{
  : clean-all
  :
  $* --clean --all 2>>EOE != 0
  error: both --clean and --all|-a specified
    info: run 'bpkg help rep-remove' for more information
  EOE

  : clean-repos
  :
  $* --clean $rep/extra 2>>EOE != 0
  error: both --clean and repository argument specified
    info: run 'bpkg help rep-remove' for more information
  EOE

  : all-repos
  :
  $* --all $rep/extra 2>>EOE != 0
  error: both --all|-a and repository argument specified
    info: run 'bpkg help rep-remove' for more information
  EOE

  : none
  :
  $* 2>>EOE != 0
  error: repository name or location argument expected
    info: run 'bpkg help rep-remove' for more information
  EOE
}

: clean
:
{
  $clone_cfg;
  $rep_add $rep/extra && $rep_fetch;

  $* --clean 2>>"EOE";
    cleaned pkg:build2.org/rep-remove/extra
    EOE

  $rep_list >>"EOE";
    pkg:build2.org/rep-remove/extra ($rep/extra)
    EOE

  $pkg_status libbar >'unknown'
}

: all
:
{
  $clone_cfg;
  $rep_add $rep/extra && $rep_fetch;

  $* --all 2>>"EOE";
    removed pkg:build2.org/rep-remove/extra
    EOE

  $rep_list >:"";
  $pkg_status libbar >'unknown'
}

: by-name
:
{
  $clone_cfg;
  $rep_add $rep/extra && $rep_fetch;

  $* 'pkg:build2.org/rep-remove/extra' 2>>"EOE";
    removed pkg:build2.org/rep-remove/extra
    EOE

  $rep_list >:"";
  $pkg_status libbar >'unknown'
}

: prerequisites-cycle
:
{
  $clone_cfg;
  $rep_add $rep/testing && $rep_fetch;

  $* $rep/testing 2>>"EOE";
    removed pkg:build2.org/rep-remove/testing
    EOE

  $rep_list >:"";
  $pkg_status libbar >'unknown';
  $pkg_status libfoo >'unknown'
}

: reacheable
:
{
  $clone_cfg;
  $rep_add $rep/testing && $rep_add $rep/math && $rep_fetch;

  $* $rep/testing 2>>"EOE";
    removed pkg:build2.org/rep-remove/testing
    EOE

  $rep_list >>"EOO";
    pkg:build2.org/rep-remove/math ($rep/math)
      prerequisite pkg:build2.org/rep-remove/extra ($rep/extra)
        prerequisite pkg:build2.org/rep-remove/stable ($rep/stable)
          prerequisite pkg:build2.org/rep-remove/math ($rep/math)
    EOO

  $pkg_status libbar >'available 1.0.0 sys:?';
  $pkg_status libfoo >'unknown'
}

: package-locations
:
{
  $clone_cfg;
  $rep_add $rep/testing && $rep_add $rep/alpha && $rep_fetch;

  $* $rep/testing 2>!;
  $pkg_status libbar >'available 2.0.0 sys:?';

  $* $rep/alpha 2>!;
  $pkg_status libbar >'unknown'
}

: git-repos
:
if ($git_supported != true)
{
  # Skip git repository tests.
  #
}
else
{
  rep = "$rep_git/state0"

  : root-complement
  :
  : Test that git repository root complement is handled properly. Note that
  : we also test that the repository state directory is removed. Otherwise
  : the testscript would fail to cleanup the working directory.
  :
  $clone_root_cfg;
  $rep_add "$rep/style-basic.git#master" && $rep_fetch;

  $* "$rep/style-basic.git#master" 2>>~%EOO%
    %removed git:.+style-basic#master%
    EOO
}