Extend manually installed packages test cases

This commit is contained in:
Juno Takano 2026-04-04 21:04:51 -03:00
commit 866b5b5164
4 changed files with 40 additions and 12 deletions

View file

@ -2,5 +2,6 @@
set -eu set -eu
./build.sh "$1" && clear ./build.sh "$1"
clear
./run.sh "$1" ./run.sh "$1"

View file

@ -10,11 +10,9 @@ if podman container exists "$tag"; then
podman stop --time 3 "$tag" podman stop --time 3 "$tag"
fi fi
if ! [ -f "../target/debug/$binary" ]; then cd ..
cd .. cargo build
cargo build cd -
cd -
fi
cp -v ../target/debug/$binary $binary cp -v ../target/debug/$binary $binary

View file

@ -9,7 +9,7 @@ fail() { printf " [FAIL] %b\n" "$1"; exit 1; }
try() { try() {
actual="$1" actual="$1"
expected="$2" expected="$(printf '%b' "$2")"
fail_message="${3:-}" fail_message="${3:-}"
ok_message="${4:-}" ok_message="${4:-}"
@ -20,6 +20,8 @@ try() {
fi fi
} }
info "tori version $(tori version)"
announce "Fresh install has no manually installed packages" announce "Fresh install has no manually installed packages"
tori_manual=$(tori manual) tori_manual=$(tori manual)
try "$tori_manual" "" try "$tori_manual" ""
@ -28,11 +30,13 @@ info "Updating apt packages"
apt-get update >/dev/null apt-get update >/dev/null
announce "Manually installed package is the only package in 'tori manual'" announce "Manually installed package is the only package in 'tori manual'"
info "Installing: figlet"
apt-get install -y figlet >/dev/null 2>&1 apt-get install -y figlet >/dev/null 2>&1
tori_manual=$(tori manual) tori_manual=$(tori manual)
try "$tori_manual" figlet try "$tori_manual" figlet
announce "Manually installed packages are the only packages in 'tori manual'" announce "Manually installed packages are the only packages in 'tori manual'"
info "Installing: sudo"
apt-get install -y sudo >/dev/null 2>&1 apt-get install -y sudo >/dev/null 2>&1
tori_manual=$(tori manual | sort) tori_manual=$(tori manual)
try "$tori_manual" "$(printf 'figlet\nsudo')" try "$tori_manual" "$(printf 'figlet\nsudo')"

View file

@ -9,7 +9,7 @@ fail() { printf " [FAIL] %b\n" "$1"; exit 1; }
try() { try() {
actual="$1" actual="$1"
expected="$2" expected="$(printf '%b' "$2")"
operator="${3:-=}" operator="${3:-=}"
fail_message="${3:-}" fail_message="${3:-}"
ok_message="${4:-}" ok_message="${4:-}"
@ -23,18 +23,43 @@ try() {
fi fi
} }
info "tori version $(tori version)"
announce "sudo works" announce "sudo works"
whoami=$(whoami) whoami=$(whoami)
sudo_whoami=$(sudo whoami) sudo_whoami=$(sudo whoami)
echo try "$whoami" "$sudo_whoami" !=
try "$whoami" "$sudo_whoami" != try "$whoami" "$sudo_whoami" !=
echo try "$sudo_whoami" root
try "$sudo_whoami" root try "$sudo_whoami" root
info "Updating apt packages" info "Updating apt packages"
sudo apt-get update >/dev/null sudo apt-get update >/dev/null
announce "Manually installed packages are the only packages in 'tori manual'" announce "Manually installed packages are the only packages in 'tori manual'"
info "Installing: sudo"
sudo apt-get install -y sudo >/dev/null 2>&1 sudo apt-get install -y sudo >/dev/null 2>&1
tori_manual=$(tori manual | sort) tori_manual=$(tori manual)
try "$tori_manual" "sudo"
announce "Manually installed packages change after installing one"
info "Installing: figlet"
sudo apt-get install -y figlet >/dev/null 2>&1
tori_manual=$(tori manual)
try "$tori_manual" "figlet\nsudo"
announce "Manually installed packages change after installing several"
info "Installing: vim-tiny tmux qalc"
sudo apt-get install -y vim-tiny tmux qalc >/dev/null 2>&1
tori_manual=$(tori manual)
try "$tori_manual" "figlet\nqalc\nsudo\ntmux\nvim-tiny"
announce "Manually installed packages change after uninstalling one"
info "Uninstalling: qalc"
sudo apt-get remove -y qalc >/dev/null 2>&1
tori_manual=$(tori manual)
try "$tori_manual" "figlet\nsudo\ntmux\nvim-tiny"
announce "Manually installed packages change after uninstalling several"
info "Uninstalling: figlet tmux vim-tiny"
sudo apt-get remove -y figlet tmux vim-tiny >/dev/null 2>&1
tori_manual=$(tori manual)
try "$tori_manual" "sudo" try "$tori_manual" "sudo"