chiark / gitweb /
9a818fab14cbb27e910468d9d56875cedce3b598
[dgit.git] / tests / tests / sourceonlypolicy
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-tstunt-parsechangelog
6
7 t-prep-newpackage example 1.0
8
9 cd $p
10 revision=1
11
12 dgit-with-policy () {
13         local policy=$1
14         t-dgit -cdgit-distro.test-dummy.source-only-uploads=$policy "$@"
15 }
16
17 t-expect-fail '' \
18 t-dgit-with-policy not-wholly-new push
19
20 t-dgit -c dgit-distr push --new 
21
22 git tag start
23
24 echo DUMMY >some-file
25 git add some-file
26 git commit -m some-file
27 taint=`git rev-parse HEAD`
28 t-policy-admin taint --global $taint dummy
29 git reset --hard HEAD~
30
31 t-commit 'Make something to autotaint'
32 t-dgit build
33 t-dgit push --new
34
35 autotaint=`t-git-get-ref "refs/tags/$tagpfx/$v"`
36
37 git reset --hard start
38 t-commit 'Thing which will autotaint'
39 t-dgit build
40
41 fifo=$tmp/sqlite-cmds
42 mkfifo $fifo
43 exec 3<>$fifo
44 sqlite3 -interactive $tmp/git/policy.sqlite3 0<$fifo 3>&- &
45 sqlite3_pid=$!
46
47 taintsout=$tmp/sqlite3.taints-out
48 echo >&3 'begin;';
49 echo >&3 ".output $taintsout"
50 echo >&3 'select * from taints;';
51 echo >&3 'create table dummy (x text);'
52
53 t-dgit build
54
55 while ! grep $taint $taintsout; do sleep 0.1; done
56
57 DGIT_RPD_TEST_DBLOOP_HOOK='
58         print STDERR "DBLOOP HOOK $sleepy\n";
59         $poldbh->sqlite_busy_timeout(2500);
60         if ($sleepy > 2) {
61                 system '\''
62                         set -ex
63                         echo >'"$fifo"' "rollback;"
64                         touch '"$tmp/sqlite3.rolled-back"'
65                 '\'' and die "$? $!";
66         }
67 ' \
68 t-dgit push --deliberately-not-fast-forward
69
70 exec 3>&-
71 wait $sqlite3_pid
72
73 ls $tmp/sqlite3.rolled-back
74
75 t-policy-admin list-taints | tee $tmp/taints-list | grep $autotaint
76
77 t-ok