summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2018-07-13 11:23:42 -0400
committerLuke Shumaker <lukeshu@parabola.nu>2018-10-07 18:15:03 -0400
commit54dba5837495e03fe45862c8c946e7d0cf19403f (patch)
tree2acae00430553ebedf40583e8abdec44e2308031
parent297fd7bffb8c883efc4f312e92179047a88c6759 (diff)
test: checkPackageDB(): Resolve "FIXME: We guess the location of the PKGBUILD"
The problem statement: checkPackageDB and checkRemovedPackageDB need bit of information on the package they're checking: a full list of pkgnames with that pkgbase, the list of pkgarches, and (for checkPackageDB only) the full version. In dbscripts itself, we can get that directly from the .db files; however, since the test suite is checking the ability of dbscripts to edit those .db files, that's obviously not a good solution. The current solution is to get this information from the PKGBUILD... which we also count on dbscripts to correctly keep track of. Wait, that's skipping ahead, let's back up. The current solution is to get this information from the PKGBUILD. For checkRemovedPackageDB, that's easy; we just get it from trunk, as that's the most up-to-date information on the package as-it-would-have-existed (if that sounded a little hand-wavey, it was). But for checkPackageDB, it's a little trickier, because of 2 factors working together: (1) there might be different versions on different repos, and (2) unlike checkRemovedPackageDB, checkPackageDB actually cares about pkgver. So, checkPackageDB "guesses" the location in a slightly sloppy way, and is tagged with a "FIXME". What todo about it? There are a couple of things to observe: - Hidden in the hand-waving in assuming that "trunk" is fine for checkRemovedPackageDB is the assumption that neither pkgname=() nor arch=() is going to change between versions. Which is a fine assumption, because we don't change those things between versions in any of our test cases. - We're counting on dbscripts correctly keeping track of which PKGBUILD is correct for which repo... which is one of the thing's we're trying to test, we shouldn't be counting on it. That's actually a bigger problem than the original "FIXME"! So, putting those things together, let's (1) take the code under test out of the equation, and (2) remove any suggestion that the version of the PKGBUILD makes a difference to pkgnames/pkgarches: Let's have both functions that that information from the PKGBUILDs under "fixtures/", rather than getting PKGBUILDs from VCS. That just leaves one question: How to get the correct pkgver in checkPackageDB? The obvious answer is: Each test case knows what the version should be; add it as an argument, and adjust every testcase that calls it.
-rw-r--r--test/cases/db-move.bats20
-rw-r--r--test/cases/db-repo-add.bats6
-rw-r--r--test/cases/db-update.bats22
-rw-r--r--test/cases/ftpdir-cleanup.bats6
-rw-r--r--test/cases/testing2x.bats2
-rw-r--r--test/lib/common.bash26
6 files changed, 35 insertions, 47 deletions
diff --git a/test/cases/db-move.bats b/test/cases/db-move.bats
index 27fe8d1..eb77ef9 100644
--- a/test/cases/db-move.bats
+++ b/test/cases/db-move.bats
@@ -15,8 +15,8 @@ load ../lib/common
db-move testing extra pkg-simple-a
checkRemovedPackage testing pkg-simple-a
- checkPackage extra pkg-simple-a
- checkPackage testing pkg-simple-b
+ checkPackage extra pkg-simple-a 1-1
+ checkPackage testing pkg-simple-b 1-1
}
@test "move multiple packages" {
@@ -35,7 +35,7 @@ load ../lib/common
for pkgbase in ${pkgs[@]}; do
checkRemovedPackage testing ${pkgbase}
- checkPackage extra ${pkgbase}
+ checkPackage extra ${pkgbase} 1-1
done
}
@@ -54,8 +54,8 @@ load ../lib/common
db-move testing extra pkg-single-arch
checkRemovedPackage testing pkg-single-arch
- checkPackage extra pkg-single-arch
- checkPackage testing pkg-simple-b
+ checkPackage extra pkg-single-arch 1-1
+ checkPackage testing pkg-simple-b 1-1
}
@test "move epoch packages" {
@@ -73,7 +73,7 @@ load ../lib/common
db-move testing extra pkg-simple-epoch
checkRemovedPackage testing pkg-simple-epoch
- checkPackage extra pkg-simple-epoch
+ checkPackage extra pkg-simple-epoch 1:1-1
}
@test "move any packages" {
@@ -87,9 +87,9 @@ load ../lib/common
db-update
db-move testing extra pkg-any-a
- checkPackage extra pkg-any-a
+ checkPackage extra pkg-any-a 1-1
checkRemovedPackage testing pkg-any-a
- checkPackage testing pkg-any-b
+ checkPackage testing pkg-any-b 1-1
}
@test "move split packages" {
@@ -106,6 +106,6 @@ load ../lib/common
db-update
db-move testing extra pkg-split-a
- checkPackage extra pkg-split-a
- checkPackage testing pkg-split-b
+ checkPackage extra pkg-split-a 1-1
+ checkPackage testing pkg-split-b 1-1
}
diff --git a/test/cases/db-repo-add.bats b/test/cases/db-repo-add.bats
index ac91058..e49c2fa 100644
--- a/test/cases/db-repo-add.bats
+++ b/test/cases/db-repo-add.bats
@@ -36,7 +36,7 @@ __movePackageToRepo() {
done
for pkgbase in ${pkgs[@]}; do
- checkPackageDB extra ${pkgbase}
+ checkPackageDB extra ${pkgbase} 1-1
done
}
@@ -60,7 +60,7 @@ __movePackageToRepo() {
done
for pkgbase in ${pkgs[@]}; do
- checkPackageDB extra ${pkgbase}
+ checkPackageDB extra ${pkgbase} 1-1
done
}
@@ -77,6 +77,6 @@ __movePackageToRepo() {
done
for pkgbase in ${pkgs[@]}; do
- checkPackageDB extra ${pkgbase}
+ checkPackageDB extra "${pkgbase}" 1-1
done
}
diff --git a/test/cases/db-update.bats b/test/cases/db-update.bats
index 3bf82b0..9ee0632 100644
--- a/test/cases/db-update.bats
+++ b/test/cases/db-update.bats
@@ -13,20 +13,20 @@ load ../lib/common
db-update
for pkgbase in ${pkgs[@]}; do
- checkPackage extra ${pkgbase}
+ checkPackage extra ${pkgbase} 1-1
done
}
@test "add single simple package" {
releasePackage extra 'pkg-single-arch'
db-update
- checkPackage extra 'pkg-single-arch'
+ checkPackage extra 'pkg-single-arch' 1-1
}
@test "add single epoch package" {
releasePackage extra 'pkg-single-epoch'
db-update
- checkPackage extra 'pkg-single-epoch'
+ checkPackage extra 'pkg-single-epoch' 1:1-1
}
@test "add any packages" {
@@ -40,7 +40,7 @@ load ../lib/common
db-update
for pkgbase in ${pkgs[@]}; do
- checkPackage extra ${pkgbase}
+ checkPackage extra ${pkgbase} 1-1
done
}
@@ -58,7 +58,7 @@ load ../lib/common
db-update
for pkgbase in ${pkgs[@]}; do
- checkPackage extra ${pkgbase}
+ checkPackage extra ${pkgbase} 1-1
done
}
@@ -71,7 +71,7 @@ load ../lib/common
releasePackage extra pkg-any-a
db-update
- checkPackage extra pkg-any-a
+ checkPackage extra pkg-any-a 1-2
}
@test "update any package to different repositories at once" {
@@ -83,14 +83,14 @@ load ../lib/common
db-update
- checkPackage extra pkg-any-a
- checkPackage testing pkg-any-a
+ checkPackage extra pkg-any-a 1-1
+ checkPackage testing pkg-any-a 1-2
}
@test "update same any package to same repository fails" {
releasePackage extra pkg-any-a
db-update
- checkPackage extra pkg-any-a
+ checkPackage extra pkg-any-a 1-1
PKGEXT=.pkg.tar.gz releasePackage extra pkg-any-a
run db-update
@@ -109,7 +109,7 @@ load ../lib/common
releasePackage extra pkg-any-a
db-update
- checkPackage extra pkg-any-a
+ checkPackage extra pkg-any-a 1-1
releasePackage testing pkg-any-a
run db-update
@@ -140,7 +140,7 @@ load ../lib/common
releasePackage extra 'pkg-any-a'
releasePackage unknown 'pkg-any-b'
db-update
- checkPackage extra 'pkg-any-a'
+ checkPackage extra 'pkg-any-a' 1-1
[ ! -e "${FTP_BASE}/unknown" ]
rm -rf "${STAGING}/unknown/"
}
diff --git a/test/cases/ftpdir-cleanup.bats b/test/cases/ftpdir-cleanup.bats
index 7645278..de2d2d9 100644
--- a/test/cases/ftpdir-cleanup.bats
+++ b/test/cases/ftpdir-cleanup.bats
@@ -45,7 +45,7 @@ __checkRepoRemovedPackage() {
__checkRepoRemovedPackage extra 'pkg-simple-a' ${arch}
done
- checkPackage extra pkg-simple-b
+ checkPackage extra pkg-simple-b 1-1
}
@test "cleanup epoch packages" {
@@ -92,7 +92,7 @@ __checkRepoRemovedPackage() {
__checkRepoRemovedPackage extra 'pkg-any-a' ${arch}
done
- checkPackage extra pkg-any-b
+ checkPackage extra pkg-any-b 1-1
}
@test "cleanup split packages" {
@@ -119,7 +119,7 @@ __checkRepoRemovedPackage() {
done
checkRemovedPackage extra ${pkgs[0]}
- checkPackage extra ${pkgs[1]}
+ checkPackage extra ${pkgs[1]} 1-1
}
@test "cleanup old packages" {
diff --git a/test/cases/testing2x.bats b/test/cases/testing2x.bats
index f9f04e2..6127cf9 100644
--- a/test/cases/testing2x.bats
+++ b/test/cases/testing2x.bats
@@ -11,6 +11,6 @@ load ../lib/common
testing2x pkg-any-a
- checkPackage core pkg-any-a
+ checkPackage core pkg-any-a 1-2
checkRemovedPackage testing pkg-any-a
}
diff --git a/test/lib/common.bash b/test/lib/common.bash
index cfd9784..5ba31e4 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -172,6 +172,7 @@ updateRepoPKGBUILD() {
checkPackageDB() {
local repo=$1
local pkgbase=$2
+ local pkgver=$3
local db
local pkgarch
local repoarch
@@ -179,20 +180,8 @@ checkPackageDB() {
local pkgfile
local pkgname
- # FIXME: We guess the location of the PKGBUILD used for this repo
- # We cannot read from trunk as __updatePKGBUILD() might have bumped the version
- # and different repos can have different versions of the same package
- local pkgbuildPaths=($(compgen -G "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-*"))
- local pkgbuildPath="${pkgbuildPaths[0]}"
- echo Repo is $repo
- echo pkgbuildPaths = ${pkgbuildPaths[@]}
- echo pkgbuildPath = ${pkgbuildPath}
- ls -ahl ${TMP}/svn-packages-copy/${pkgbase}/repos/
- [ -r "${pkgbuildPath}/PKGBUILD" ]
-
- local pkgarches=($(. "${pkgbuildPath}/PKGBUILD"; echo ${arch[@]}))
- local pkgnames=($(. "${pkgbuildPath}/PKGBUILD"; echo ${pkgname[@]}))
- local pkgver=$(. "${pkgbuildPath}/PKGBUILD"; get_full_version)
+ local pkgarches=($(. "fixtures/$pkgbase/PKGBUILD"; echo ${arch[@]}))
+ local pkgnames=($(. "fixtures/$pkgbase/PKGBUILD"; echo ${pkgname[@]}))
if [[ ${pkgarches[@]} == any ]]; then
repoarches=(${ARCHES[@]})
@@ -235,12 +224,13 @@ checkPackageDB() {
checkPackage() {
local repo=$1
local pkgbase=$2
+ local pkgver=$3
svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
# TODO: Does not fail if one arch is missing
compgen -G "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-*" >/dev/null
- checkPackageDB $repo $pkgbase
+ checkPackageDB "$repo" "$pkgbase" "$pkgver"
}
checkRemovedPackage() {
@@ -266,10 +256,8 @@ checkRemovedPackageDB() {
local pkgnames
local pkgname
- local pkgbuildPath="${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"
- [[ -r ${pkgbuildPath} ]]
- pkgarches=($(. "${pkgbuildPath}"; echo ${arch[@]}))
- pkgnames=($(. "${pkgbuildPath}"; echo ${pkgname[@]}))
+ pkgarches=($(. "fixtures/$pkgbase/PKGBUILD"; echo ${arch[@]}))
+ pkgnames=($(. "fixtures/$pkgbase/PKGBUILD"; echo ${pkgname[@]}))
if [[ ${pkgarches[@]} == any ]]; then
tarches=(${ARCHES[@]})