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

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

# Source repository:
#
# rep-fetch
# |-- bar
# |   |-- stable                  -> ../foo/stable (prerequisite)
# |   |   |-- libbar-1.0.0.tar.gz -> libfoo >= 1.0.0
# |   |   `-- repositories
# |   |-- testing                 -> stable (complement),
# |   |   |                          ../foo/testing (prerequisite)
# |   |   |-- libbar-1.1.0.tar.gz -> libfoo >= 1.1.0
# |   |   `-- repositories
# |   `-- unstable                -> testing (complement),
# |       |                          ../foo/testing (prerequisite)
# |       |-- libbar-1.1.1.tar.gz  -> libfoo >= 1.1.0
# |       `-- repositories
# |
# |-- foo
# |   |-- stable
# |   |   |-- libfoo-1.0.0.tar.gz
# |   |   `-- repositories
# |   `-- testing                 -> stable (complement)
# |       |-- libfoo-1.1.0.tar.gz
# |       `-- repositories
# |
# `-- hello
# |   |-- libhello-1.0.0.tar.gz
# |   `-- repositories
# |
# `-- git/* (see rep-fetch-git.test)

# Prepare repositories used by tests if running in the local mode.
#
+if ($remote != true)
  rep_create += 2>!

  # Create the signed 'hello' repository.
  #
  cp -r $src/hello $out/hello
  cat <<<$cert_manifest >+$out/hello/repositories
  $rep_create --key $key $out/hello &$out/hello/packages &$out/hello/signature

  # Create 'foo/*' repositories.
  #
  cp -r $src/foo $out/foo
  $rep_create $out/foo/stable  &$out/foo/stable/packages
  $rep_create $out/foo/testing &$out/foo/testing/packages

  # Create 'bar/*' repositories.
  #
  cp -r $src/bar $out/bar
  $rep_create $out/bar/stable   &$out/bar/stable/packages
  $rep_create $out/bar/testing  &$out/bar/testing/packages
  $rep_create $out/bar/unstable &$out/bar/unstable/packages

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

  $git_extract $src/git/state1/libfoo.tar
  $git_extract $src/git/state1/libbaz.tar
  $git_extract $src/git/state1/style.tar
  $git_extract $src/git/state1/style-basic.tar &$out_git/state1/***
end

: no-repos
:
$clone_cfg;
$* 2>>/EOE != 0
  error: configuration cfg/ has no repositories
    info: use 'bpkg rep-add' to add a repository
  EOE

: bpkg-repos
:
{
  test.options += --auth all

  rep_add += -d cfg 2>!

  : hello
  :
  {
    $clone_root_cfg && $rep_add $rep/hello;

    $* --trust $cert_fp 2>>EOE &cfg/.bpkg/certificates/**;
      fetching bpkg:build2.org/rep-fetch/hello
      1 package(s) in 1 repository(s)
      EOE

    $* 2>>EOE
      fetching bpkg:build2.org/rep-fetch/hello
      1 package(s) in 1 repository(s)
      EOE
  }

  : bar-unstable
  :
  {
    $clone_root_cfg && $rep_add $rep/bar/unstable;

    $* --trust-yes 2>>EOE;
      fetching bpkg:build2.org/rep-fetch/bar/unstable
      fetching bpkg:build2.org/rep-fetch/foo/testing (prerequisite of bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/foo/stable (complements bpkg:build2.org/rep-fetch/foo/testing)
      fetching bpkg:build2.org/rep-fetch/bar/testing (complements bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/bar/stable (complements bpkg:build2.org/rep-fetch/bar/testing)
      5 package(s) in 5 repository(s)
      EOE

    $* 2>>EOE
      fetching bpkg:build2.org/rep-fetch/bar/unstable
      fetching bpkg:build2.org/rep-fetch/foo/testing (prerequisite of bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/foo/stable (complements bpkg:build2.org/rep-fetch/foo/testing)
      fetching bpkg:build2.org/rep-fetch/bar/testing (complements bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/bar/stable (complements bpkg:build2.org/rep-fetch/bar/testing)
      5 package(s) in 5 repository(s)
      EOE
  }

  : both
  :
  {
    $clone_root_cfg && $rep_add $rep/hello && $rep_add $rep/bar/unstable;

    $* --trust-yes 2>>EOE &cfg/.bpkg/certificates/**;
      fetching bpkg:build2.org/rep-fetch/bar/unstable
      fetching bpkg:build2.org/rep-fetch/foo/testing (prerequisite of bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/foo/stable (complements bpkg:build2.org/rep-fetch/foo/testing)
      fetching bpkg:build2.org/rep-fetch/bar/testing (complements bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/bar/stable (complements bpkg:build2.org/rep-fetch/bar/testing)
      fetching bpkg:build2.org/rep-fetch/hello
      6 package(s) in 6 repository(s)
      EOE

    $* 2>>EOE
      fetching bpkg:build2.org/rep-fetch/bar/unstable
      fetching bpkg:build2.org/rep-fetch/foo/testing (prerequisite of bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/foo/stable (complements bpkg:build2.org/rep-fetch/foo/testing)
      fetching bpkg:build2.org/rep-fetch/bar/testing (complements bpkg:build2.org/rep-fetch/bar/unstable)
      fetching bpkg:build2.org/rep-fetch/bar/stable (complements bpkg:build2.org/rep-fetch/bar/testing)
      fetching bpkg:build2.org/rep-fetch/hello
      6 package(s) in 6 repository(s)
      EOE
  }
}

: git-repos
:
if ($git_supported != true)
{
  # Skip git repository tests.
  #
}
elif ($remote != true)
{
  git_protocol = 'local'
  .include rep-fetch-git.test
}
else
{
  : https-dumb
  :
  {
    git_protocol = 'https-dumb'
    .include rep-fetch-git.test
  }

  : https-smart
  :
  {
    git_protocol = 'https-smart'
    .include rep-fetch-git.test
  }

  : https-smart-unadv
  :
  {
    git_protocol = 'https-smart-unadv'
    .include rep-fetch-git.test
  }

  : git
  :
  {
    git_protocol = 'git'
    .include rep-fetch-git.test
  }
}