feat: XDG Base Directory compliance, --uninstall flag, and xclip advisory
- Resolve all paths via $XDG_CONFIG_HOME, $XDG_DATA_HOME, and $XDG_RUNTIME_DIR with conventional fallbacks (~/.config, ~/.local/share, /tmp); BIN_DIR stays ~/.local/bin (no XDG standard) - Add --uninstall: removes symlink, desktop entry, and data dir with colored per-step output; prompts to remove config when interactive, skips silently when not; post-run verification reports any failures - Warn in --check-deps and --install when only xclip is present — xclip operates through XWayland and can be unreliable on Wayland - Normalize dependency messages to package names (wl-clipboard, xclip) - Update README: XDG paths in install steps, --uninstall in usage, xclip advisory in prerequisites - Fix test sandbox: export XDG_CONFIG_HOME and XDG_DATA_HOME so the overridden HOME is respected; add install (test 15) and uninstall (test 16) coverage; add cp and ln to mocked tool set
This commit is contained in:
@@ -59,9 +59,13 @@ MOCK
|
||||
chmod +x "$BIN_DIR/curl"
|
||||
ln -s /usr/bin/mv "$BIN_DIR/mv"
|
||||
ln -s /usr/bin/tr "$BIN_DIR/tr"
|
||||
ln -s /usr/bin/cp "$BIN_DIR/cp"
|
||||
ln -s /usr/bin/ln "$BIN_DIR/ln"
|
||||
|
||||
export PATH="$BIN_DIR"
|
||||
export HOME="$TEST_DIR"
|
||||
export XDG_CONFIG_HOME="$TEST_DIR/.config"
|
||||
export XDG_DATA_HOME="$TEST_DIR/.local/share"
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
export XDG_CURRENT_DESKTOP=KDE
|
||||
|
||||
@@ -232,6 +236,44 @@ else
|
||||
echo " Actual output: $output"
|
||||
fi
|
||||
|
||||
# 15. Install — files placed in correct XDG directories
|
||||
it "installs files to XDG directories"
|
||||
# Clear any artifacts from earlier tests before verifying a clean install
|
||||
rm -rf "$XDG_DATA_HOME/color-tool" \
|
||||
"$XDG_DATA_HOME/applications/color-tool.desktop" \
|
||||
"$HOME/.local/bin" 2>/dev/null || true
|
||||
install_out=$("$COLOR_TOOL" --install 2>&1)
|
||||
if [[ -f "$XDG_DATA_HOME/color-tool/color-tool" ]] &&
|
||||
[[ -f "$XDG_DATA_HOME/color-tool/wl-colorpicker-plasma.py" ]] &&
|
||||
[[ -L "$HOME/.local/bin/color-tool" ]] &&
|
||||
[[ -f "$XDG_DATA_HOME/applications/color-tool.desktop" ]] &&
|
||||
[[ -f "$XDG_CONFIG_HOME/color-tool/config.toml" ]]; then
|
||||
echo "PASS"
|
||||
passed=$((passed + 1))
|
||||
else
|
||||
echo "FAIL"
|
||||
echo " Install output: $install_out"
|
||||
echo " Files found:"
|
||||
/usr/bin/find "$TEST_DIR/.local" "$TEST_DIR/.config" \( -type f -o -type l \) 2>/dev/null | /usr/bin/sort || true
|
||||
fi
|
||||
|
||||
# 16. Uninstall — removes installed files, config is kept in non-interactive mode
|
||||
it "uninstalls installed files (keeps config)"
|
||||
uninstall_out=$("$COLOR_TOOL" --uninstall 2>&1)
|
||||
if [[ ! -e "$HOME/.local/bin/color-tool" ]] &&
|
||||
[[ ! -L "$HOME/.local/bin/color-tool" ]] &&
|
||||
[[ ! -d "$XDG_DATA_HOME/color-tool" ]] &&
|
||||
[[ ! -f "$XDG_DATA_HOME/applications/color-tool.desktop" ]] &&
|
||||
[[ -f "$XDG_CONFIG_HOME/color-tool/config.toml" ]]; then
|
||||
echo "PASS"
|
||||
passed=$((passed + 1))
|
||||
else
|
||||
echo "FAIL"
|
||||
echo " Uninstall output: $uninstall_out"
|
||||
echo " Files still present:"
|
||||
/usr/bin/find "$TEST_DIR/.local" "$TEST_DIR/.config" \( -type f -o -type l \) 2>/dev/null | /usr/bin/sort || true
|
||||
fi
|
||||
|
||||
# ── Cleanup ───────────────────────────────────────────────────────────────────
|
||||
echo "---------------------------------------"
|
||||
echo "Result: $passed/$total tests passed."
|
||||
|
||||
Reference in New Issue
Block a user