diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-16 09:44:26 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-16 09:44:26 +0200 |
| commit | 845e6d3f393811bdc78833c9457d9768e685e572 (patch) | |
| tree | d8adbb5631936c55e95da08405a130b4525cf698 /tests | |
| parent | da1f0761e8a902b68134cdd9ec5eac3c549a9fcb (diff) | |
| download | wallp-master.tar.gz wallp-master.zip | |
wallp no longer owns a colour theme. The --theme flag, the THEME config
key, the persisted ~/.config/wallp/theme file and the wal invocation are
gone; finalize now writes ~/.cache/udt/wpaper and hands it to udt-accent,
which owns the whole palette (rofi, Hyprland, Firefox, quickshell,
Sublime). That call is best-effort: a missing or failing udt-accent must
never stop a wallpaper from being set, so wal is also dropped from the
required-binary check.
Tests follow the same shape: the theme-resolution and apply_theme cases
are removed, the wal stub is replaced by udt-accent, and two new cases
cover finalize calling udt-accent on the symlink and surviving its
failure.
Docs updated to match, including the install method: ~/bin/wallp is now
a symlink to the checkout rather than a copy, so repo edits no longer
need a manual re-copy to reach the live desktop.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/wallp.bats | 103 |
1 files changed, 31 insertions, 72 deletions
diff --git a/tests/wallp.bats b/tests/wallp.bats index d16f1a3..56f3d54 100644 --- a/tests/wallp.bats +++ b/tests/wallp.bats @@ -8,7 +8,7 @@ setup() { mkdir -p "$STUB_DIR" export PATH="$STUB_DIR:$PATH" local bin - for bin in swaybg wal qarma notify-send pkill kill; do + for bin in swaybg udt-accent qarma notify-send pkill kill; do cat > "$STUB_DIR/$bin" <<EOF #!/bin/bash echo "$bin \$*" >> "$TMP_HOME/calls.log" @@ -42,13 +42,11 @@ teardown() { conf="$HOME/c.conf" printf '%s\n' \ '# comment' '' \ - 'THEME=mytheme' \ 'OUTPUT_H=DP-1' \ 'OUTPUT_V=DP-3' \ 'DEFAULT_H=~/p/h.png' \ 'DEFAULT_V=/abs/v.png' > "$conf" parse_conf "$conf" - [ "$CONF_THEME" = "mytheme" ] [ "$CONF_OUTPUT_H" = "DP-1" ] [ "$CONF_OUTPUT_V" = "DP-3" ] [ "$CONF_DEFAULT_H" = "$HOME/p/h.png" ] @@ -71,41 +69,6 @@ teardown() { [[ "$output" == *"DEFAULT_V"* ]] } -@test "load_conf ok with THEME fallback" { - mkdir -p "$HOME/.config/wallp" - printf '%s\n' 'OUTPUT_H=DP-1' 'OUTPUT_V=DP-3' \ - 'DEFAULT_H=/a.png' 'DEFAULT_V=/b.png' \ - > "$HOME/.config/wallp/wallp.conf" - load_conf - [ "$?" -eq 0 ] - [ "$CONF_THEME" = "sexy-splurge" ] -} - -@test "resolve_theme flag wins over all" { - CONF_THEME="conf"; mkdir -p "$HOME/.config/wallp" - echo persisted > "$HOME/.config/wallp/theme" - run resolve_theme flagged - [ "$output" = "flagged" ] -} - -@test "resolve_theme persisted beats conf" { - CONF_THEME="conf"; mkdir -p "$HOME/.config/wallp" - echo persisted > "$HOME/.config/wallp/theme" - run resolve_theme '' - [ "$output" = "persisted" ] -} - -@test "resolve_theme uses conf when no persisted" { - CONF_THEME="conf" - run resolve_theme '' - [ "$output" = "conf" ] -} - -@test "persist_theme writes the file" { - persist_theme "abc" - [ "$(cat "$HOME/.config/wallp/theme")" = "abc" ] -} - @test "output_for maps logical to physical" { CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" run output_for H @@ -180,66 +143,71 @@ teardown() { [ "$(cat "$HOME/.cache/wallp/H.pid")" = "99999" ] } -@test "update_wpaper symlinks to H image" { +@test "finalize refreshes the accent from the wpaper symlink" { : > "$HOME/h.png"; mkdir -p "$HOME/.config/wallp" echo "$HOME/h.png" > "$HOME/.config/wallp/wall_h" - update_wpaper - [ "$(readlink "$HOME/.cache/wal/wpaper")" = "$HOME/h.png" ] + finalize + grep -q "udt-accent $HOME/.cache/udt/wpaper" "$HOME/calls.log" +} + +@test "finalize survives a failing udt-accent" { + cat > "$STUB_DIR/udt-accent" <<'EOS' +#!/bin/bash +exit 1 +EOS + chmod +x "$STUB_DIR/udt-accent" + : > "$HOME/h.png"; mkdir -p "$HOME/.config/wallp" + echo "$HOME/h.png" > "$HOME/.config/wallp/wall_h" + run finalize + [ "$status" -eq 0 ] } -@test "apply_theme runs wal and persists theme" { - apply_theme "mytheme" - [ "$(cat "$HOME/.config/wallp/theme")" = "mytheme" ] - grep -q "wal --backend colorz -nq --theme mytheme -o $HOME/bin/wal.sh" "$HOME/calls.log" - grep -q "notify-send" "$HOME/calls.log" +@test "update_wpaper symlinks to H image" { + : > "$HOME/h.png"; mkdir -p "$HOME/.config/wallp" + echo "$HOME/h.png" > "$HOME/.config/wallp/wall_h" + update_wpaper + [ "$(readlink "$HOME/.cache/udt/wpaper")" = "$HOME/h.png" ] } @test "restore uses persisted wallpapers" { - CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf" + CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" CONF_DEFAULT_H="$HOME/dh.png"; CONF_DEFAULT_V="$HOME/dv.png" : > "$HOME/saved_h.png"; : > "$HOME/saved_v.png" mkdir -p "$HOME/.config/wallp" echo "$HOME/saved_h.png" > "$HOME/.config/wallp/wall_h" echo "$HOME/saved_v.png" > "$HOME/.config/wallp/wall_v" - do_restore "" + do_restore grep -q "swaybg -o DP-1 -i $HOME/saved_h.png" "$HOME/calls.log" grep -q "swaybg -o DP-3 -i $HOME/saved_v.png" "$HOME/calls.log" } @test "restore falls back to conf defaults" { - CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf" + CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" : > "$HOME/dh.png"; : > "$HOME/dv.png" CONF_DEFAULT_H="$HOME/dh.png"; CONF_DEFAULT_V="$HOME/dv.png" - do_restore "" + do_restore grep -q "swaybg -o DP-1 -i $HOME/dh.png" "$HOME/calls.log" [ "$(cat "$HOME/.config/wallp/wall_h")" = "$HOME/dh.png" ] } @test "set CLI partial sets only V" { - CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf" + CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" : > "$HOME/v.png" - do_set "" "V=$HOME/v.png" + do_set "V=$HOME/v.png" grep -q "swaybg -o DP-3 -i $HOME/v.png" "$HOME/calls.log" ! grep -q "swaybg -o DP-1" "$HOME/calls.log" } -@test "set CLI persists flag theme" { - CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf" - : > "$HOME/h.png" - do_set "flagtheme" "H=$HOME/h.png" - [ "$(cat "$HOME/.config/wallp/theme")" = "flagtheme" ] -} - @test "set with no args and no display errors" { - CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf" + CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" unset WAYLAND_DISPLAY - run do_set "" + run do_set [ "$status" -eq 1 ] [[ "$output" == *"no display"* ]] } @test "set qarma path applies selected screen" { - CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf" + CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" export WAYLAND_DISPLAY="wayland-0" : > "$HOME/picked.png" # qarma stub: --list returns the screen choice; --file-selection returns a path. @@ -259,7 +227,7 @@ esac exit 0 EOF chmod +x "$STUB_DIR/qarma" - do_set "" + do_set grep -q "swaybg -o DP-3 -i $HOME/picked.png" "$HOME/calls.log" ! grep -q "swaybg -o DP-1" "$HOME/calls.log" } @@ -306,15 +274,6 @@ EOF [ ! -e "$HOME/.cache/wallp/H.pid" ] } -@test "theme flag honored through main with restore" { - unset WAYLAND_DISPLAY - mkdir -p "$HOME/.config/wallp" - printf '%s\n' 'OUTPUT_H=DP-1' 'OUTPUT_V=DP-3' \ - 'DEFAULT_H=/dh.png' 'DEFAULT_V=/dv.png' > "$HOME/.config/wallp/wallp.conf" - main --restore --theme tflag - [ "$(cat "$HOME/.config/wallp/theme")" = "tflag" ] -} - @test "missing required binary errors before acting" { unset WAYLAND_DISPLAY rm -f "$STUB_DIR/swaybg" # swaybg now absent |
