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

.include common.testscript config.testscript remote.testscript

# Source repository:
#
# pkg-build
# |
# `-- t0a
#     |-- libbar-0.0.1.tar.gz   -> libbaz == 0.0.1
#     |-- libbaz-0.0.1.tar.gz   -> libfox
#     |-- libbaz-0.0.3.tar.gz   -> libfoo
#     |-- libbox-0.0.1.tar.gz   -> libbaz
#     |-- libfix-0.0.1.tar.gz
#     |-- libfoo-0.0.1.tar.gz   -> libfix
#     |-- libfox-0.0.1.tar.gz
#     `-- repositories.manifest

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

  cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest
end

cfg_create += -d cfg 2>! &cfg/***
pkg_build  += -d cfg --yes --auth all --trust-yes 2>!

+$pkg_build "libbaz@$rep/t0a"

test.options += --build-option -s

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

  : all-all-pattern
  :
  $* --all --all-pattern 'lib*' 2>>EOE != 0
    error: both --all|-a and --all-pattern specified
      info: run 'bpkg help pkg-test' for more information
    EOE

  : all-name
  :
  $* --all libbaz 2>>EOE != 0
    error: both --all|-a and package argument specified
      info: run 'bpkg help pkg-test' for more information
    EOE

  : all-pattern-name
  :
  $* --all-pattern 'lib*' libbaz 2>>EOE != 0
    error: both --all-pattern and package argument specified
      info: run 'bpkg help pkg-test' for more information
    EOE

  : recursive-immediate
  :
  $* libbaz --recursive --immediate 2>>~%EOE% != 0
      error: both --immediate|-i and --recursive|-r specified
        info: run 'bpkg help pkg-test' for more information
      EOE
}

: package
:
{
  $clone_cfg;

  $* libbaz 2>>~%EOE%
      %info: .+ has nothing to test%
      tested libbaz/0.0.3
      EOE
}

: all
:
{
  : src
  :
  {
    $clone_root_cfg;

    $* --all 2>>~%EOE%
        %info: .+ has nothing to test%
        tested libbaz/0.0.3
        EOE
  }

  : sys
  :
  {
    $cfg_create;
    $pkg_build "sys:libbaz@$rep/t0a";

    $* --all 2>'info: nothing to test'
  }
}

: all-pattern
:
{
  : match
  :
  {
    $clone_root_cfg;

    $* --all-pattern 'libf*' --all-pattern 'lib*' --all-pattern 'libz*' 2>>~%EOE%
        %info: .+ has nothing to test%
        tested libbaz/0.0.3
        EOE
  }

  : not-match
  :
  {
    $clone_root_cfg;

    $* --all-pattern 'libf*' 2>'info: nothing to test'
  }
}

: immediate
:
{
  $clone_cfg;

  $* libbaz --immediate 2>>~%EOE%
      %info: .+ has nothing to test%{2}
      tested libbaz/0.0.3
      tested libfoo/0.0.1
      EOE
}

: recursive
:
{
  $clone_cfg;

  $* libbaz --recursive 2>>~%EOE%
      %info: .+ has nothing to test%{3}
      tested libbaz/0.0.3
      tested libfoo/0.0.1
      tested libfix/0.0.1
      EOE
}

: package-cwd
:
{
  $clone_cfg;

  $* libbaz --recursive --package-cwd -v 2>>/~%EOE%
      %(.+ test\('\./'\)|info: .+ has nothing to test)%{6}
      %tested .+%{3}
      EOE
}