`coredesktop-dev smoketest run --with HamPack` installs HamPack on a VM with CoreDesktop and checks a fresh install, an update with nothing to do, a one-app rebuild, a failing build and hampackremove, with smoketest/health checking every package, Flatpak and app is in place. HAMPACK_SKIP_WINDOWS_APPS skips the Windows installers, which the test VMs' desktop would start with no one to click through them; smoketest/setup sets it in each VM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
134 lines
4.8 KiB
Bash
134 lines
4.8 KiB
Bash
#!/usr/bin/env bats
|
|
#
|
|
# install-windows-apps.sh, install-flatpaks.sh and patch-potacat.sh
|
|
|
|
load helpers
|
|
|
|
setup() {
|
|
setup_fake_home
|
|
fake_coredesktop
|
|
stub curl 'exit 1'
|
|
# So xdg-user-dir reads the fake home's (absent) settings, not the real ones
|
|
export XDG_CONFIG_HOME="$HOME/.config"
|
|
}
|
|
|
|
install_all_windows_apps() {
|
|
local c="$HOME/.wine/drive_c"
|
|
mkdir -p "$c/VARA" "$c/VARA FM" "$c/RMS Express"
|
|
touch "$c/VARA/VARA.exe" "$c/VARA/VARA Terminal.exe" "$c/VARA FM/VARAFM.exe" "$c/RMS Express/RMS Express.exe"
|
|
}
|
|
|
|
@test "windows apps: when all are installed, nothing is downloaded or run" {
|
|
install_all_windows_apps
|
|
export DISPLAY=:0
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[ "$status" -eq 0 ]
|
|
! grep -qE '^(curl|winetricks|wine) ' "$STUB_LOG"
|
|
}
|
|
|
|
@test "windows apps: VARA Terminal is installed even when VARA HF is" {
|
|
install_all_windows_apps
|
|
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
|
|
export DISPLAY=:0
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[[ "$output" == *"VARA HF is already installed"* ]]
|
|
grep -q "^curl .*VARA%20Products" "$STUB_LOG"
|
|
}
|
|
|
|
@test "windows apps: when winlink.org refuses the download, the user is asked to download it and the update isn't failed" {
|
|
install_all_windows_apps
|
|
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
|
|
export DISPLAY=:0
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"VARA Terminal, from https://downloads.winlink.org/VARA%20Products/"* ]]
|
|
[[ "$output" == *"Leave them in $HOME/Downloads"* ]]
|
|
[[ "$output" != *"VARA HF, from"* ]]
|
|
! grep -q '^wine .*\.exe' "$STUB_LOG"
|
|
}
|
|
|
|
@test "windows apps: a zip in the downloads folder is installed without downloading" {
|
|
install_all_windows_apps
|
|
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
|
|
mkdir -p "$HOME/Downloads" "$BATS_TEST_TMPDIR/zip"
|
|
touch "$BATS_TEST_TMPDIR/zip/VARA Terminal setup.exe"
|
|
(cd "$BATS_TEST_TMPDIR/zip" && zip -q "$HOME/Downloads/VARA Terminal v1.2.3 setup.zip" "VARA Terminal setup.exe")
|
|
stub wine 'case "$1" in *.exe) touch "$HOME/.wine/drive_c/VARA/VARA Terminal.exe" ;; esac'
|
|
export DISPLAY=:0
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"VARA Terminal installed."* ]]
|
|
grep -q '^wine .*VARA Terminal setup.exe' "$STUB_LOG"
|
|
! grep -q '^curl ' "$STUB_LOG"
|
|
}
|
|
|
|
@test "windows apps: a zip saved with underscores for spaces is found too" {
|
|
install_all_windows_apps
|
|
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
|
|
mkdir -p "$HOME/Downloads"
|
|
echo "not a zip" > "$HOME/Downloads/VARA_Terminal_v1.2.3.zip"
|
|
export DISPLAY=:0
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[[ "$output" == *"Using $HOME/Downloads/VARA_Terminal_v1.2.3.zip"* ]]
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"VARA Terminal was not installed"* ]]
|
|
}
|
|
|
|
@test "windows apps: without a desktop session, nothing is downloaded and the update isn't failed" {
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"without a desktop session"* ]]
|
|
! grep -q '^curl ' "$STUB_LOG"
|
|
}
|
|
|
|
@test "windows apps: HAMPACK_SKIP_WINDOWS_APPS skips them, even at the desktop" {
|
|
export DISPLAY=:0 HAMPACK_SKIP_WINDOWS_APPS=1
|
|
run bash "$REPO/install-windows-apps.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"HAMPACK_SKIP_WINDOWS_APPS is set"* ]]
|
|
! grep -qE '^(curl|winetricks|wine) ' "$STUB_LOG"
|
|
}
|
|
|
|
@test "windows apps: winetricks runs only once" {
|
|
export DISPLAY=:0
|
|
mkdir -p "$HOME/.wine"
|
|
bash "$REPO/install-windows-apps.sh" || true
|
|
bash "$REPO/install-windows-apps.sh" || true
|
|
[ "$(grep -c '^winetricks ' "$STUB_LOG")" -eq 1 ]
|
|
}
|
|
|
|
@test "flatpaks: installs missing ones from flathub and records only those" {
|
|
local first second
|
|
first="$(all_hampack_flatpaks | sed -n 1p)"
|
|
second="$(all_hampack_flatpaks | sed -n 2p)"
|
|
touch "$FAKE_FLATPAKS/$first"
|
|
run bash "$REPO/install-flatpaks.sh"
|
|
[ "$status" -eq 0 ]
|
|
grep -qx "flatpak install --system --noninteractive flathub $second" "$STUB_LOG"
|
|
[ "$(cat "$HAMPACK_STATE/installed-flatpaks")" = "$second" ]
|
|
}
|
|
|
|
@test "flatpaks: update with everything installed installs nothing" {
|
|
local pak
|
|
for pak in $(all_hampack_flatpaks); do touch "$FAKE_FLATPAKS/$pak"; done
|
|
run bash "$REPO/install-flatpaks.sh"
|
|
[ "$status" -eq 0 ]
|
|
! grep -q '^flatpak install' "$STUB_LOG"
|
|
}
|
|
|
|
@test "patch-potacat removes deb and rpm targets in both forms" {
|
|
local pkg="$BATS_TEST_TMPDIR/package.json"
|
|
echo '{"build":{"linux":{"target":["AppImage","deb",{"target":"rpm"}],"category":"Utility"}}}' > "$pkg"
|
|
run bash "$REPO/patch-potacat.sh" "$pkg"
|
|
[ "$status" -eq 0 ]
|
|
[ "$(jq -c '.build.linux' "$pkg")" = '{"target":["AppImage"],"category":"Utility"}' ]
|
|
}
|
|
|
|
@test "patch-potacat leaves a package.json without targets alone" {
|
|
local pkg="$BATS_TEST_TMPDIR/package.json"
|
|
echo '{"name":"x"}' > "$pkg"
|
|
run bash "$REPO/patch-potacat.sh" "$pkg"
|
|
[ "$status" -eq 0 ]
|
|
[ "$(jq -c . "$pkg")" = '{"name":"x"}' ]
|
|
}
|