Files
Coredesktop-Dev/tests/doctor.bats
T
davidandClaude Opus 5.5 2207208326 Install QEMU's virtio-vga display and check for it
The smoketest VMs start with -vga virtio, but Arch packages that display
apart from qemu-base, so the base image build failed with "Virtio VGA not
available". update.sh now installs qemu-hw-display-virtio-vga, and doctor
and smoketest run check QEMU has the display before anything downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:04:39 -07:00

86 lines
2.6 KiB
Bash

#!/usr/bin/env bats
load test_helper
@test "doctor reports local changes in the deployed copy and how to fix them" {
make_working_copy
echo "# edited" >> "$DEPLOYED/update"
run cdd doctor
[ "$status" -eq 1 ]
[[ "$output" == *"PROBLEM the deployed copy has local changes"* ]]
[[ "$output" == *"M update"* ]]
[[ "$output" == *"coredesktop-dev deployed restore"* ]]
}
@test "doctor is happy with a clean deployed copy that can fast-forward" {
make_working_copy
# Upstream moves on; the deployed copy is behind, which is fine
git -C "$WC" commit -q --allow-empty -m "new"
git -C "$WC" push -q origin main
run cdd doctor
[[ "$output" == *"ok the deployed copy has no local changes"* ]]
[[ "$output" == *"ok the deployed copy can fast-forward to its upstream"* ]]
[[ "$output" == *"ok working copy: $WC"* ]]
}
@test "doctor reports a deployed copy with commits upstream doesn't have" {
make_working_copy
git -C "$DEPLOYED" commit -q --allow-empty -m "local commit"
run cdd doctor
[ "$status" -eq 1 ]
[[ "$output" == *"has commits its upstream doesn't"* ]]
}
@test "doctor reports a missing working copy" {
run cdd doctor
[ "$status" -eq 1 ]
[[ "$output" == *"PROBLEM no working copy is set"* ]]
}
@test "doctor reports when it was run from a Flatpak" {
make_working_copy
COREDESKTOP_DEV_VIA_FLATPAK=1 run cdd doctor
[[ "$output" == *"note you ran this in a Flatpak"* ]]
}
@test "doctor reports the pre-push hook" {
make_working_copy
run cdd doctor
[[ "$output" == *"the pre-push hook isn't installed"* ]]
cdd hooks install
run cdd doctor
[[ "$output" == *"ok the pre-push hook is installed"* ]]
}
@test "in a Flatpak, coredesktop-dev re-runs itself on the host" {
stub flatpak-spawn
FLATPAK_ID=com.vscodium.codium run cdd doctor
[ "$status" -eq 0 ]
called flatpak-spawn --host --env=COREDESKTOP_DEV_VIA_FLATPAK=1 \
"$(readlink -f "$PROJECT/bin/coredesktop-dev")" doctor
}
@test "--help works in a Flatpak without going to the host" {
stub flatpak-spawn
FLATPAK_ID=com.vscodium.codium run cdd doctor --help
[ "$status" -eq 0 ]
[[ "$output" == *"Usage: coredesktop-dev doctor"* ]]
not_called flatpak-spawn
}
@test "doctor reports QEMU without the virtio-vga display" {
make_working_copy
stub qemu-system-x86_64 'echo "name \"VGA\", bus PCI"'
run cdd doctor
[ "$status" -eq 1 ]
[[ "$output" == *"PROBLEM QEMU has no virtio-vga display"* ]]
stub qemu-system-x86_64 'echo "name \"virtio-vga\", bus PCI"'
run cdd doctor
[[ "$output" == *"ok QEMU has the virtio-vga display"* ]]
}