]> git.donarmstrong.com Git - wannabuild.git/blob - tests/tests.sh
Prevent test suite to send out mails
[wannabuild.git] / tests / tests.sh
1 #!/bin/bash
2
3 #
4 # This file runs wanna-build in a clean environment to make sure, certain
5 # features work as expected.
6 #
7 # At the moment it
8 #  * Uploads a source
9 #  * Take the build
10 #  * Marks it as uploaded
11 #  * Uploads a source with build-depends
12 #  - Makes sure the package is marked Dep-Wait
13 #  * Uploads a new version of the dependency
14 #  - Makes sure the Dep-Wait is cleared
15 #
16
17 parent_pid=$$
18
19 function assert {
20         if ! eval $1
21         then
22                 echo "Assertion failed: $1"
23                 exit 1;
24         fi
25 }
26
27 function assert_grep {
28         cat > $testdir/assert_grep
29         if ! grep -q "$1" $testdir/assert_grep 
30         then
31           echo "Could not find expected \"$1\" in:"
32           cat $testdir/assert_grep
33           # We are in a pipe, i.e. a subshell, so kill the parent 
34           kill -TERM $parent_pid
35           exit 1
36         fi
37 }
38
39 cd "$(dirname $0)"/..
40
41 assert "[ -e bin/wanna-build ]"
42
43 testdir=./tests/tmp
44 rm -rf $testdir
45 mkdir -p $testdir
46
47 # This is a fake configuration file to make sure we do not interfere with a
48 # possibly installed wanna-build instance
49 cat > $testdir/wanna-build.conf <<__END__
50 \$basedir = "$testdir/db";
51 \$ignore_epochs = 0;
52 \$db_maint = "wb-team\@dontsend.buildd.debian.org";
53 \$notforus_maint = "notforus\@dontsend.buildd.debian.org";
54 \$stat_mail = "wb-team\@dontsend.buildd.debian.org";
55 \$buildd_domain = "buildd.debian.org";
56 \$web_stats = "/var/www/buildd/stats.txt";
57 @sections = qw(main contrib non-US/main non-US/contrib);
58 \$pkgs_source = "$testdir/ftp";
59 \$quinn_source = "$testdir/quinn-diff-output";
60 \$quinn_source_multi_section = 0;
61 @admin_users = qw(wbadm $USER);
62 \$mailprog = "/bin/true";
63 %distributions = (
64         "unstable" => { },
65 );
66 # don't remove this, Perl needs it:
67 1;
68 __END__
69
70 mkdir $testdir/db;
71 mkdir $testdir/db/amd64;
72
73 function wanna-build {
74         # Here we make sure that the "require /etc/wanan-build.conf" does not
75         # have effect, and load our own file instead.
76         echo "Executing wanna-build" "$@" >&2
77         export PERL5LIB=/home/jojo/debian/wanna-build/testsetup/bin
78         perl -e '
79           package conf;
80           do "./tests/tmp/wanna-build.conf";
81           $INC{"/etc/wanna-build.conf"}=1;
82           package main;
83           my $ret;
84           eval {
85                 require "./bin/wanna-build";
86           };
87           if ($@) { die $@; }
88         ' -- "$@"
89 }
90
91 # Create database
92 wanna-build -A amd64 -b amd64/build-db --create-db --info no-package-1.2.3
93
94 echo Load some sources
95 wanna-build -A amd64 -b amd64/build-db --merge-all <(cat <<__END__ 
96 Package: bin-a-indep
97 Version: 1
98 Architecture: all
99 Source: src-a
100 __END__
101 ) <( cat <<__END__ 
102 misc/src-a_1.dsc [optional:uncompiled]
103 __END__
104 )  <( cat <<__END__
105 Package: src-a
106 Version: 1
107 Architecture: any
108 Section: misc
109 Priority: standard
110 Build-Depends: compiler
111 Binary: bin-a-indep,bin-a-1
112 __END__
113 )
114
115 # Test that they exist are in state Needs-Build
116 wanna-build -A amd64 -b amd64/build-db --info src-a | assert_grep ' State.*: Needs-Build'
117
118 echo Take for building
119 wanna-build -A amd64 -b amd64/build-db --take src-a_1
120 wanna-build -A amd64 -b amd64/build-db --info src-a | assert_grep ' State.*: Building'
121
122 echo Upload binaries
123 wanna-build -A amd64 -b amd64/build-db --uploaded src-a_1
124 wanna-build -A amd64 -b amd64/build-db --info src-a | assert_grep ' State.*: Uploaded'
125
126 echo Load the binaries for the sources
127 wanna-build -A amd64 -b amd64/build-db --merge-all <(cat <<__END__ 
128 Package: bin-a-indep
129 Version: 1
130 Architecture: all
131 Source: src-a
132
133 Package: bin-a-1
134 Version: 1
135 Architecture: amd64
136 Source: src-a
137 __END__
138 ) <( cat <<__END__ 
139 __END__
140 )  <( cat <<__END__
141 Package: src-a
142 Version: 1
143 Architecture: any
144 Section: misc
145 Priority: standard
146 Build-Depends: compiler
147 Binary: bin-a-indep,bin-a-1
148 __END__
149 )
150
151 # Test that they exist are in state Needs-Build
152 wanna-build -A amd64 -b amd64/build-db --info src-a | assert_grep ' State .*: Installed'
153
154 echo Upload another source that needs bin-a-1 in Version 2
155 wanna-build -A amd64 -b amd64/build-db --merge-all <(cat <<__END__ 
156 Package: bin-a-indep
157 Version: 1
158 Architecture: all
159 Source: src-a
160
161 Package: bin-a-1
162 Version: 1
163 Architecture: amd64
164 Source: src-a
165 __END__
166 ) <( cat <<__END__ 
167 misc/src-b_1.dsc [optional:uncompiled]
168 __END__
169 )  <( cat <<__END__
170 Package: src-a
171 Version: 1
172 Architecture: any
173 Section: misc
174 Priority: standard
175 Build-Depends: compiler
176 Binary: bin-a-indep,bin-a-1
177
178 Package: src-b
179 Version: 1
180 Architecture: any
181 Section: misc
182 Priority: standard
183 Build-Depends: bin-a-1 (>= 2)
184 Binary: bin-b
185 __END__
186 )
187
188 wanna-build -A amd64 -b amd64/build-db --info src-b | assert_grep "bin-a-1 (>= 2)"
189
190 echo Uploading the new source with an updated binary package
191 wanna-build -A amd64 -b amd64/build-db --merge-all <(cat <<__END__ 
192 Package: bin-a-indep
193 Version: 2
194 Architecture: all
195 Source: src-a
196
197 Package: bin-a-1
198 Version: 2
199 Architecture: amd64
200 Source: src-a
201 __END__
202 ) <( cat <<__END__ 
203 misc/src-a_1.dsc [optional:uncompiled]
204 misc/src-b_1.dsc [optional:uncompiled]
205 __END__
206 )  <( cat <<__END__
207 Package: src-a
208 Version: 1
209 Architecture: any
210 Section: misc
211 Priority: standard
212 Build-Depends: compiler
213 Binary: bin-a-indep,bin-a-1,bin-a-2
214
215 Package: src-b
216 Version: 1
217 Architecture: any
218 Section: misc
219 Priority: standard
220 Build-Depends: bin-a-1 (>= 2)
221 Binary: bin-b
222 __END__
223 )
224
225 wanna-build -A amd64 -b amd64/build-db --info src-b | assert_grep "State.*:.*Needs-Build"
226
227 echo "Finished sucessfully"