X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Fadd.t;h=0305c8d823c0d554a2b6188bca5b807d61d6b741;hb=86d735d52280359df4896d5c542ddfbe33d8df7b;hp=4f0725d392e65561684e9ad346c6a259325ee247;hpb=c20db3d43f58abb15e22fca0fe12e23ffb21d0d5;p=zpackage diff --git a/t/add.t b/t/add.t index 4f0725d..0305c8d 100755 --- a/t/add.t +++ b/t/add.t @@ -7,20 +7,23 @@ PF=test.db -plan 17 +plan 34 -td=test.addtopackage -rm -rf $td -mkdir $td -echo foo > $td/foo +require rm -rf tmp +require mkdir tmp +cd tmp || bailout 'cannot cd to tmp' + +echo foo > foo okexit 'making foo' -rm -f zpmtest-1.0-1.zpm +pkgid=zpmtest-1.0-1 +PF=zpmtest-1.0-1.zpm -require zpm add -C zpmtest $td/foo -h=$(zpm hash $td/foo) -require zpm extract zpmtest-1.0-1.zpm $h $td/foo2 -h2=$(zpm hash $td/foo2) +require -v zpm newpackage -C $pkgid +require -v zpm add -vvv -f $PF -p $pkgid foo +h=$(zpm hash foo) +require -v zpm extract -f zpmtest-1.0-1.zpm $h foo2 +h2=$(zpm hash foo2) okstreq "$h" "$h2" "foo and foo2 hash match" pkglist=$(zpm showpkg zpmtest-1.0-1.zpm) @@ -28,15 +31,15 @@ set $pkglist okstreq "$1" "zpmtest" package name okstreq "$2" "1.0" package version okstreq "$3" "1" package release -okstreq "$4" "$td/foo" file foo in package +okstreq "$4" "/foo" file foo in package diag "$pkglist" -rm zpmtest-1.0-1.zpm - -require zpm add -C -f $PF zpmtest $td/foo -rm -f $td/foo2 -require zpm extract $PF $h $td/foo2 -h2=$(zpm hash $td/foo2) +rm -f $PF +require zpm newpackage -f $PF -C $pkgid +require zpm add -f $PF -p zpmtest foo +rm -f foo2 +require zpm extract -f $PF $h foo2 +h2=$(zpm hash foo2) okstreq "$h" "$h2" pkglist=$(zpm showpkg $PF) @@ -44,16 +47,48 @@ set $pkglist okstreq "$1" "zpmtest" package name okstreq "$2" "1.0" package version okstreq "$3" "1" package release -okstreq "$4" "$td/foo" file foo in package +okstreq "$4" "/foo" file foo in package diag "$pkglist" rm -f $PF -require zpm add -C -f $PF -S "$td" zpmtest $td/foo +mkdir subdir +touch subdir/foo +require zpm newpackage -f $PF -C $pkgid +require -v zpm add -f $PF -S subdir -p zpmtest subdir/foo fn=$(zpm showpkg $PF | awk '{print $4}') -okstreq "$fn" "foo" file foo in package prefix striped +okstreq "$fn" "/foo" file foo in package prefix striped +rm -f $PF + +require zpm newpackage -f $PF -C $pkgid +require zpm add -f $PF -p zpmtest foo +ph=$(zpm pkg -f $PF zpmtest hash) +okstreq "$ph" "" package hash empty +mtime=$(zpm pkg -f $PF zpmtest build_time) +okstreq "$ph" "" package mtime empty + +zpm add -C -f $PF -p zpmtest subdir/foo +okexit added file and completed package +ph=$(zpm pkg -f $PF zpmtest hash) +test -n "$ph" +okexit package hash not empty +diag "hash: $ph" +mtime=$(zpm pkg -f $PF zpmtest build_time) +test -n "$mtime" +okexit package mtime not empty + +touch subdir/bar +require zpm add -f $PF -p zpmtest subdir/bar +ph=$(zpm pkg -f $PF zpmtest hash) +okstreq "$ph" "" package hash cleared +mtime=$(zpm pkg -f $PF zpmtest build_time) +okstreq "$ph" "" package mtime cleared + +echo junk data > subdir/baz +require zpm add -f $PF subdir/baz +rm $PF +require zpm add -i -f $PF subdir/baz finish -rm -rf $td -rm -f $PF -rm -f zpmtest-1.0-1.zpm +cd .. +rm -rf tmp