aboutsummaryrefslogtreecommitdiff
path: root/tests/pkg-update.testscript
blob: 89833d46cf2488318cb6a041494fead610b1012e (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
# file      : tests/pkg-update.testscript
# license   : MIT; see accompanying LICENSE file

.include common.testscript auth.testscript config.testscript remote.testscript

# Source repository:
#
# pkg-update
# |-- hello
# |   |-- libhello-1.0.0.tar.gz
# |   `-- repositories.manifest
# `-- libhello-1.0.0
#     |-- build
#     |   |-- bootstrap.build
#     |   |-- export.build
#     |   `-- root.build
#     |-- buildfile
#     |-- hello
#     |   |-- buildfile
#     |   |-- export
#     |   |-- hello
#     |   `-- hello.cxx
#     |-- INSTALL
#     |-- manifest
#     |-- tests
#     |   |-- build
#     |   |   |-- bootstrap.build
#     |   |   `-- root.build
#     |   |-- buildfile
#     |   `-- test
#     |       |-- buildfile
#     |       |-- driver.cxx
#     |       `-- test.out
#     `-- version

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

  # Create the signed 'hello' repository.
  #
  cp -r $src/hello $out/hello
  cat <<<$cert_manifest >+$out/hello/repositories.manifest

  $rep_create --key $key $out/hello &$out/hello/packages.manifest \
                                    &$out/hello/signature.manifest
end

config_cxx = [cmdline] config.cxx=$quote($recall($cxx.path) $cxx.config.mode, true)

pkg_configure += -d cfg $config_cxx 2>!
pkg_disfigure += -d cfg
pkg_fetch     += -d cfg 2>!
pkg_purge     += -d cfg
pkg_build     += -d cfg
pkg_unpack    += -d cfg 2>!
rep_add       += -d cfg 2>!
rep_fetch     += -d cfg --auth all 2>!

: no-name
:
$clone_cfg;
$* 2>>EOE != 0
  error: package name argument expected
    info: run 'bpkg help pkg-update' for more information
  EOE

: fetched
:
{
  +$clone_cfg
  +$rep_add $rep/hello
  +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/**

  : no-such-package
  :
  $clone_cfg;
  $* libhello 2>>/EOE != 0
    error: package libhello does not exist in configuration cfg/
    EOE

  : wrong-state
  :
  {
    $clone_cfg && $pkg_fetch libhello/1.0.0;

    $* libhello 2>>EOE != 0;
      error: package libhello is fetched
        info: expected it to be configured
      EOE

    $pkg_purge libhello 2>'purged libhello/1.0.0'
  }

  : src-eq-out
  :
  {
    $clone_cfg;
    $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello;
    $pkg_configure libhello;

    $* libhello 2>>~%EOE%;
      %(c\+\+|ar|ld) .+%{6}
      updated libhello/1.0.0
      EOE

    $* libhello 2>>~%EOE%;
      %info: .+ is up to date%
      updated libhello/1.0.0
      EOE

    $pkg_disfigure libhello 2>'disfigured libhello/1.0.0';
    $pkg_purge     libhello 2>'purged libhello/1.0.0'
  }
}

: src-ne-out
:
{
  $clone_cfg;
  $pkg_unpack -e $src/libhello-1.0.0 && $pkg_configure libhello;

  $* libhello 2>>~%EOE%;
    %(mkdir|c\+\+|ar|ld) .+%{8}
    updated libhello/1.0.0
    EOE

  $* libhello 2>>~%EOE%;
    %info: .+ is up to date%
    updated libhello/1.0.0
    EOE

  $pkg_disfigure libhello 2>'disfigured libhello/1.0.0';
  $pkg_purge     libhello 2>'purged libhello/1.0.0'
}

: vars
:
{
  +$cfg_create cxx $config_cxx -d cfg 2>- &cfg/***
  +$rep_fetch $rep/hello --trust $cert_fp &cfg/.bpkg/certs/**

  : global-and-local
  :
  {
    $clone_cfg;
    $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello;
    $pkg_configure libhello;

    $* -v config.cxx.poptions=-DG libhello +{ config.cxx.poptions+=-DL } 2>>~%EOE%;
      %.+ config\.cxx\.poptions=-DG config\.cxx\.poptions\+=-DL update.+%
      %.{6}
      updated libhello/1.0.0
      EOE

    $pkg_disfigure libhello 2>'disfigured libhello/1.0.0';
    $pkg_purge     libhello 2>'purged libhello/1.0.0'
  }

  : all-packages
  :
  {
    $clone_cfg;
    $pkg_build libhello 2>!; # To hold libhello package.

    $* -v --all config.cxx.poptions=-DG 2>>~%EOE%;
      %.+ config\.cxx\.poptions=-DG update.+%
      %.{6}
      updated libhello/1.0.0
      EOE

    $pkg_disfigure libhello 2>'disfigured libhello/1.0.0';
    $pkg_purge     libhello 2>'purged libhello/1.0.0'
  }

  : var-opts
  :
  {
    $clone_cfg;

    $* config.cxx.poptions=-DG +{ --all } 2>>EOE != 0
      error: unexpected options group for variable 'config.cxx.poptions=-DG'
      EOE
  }
}