#!/usr/bin/env zsh unset -m 'GIT_*' 'XDG_*' setopt err_exit trap "print -P '\n%N:%i: %B%F{red}Test faild!%F{default}%b'" ZERR alias pkg='pkg --quiet --no-colours' source test/documentation function stringcmp { diff -u <(echo $1) <(echo $2) } tests=$PWD/test test_pdir=$(mktemp -dt pkgdir.XXXXXX) test_proot=$(mktemp -dt pkgroot.XXXXXX) test_home=$(mktemp -dt pkghome.XXXXXX) export PATH=$PWD/bin:$PATH cat << meow test directories: PKG_DIR = $test_pdir PKG_ROOT = $test_proot HOME = $test_home meow cd $test_home export HOME=$test_home source $tests/checklinks (source $tests/setup) echo "# bootstrapping PKG_DIR" $test_proot/pkg/include/bootstrap $test_proot $test_pdir echo "# checking for success" [[ -e $test_home/.config/pkg/pkg.conf ]] [[ -d $test_proot/pkg ]] [[ -d $test_pdir/pkg ]] [[ -L $test_home/bin/pkg ]] [[ -L $test_home/bin/checklinks ]] [[ -x $(readlink $test_home/bin/pkg) ]] [[ -x $(readlink $test_home/bin/checklinks) ]] [[ -e $test_pdir/.collected/man/man1/pkg.1 ]] [[ -e $test_pdir/.collected/man/man5/pkg.conf.5 ]] [[ -e $test_pdir/.collected/man/man7/pkg.7 ]] echo "# pkg list local" stringcmp "pkg" "$(pkg list)" stringcmp "pkg" "$(pkg list local)" echo "# pkg list not-installed" stringcmp "ra\nra-bare\nrb\nrb-bare\nrc\nrc-bare" "$(pkg list not-installed)" echo "# pkg list all" stringcmp "pkg\nra\nra-bare\nrb\nrb-bare\nrc\nrc-bare" "$(pkg list all)" echo "# pkg add (no such repo)" ! pkg add weltfrieden echo "# pkg add (already installed)" ! pkg add pkg for conf_origin in 0 1; { echo "## GIT_USE_ORIGIN=$conf_origin" echo "GIT_USE_ORIGIN=$conf_origin" >> $test_home/.config/pkg/pkg.conf for repo in ra ra-bare; { file=${repo%-*} if [[ $repo == *-bare ]] { echo "## bare repository" complement=$file } else { echo "## non-bare repository" complement=${repo}-bare } source $tests/add source $tests/prereqs cd $test_pdir/$repo source $tests/push cd $test_pdir source $tests/pull-prepare source $tests/remove } } rm -rf $test_pdir $test_proot $test_home print -P '%F{green} test passed%F{default}'