]> pd.if.org Git - zpackage/blob - t/scripts.t
add test for pre-install script failure
[zpackage] / t / scripts.t
1 #!/bin/sh
2
3 # test addfile
4
5 . tap.sh
6
7 plan 16
8
9 PF=test.db
10 pkgid=scriptrunner-1.0-1
11
12 require rm -rf tmp
13 require mkdir tmp
14 cd tmp 2>/dev/null || bailout "can't cd to tmp"
15
16 require zpm init $PF
17 require zpm newpackage -f $PF $pkgid
18
19 tryrun zpm setscript -f $PF scriptrunner-1.0-1 configure /bin/true
20 tryrun zpm runscript -f $PF -p configure scriptrunner-1.0-1
21 tryrun zpm setscript -f $PF scriptrunner-1.0-1 configure /bin/false
22 zpm runscript -f $PF -p configure scriptrunner-1.0-1 2>/dev/null
23 failsok failure script fails
24
25 zpm runscript -f $PF -p nosuchphase -R scriptrunner-1.0-1 2>/dev/null
26 failsok required non-existing script fails
27 tryrun zpm runscript -f $PF -p nosuchphase scriptrunner-1.0-1 2>/dev/null
28
29 cat >script <<-'EOC'
30 #!/bin/sh
31 echo $1
32 EOC
33 tryrun zpm setscript -f $PF scriptrunner-1.0-1 configure script
34 first=$(zpm runscript -f $PF -p configure -o - scriptrunner-1.0-1)
35 okexit first arg script
36 okstreq "$first" "scriptrunner-1.0-1" "first arg value"
37
38 cat >script <<-'EOC'
39 #!/bin/sh
40 echo $2
41 EOC
42 tryrun zpm setscript -f $PF scriptrunner-1.0-1 configure script
43 second=$(zpm runscript -f $PF -p configure -o - scriptrunner-1.0-1 secondarg)
44 okexit second arg script
45 okstreq "$second" "secondarg" "second arg value"
46
47 cd ..
48 rm -rf tmp
49
50 finish
51
52 rm -f $PF