#!/bin/bash cachedir=/var/cache/pacman/pkg test_path() { local -a packages=("$cachedir"/*.pkg.tar.xz) printf $'\e[1;33m::\e[0m Testing path: `%s\'\n' "$1" ./scripts/repo-add "$1" "${packages[0]}" } paths=(foo.db.tar.gz::0 ../foo.db.tar.gz::0 /foo.db.tar.gz::1 /tmp/foo.files.tar.gz::0 /mnt/lol/foo.files.tar.gz::1) if [[ ! -f ./scripts/repo-add ]]; then printf './scripts/repo-add not found!\n' exit 1 fi # path check regression testing for path in "${paths[@]}"; do res=${path##*::} repo=${path%%::*} test_path "$repo" ret=$? printf 'got %d, expected %d: ' $ret $res if (( ret == res )); then printf "\e[1;32mPASS\e[0m\n" (( ++success )) else printf "\e[1;31mFAIL\e[0m\n" (( ++failure )) continue fi rm -f "$repo" "${repo%.tar.gz}" done # bash3 v. bash4 printf 'comparing bash3 repo tarball to bash4\n' if type -P bash3 &>/dev/null; then { bash3 ./scripts/repo-add bash3.db.tar "$cachedir"/a*.pkg.tar.xz bash ./scripts/repo-add bash4.db.tar "$cachedir"/a*.pkg.tar.xz } &>/dev/null else printf 'bash3 not found -- skipping test\n' fi diff -u <(bsdtar xOf bash3.db.tar) <(bsdtar xOf bash4.db.tar) res=0 ret=$? printf 'got %d, expected %d: ' $ret $res if (( ret == res )); then printf "\e[1;32mPASS\e[0m\n" (( ++success )) else printf "\e[1;31mFAIL\e[0m\n" (( ++failure )) fi rm bash?.db* echo if (( failure )); then printf '%s tests failed\n' "$failure" else printf 'all tests passed!\n' fi