diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2018-07-15 01:19:54 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-10-07 18:15:03 -0400 |
commit | 34aa73f940843fcbb9a7849fedd4940fce824b4a (patch) | |
tree | 3690449e433885a0e0daa5669840c4a53096f3b9 | |
parent | 6ea24d6e2e429b5b101e9943dbe60af7ab986ae2 (diff) |
test: Resolve "TODO: Does not fail if one arch is missing"
- Implement the TODO by keeping a list/set of architectures found via
"$repo-$arch" directory names, and another list/set of architectures
named in arch=() in the PKGBUILD(s). This means turning the simple
`compgen` in to a loop.
- While we're at it loading PKGBUILDs in a loop, fix that it clearly isn't
doing anything with the $pkgver argument; it should verify that the
version in the found PKGBUILD(s) matches that argument.
- Use extglob to more strictly match the "arch" part of the "repo-arch"
dirname; the existing glob wouldn't have behaved correctly for values of
$repo containing a "-" (like "community-testing"). We don't currently
test with any of those, but it makes me nervous.
- Also make that extglob change in checkRemovedPackage. While we're at
it, just use an array assignment to do glob expansion, instead of
compgen; it means we don't have to worry about escaping the non-glob
part of the string. Not that we expect it to contain anything needing
escaping, but again, it made me nervous.
-rw-r--r-- | test/lib/common.bash | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/test/lib/common.bash b/test/lib/common.bash index 5ba31e4..83aaac4 100644 --- a/test/lib/common.bash +++ b/test/lib/common.bash @@ -1,4 +1,5 @@ . /usr/share/makepkg/util.sh +shopt -s extglob __updatePKGBUILD() { local pkgrel @@ -227,8 +228,27 @@ checkPackage() { 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 + + local dirarches=() pkgbuildarches=() + local pkgbuild dirarch pkgbuildver + for pkgbuild in "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-"+([^-])"/PKGBUILD"; do + [[ -e $pkgbuild ]] || continue + dirarch=${pkgbuild%/PKGBUILD} + dirarch=${dirarch##*-} + + dirarches+=("$dirarch") + pkgbuildarches+=($(. "$pkgbuild"; echo ${arch[@]})) + pkgbuildver=$(. "$pkgbuild"; get_full_version) + [[ $pkgver = "$pkgbuildver" ]] + done + # Verify that the arches-from-dirnames and + # arches-from-PKGBUILDs agree (that a PKGBUILD existed for + # every arch). + (( ${#dirarches[@]} > 0 )) + read -d '' -r -a dirarches < <(printf '%s\0' "${dirarches[@]}" | sort -uz) + read -d '' -r -a pkgbuildarches < <(printf '%s\0' "${pkgbuildarches[@]}" | sort -uz) + declare -p dirarches pkgbuildarches + [[ "${dirarches[*]}" = "${pkgbuildarches[*]}" ]] checkPackageDB "$repo" "$pkgbase" "$pkgver" } @@ -238,7 +258,8 @@ checkRemovedPackage() { local pkgbase=$2 svn up -q "${TMP}/svn-packages-copy/${pkgbase}" - if compgen -G "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-*" >/dev/null; then + + if __isGlobfile "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-"+([^-])"/PKGBUILD"; then return 1 fi |