#!/usr/bin/env bats load test_helper setup() { common_setup make_working_copy stub dbus-run-session '[ "$1" = -- ] && shift; exec "$@"' export DISPLAY=:0 WAYLAND_DISPLAY=wayland-0 DBUS_SESSION_BUS_ADDRESS=unix:path=/nowhere SSH_AUTH_SOCK=/nowhere } @test "try runs the command in a throwaway home with the working copy as CoreDesktop" { run cdd try bash -c 'echo "home=$HOME" echo "runtime=$XDG_RUNTIME_DIR $(stat -c %a "$XDG_RUNTIME_DIR")" echo "display=${DISPLAY-unset} ${WAYLAND_DISPLAY-unset} ${DBUS_SESSION_BUS_ADDRESS-unset} ${SSH_AUTH_SOCK-unset}" echo "coredesktop=$(readlink ~/.local/share/coredesktop)" echo "update=$(readlink "$(command -v update)")" echo "config=$XDG_CONFIG_HOME"' [ "$status" -eq 0 ] [[ "$output" == *"home=$TMPDIR/coredesktop-dev-try."*"/home"* ]] [[ "$output" == *"runtime=$TMPDIR/coredesktop-dev-try."*"/runtime 700"* ]] [[ "$output" == *"display=unset unset unset unset"* ]] [[ "$output" == *"coredesktop=$WC"* ]] [[ "$output" == *"update=$WC/update"* ]] [[ "$output" == *"config=$TMPDIR/coredesktop-dev-try."*"/home/.config"* ]] [[ "$output" == *"still change this machine"* ]] grep -q "^dbus-run-session -- bash" "$STUB_LOG" } @test "try cleans up afterwards, and passes on the command's exit status" { run cdd try bash -c 'exit 4' [ "$status" -eq 4 ] [ -z "$(ls "$TMPDIR")" ] } @test "try --keep keeps the throwaway folder" { run cdd try --keep true [ "$status" -eq 0 ] [[ "$output" == *"Kept $TMPDIR/coredesktop-dev-try."* ]] [ -n "$(ls "$TMPDIR")" ] } @test "try doesn't touch the real home" { run cdd try bash -c 'touch ~/made-by-try' [ "$status" -eq 0 ] [ ! -e "$HOME/made-by-try" ] }