forked from rcrowley/freight
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from yegorich/ci-test-fixes
CI: perform test scripts linting
- Loading branch information
Showing
5 changed files
with
92 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,46 +5,46 @@ load apt_helpers | |
|
||
setup() { | ||
freight_init | ||
freight_add ${FIXTURES}/test_1.0_all.deb apt/example | ||
freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp | ||
freight_add "${FIXTURES}"/test_1.0_all.deb apt/example | ||
freight_add "${FIXTURES}"/test_1.0_all.deb apt/example/comp | ||
configure_local_apt | ||
} | ||
|
||
@test "freight-cache builds distro Release/InRelease file" { | ||
freight_cache -v | ||
test -e ${FREIGHT_CACHE}/dists/example/Release | ||
egrep "^Components: comp main" ${FREIGHT_CACHE}/dists/example/Release | ||
test -e ${FREIGHT_CACHE}/dists/example/InRelease | ||
egrep "^Components: comp main" ${FREIGHT_CACHE}/dists/example/InRelease | ||
test -e "${FREIGHT_CACHE}"/dists/example/Release | ||
grep -E "^Components: comp main" "${FREIGHT_CACHE}"/dists/example/Release | ||
test -e "${FREIGHT_CACHE}"/dists/example/InRelease | ||
grep -E "^Components: comp main" "${FREIGHT_CACHE}"/dists/example/InRelease | ||
} | ||
|
||
@test "freight-cache builds per-component Release file" { | ||
freight_cache -v | ||
test -e ${FREIGHT_CACHE}/dists/example/comp/binary-amd64/Release | ||
test -e ${FREIGHT_CACHE}/dists/example/main/binary-amd64/Release | ||
test -e "${FREIGHT_CACHE}"/dists/example/comp/binary-amd64/Release | ||
test -e "${FREIGHT_CACHE}"/dists/example/main/binary-amd64/Release | ||
} | ||
|
||
@test "freight-cache builds pool" { | ||
freight_cache -v | ||
test -e ${FREIGHT_CACHE}/pool/example/comp/t/test/test_1.0_all.deb | ||
test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/comp/t/test/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/main/t/test/test_1.0_all.deb | ||
} | ||
|
||
@test "freight-cache generates valid Release/InRelease signatures" { | ||
freight_cache -v | ||
gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release | ||
gpg --verify ${FREIGHT_CACHE}/dists/example/InRelease | ||
gpg --verify "${FREIGHT_CACHE}"/dists/example/Release.gpg "${FREIGHT_CACHE}"/dists/example/Release | ||
gpg --verify "${FREIGHT_CACHE}"/dists/example/InRelease | ||
} | ||
|
||
@test "freight-cache signs Release/InRelease with two keys" { | ||
sed -i 's/^GPG=.*/GPG="[email protected] [email protected]"/' $FREIGHT_CONFIG | ||
sed -i 's/^GPG=.*/GPG="[email protected] [email protected]"/' "$FREIGHT_CONFIG" | ||
freight_cache -v | ||
|
||
gpg --status-fd 1 --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release >/tmp/verify.out | ||
gpg --status-fd 1 --verify "${FREIGHT_CACHE}"/dists/example/Release.gpg "${FREIGHT_CACHE}"/dists/example/Release >/tmp/verify.out | ||
run grep -c GOODSIG /tmp/verify.out | ||
assert_output "2" | ||
|
||
gpg --status-fd 1 --verify ${FREIGHT_CACHE}/dists/example/InRelease >/tmp/verify.out | ||
gpg --status-fd 1 --verify "${FREIGHT_CACHE}"/dists/example/InRelease >/tmp/verify.out | ||
run grep -c GOODSIG /tmp/verify.out | ||
assert_output "2" | ||
} | ||
|
@@ -57,37 +57,37 @@ setup() { | |
@test "apt-get fetches package list" { | ||
check_apt_support | ||
freight_cache -v | ||
echo "deb file://${FREIGHT_CACHE} example main" > ${TMPDIR}/apt/etc/apt/sources.list | ||
apt-get -c ${FIXTURES}/apt.conf update | ||
apt-cache -c ${FIXTURES}/apt.conf show test | ||
echo "deb file://${FREIGHT_CACHE} example main" > "${TMPDIR}"/apt/etc/apt/sources.list | ||
apt-get -c "${FIXTURES}"/apt.conf update | ||
apt-cache -c "${FIXTURES}"/apt.conf show test | ||
} | ||
|
||
@test "freight-cache removes deleted packages from pool" { | ||
freight_cache -v | ||
test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb | ||
rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/main/t/test/test_1.0_all.deb | ||
rm -f "${FREIGHT_LIB}"/apt/example/test_1.0_all.deb | ||
|
||
run freight_cache -v | ||
assert_success | ||
assert_output "" | ||
test ! -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb | ||
test ! -e "${FREIGHT_CACHE}"/pool/example/main/t/test/test_1.0_all.deb | ||
} | ||
|
||
@test "freight-cache --keep retains deleted packages in pool" { | ||
freight_cache -v | ||
test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb | ||
rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/main/t/test/test_1.0_all.deb | ||
rm -f "${FREIGHT_LIB}"/apt/example/test_1.0_all.deb | ||
|
||
run freight_cache -v --keep | ||
assert_success | ||
assert_output "" | ||
test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/main/t/test/test_1.0_all.deb | ||
} | ||
|
||
@test "freight-cache handles VARLIB being a symlink" { | ||
mv $FREIGHT_LIB ${FREIGHT_LIB}_real | ||
ln -s ${FREIGHT_LIB}_real $FREIGHT_LIB | ||
mv "$FREIGHT_LIB" "${FREIGHT_LIB}"_real | ||
ln -s "${FREIGHT_LIB}"_real "$FREIGHT_LIB" | ||
freight_cache | ||
test -e ${FREIGHT_CACHE}/pool/example/comp/t/test/test_1.0_all.deb | ||
test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/comp/t/test/test_1.0_all.deb | ||
test -e "${FREIGHT_CACHE}"/pool/example/main/t/test/test_1.0_all.deb | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# vim: et:ts=4:sw=4:ft=sh | ||
|
||
configure_local_apt() { | ||
mkdir -p ${TMPDIR}/apt/etc/apt | ||
mkdir -p ${TMPDIR}/apt/var/lib/apt | ||
mkdir -p ${TMPDIR}/apt/var/lib/dpkg | ||
mkdir -p ${TMPDIR}/apt/var/cache/apt | ||
mkdir -p "$TMPDIR"/apt/etc/apt | ||
mkdir -p "$TMPDIR"/apt/var/lib/apt | ||
mkdir -p "$TMPDIR"/apt/var/lib/dpkg | ||
mkdir -p "$TMPDIR"/apt/var/cache/apt | ||
|
||
if [ ! -e "${TMPDIR}"/apt/var/lib/dpkg/status ]; then | ||
touch "${TMPDIR}"/apt/var/lib/dpkg/status | ||
if [ ! -e "$TMPDIR"/apt/var/lib/dpkg/status ]; then | ||
touch "$TMPDIR"/apt/var/lib/dpkg/status | ||
fi | ||
if [ ! -e "$TMPDIR"/apt/etc/apt/trusted.gpg ]; then | ||
gpg --output "$TMPDIR"/apt/etc/apt/trusted.gpg --export [email protected] | ||
|
@@ -16,5 +16,5 @@ configure_local_apt() { | |
|
||
check_apt_support() { | ||
type apt-get || skip "missing apt-get" | ||
apt-get --version | grep Ver:.*deb || skip "missing apt-get deb support" | ||
apt-get --version | grep "Ver:.*deb" || skip "missing apt-get deb support" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ TOPDIR=$PWD | |
FIXTURES=${TOPDIR}/test/fixtures | ||
TMPDIR=${TOPDIR}/test/tmp | ||
|
||
load ${TMPDIR}/bats-assert/all.bash | ||
load "${TMPDIR}"/bats-assert/all.bash | ||
|
||
FREIGHT_HOME=${TMPDIR}/freight | ||
FREIGHT_CONFIG=${FREIGHT_HOME}/etc/freight.conf | ||
|
@@ -15,34 +15,34 @@ export GNUPGHOME=${TMPDIR}/gpg | |
|
||
freight_init() { | ||
gpg_init | ||
rm -rf $FREIGHT_HOME | ||
mkdir -p $FREIGHT_CACHE $FREIGHT_LIB | ||
rm -rf "$FREIGHT_HOME" | ||
mkdir -p "$FREIGHT_CACHE" "$FREIGHT_LIB" | ||
bin/freight init \ | ||
-g [email protected] \ | ||
-c $FREIGHT_CONFIG \ | ||
--libdir $FREIGHT_LIB \ | ||
--cachedir $FREIGHT_CACHE \ | ||
-c "$FREIGHT_CONFIG" \ | ||
--libdir "$FREIGHT_LIB" \ | ||
--cachedir "$FREIGHT_CACHE" \ | ||
--archs "i386 amd64" \ | ||
"$@" | ||
} | ||
|
||
freight_add() { | ||
bin/freight add -c $FREIGHT_CONFIG "$@" | ||
bin/freight add -c "$FREIGHT_CONFIG" "$@" | ||
} | ||
|
||
freight_cache() { | ||
bin/freight cache -p "$FIXTURES"/passphrase -c $FREIGHT_CONFIG "$@" | ||
bin/freight cache -p "$FIXTURES"/passphrase -c "$FREIGHT_CONFIG" "$@" | ||
} | ||
|
||
freight_cache_nohup() { | ||
nohup bin/freight cache -p "$FIXTURES"/passphrase -c $FREIGHT_CONFIG "$@" | ||
nohup bin/freight cache -p "$FIXTURES"/passphrase -c "$FREIGHT_CONFIG" "$@" | ||
} | ||
|
||
# Generates a GPG key for all tests, once only due to entropy required | ||
gpg_init() { | ||
if [ ! -e $GNUPGHOME ]; then | ||
mkdir -p $GNUPGHOME | ||
chmod 0700 $GNUPGHOME | ||
if [ ! -e "$GNUPGHOME" ]; then | ||
mkdir -p "$GNUPGHOME" | ||
chmod 0700 "$GNUPGHOME" | ||
gpg --batch --yes --passphrase-fd 0 --import "$FIXTURES"/first_key.gpg < "$FIXTURES"/passphrase | ||
gpg --batch --yes --passphrase-fd 0 --import "$FIXTURES"/second_key.gpg < "$FIXTURES"/passphrase | ||
fi | ||
|