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

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

# Source repository:
#
# rep-info
# |-- testing             -> stable (complement), ../foo/testing (prerequisite)
# |   |-- foo-1.tar.gz
# |   `-- repositories
# |
# `-- git
#     |-- libbar.git      -> style-basic.git (prerequisite)
#     `-- style-basic.git

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

  # Create the unsigned 'testing' repository.
  #
  cp -r $src/testing $out/testing
  $rc $out/testing &$out/testing/packages

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

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

test.options += --auth all --trust-yes

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

: default
:
{
  : unsigned
  :
  $* $rep/testing >>"EOO"
  pkg:build2.org/rep-info/testing ($rep/testing)
  prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing)
  complement pkg:build2.org/rep-info/stable ($rep/stable)

  foo/1
  EOO

  : signed
  :
  $* $rep/signed >>"EOO"
  pkg:build2.org/rep-info/signed ($rep/signed)
  CN=build2.org/O=Code Synthesis/info@build2.org
  $cert_fp
  prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing)
  complement pkg:build2.org/rep-info/stable ($rep/stable)

  foo/1
  EOO
}

: name
:
$* --name $rep/testing >"pkg:build2.org/rep-info/testing ($rep/testing)"

: packages
:
{
  : list
  :
  $* --packages $rep/testing >>EOO

  foo/1
  EOO

  : manifest
  :
  $* --packages --manifest $rep/testing >>EOO
  : 1
  name: foo
  version: 1
  summary: The "Foo" utility
  license: MIT
  url: http://www.example.org/foo
  email: foo-users@example.org
  location: foo-1.tar.gz
  sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e
  EOO
}

: repositories
:
{
  : list
  :
  $* --repositories $rep/testing >>"EOO"
  prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing)
  complement pkg:build2.org/rep-info/stable ($rep/stable)
  EOO

  : manifest
  :
  $* --repositories --manifest $rep/testing >>EOO
  : 1
  location: ../../foo/testing
  type: pkg
  :
  location: ../stable
  type: pkg
  role: complement
  :
  EOO
}

: cert
:
{
  test.arguments += $rep/signed

  $* --cert-fingerprint  >"$cert_fp"        : fingerprint
  $* --cert-name         >'name:build2.org' : name
  $* --cert-organization >'Code Synthesis'  : organization
  $* --cert-email        >'info@build2.org' : email
}

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

  : version-module
  :
  : Version module is enabled for the project.
  :
  $* "$rep/style-basic.git#master" >>~%EOO%
  %git:.+style-basic#master .+style-basic.git#master%

  %style-basic/1\.1\.0-a\.0\..+%
  EOO

  : manifest-lists
  :
  : The packages and repositories files are present in the repository root.
  :
  $* "$rep/libbar.git#master" >>~%EOO%
  %git:.+libbar#master .+libbar.git#master%
  %prerequisite git:.+style-basic#stable .+style-basic.git#stable%

  libbar/1.0.0
  libmbar/1.0.0
  EOO
}