2016-03-24 00:18:33 +00:00
|
|
|
load common
|
|
|
|
load_fixtures
|
2016-04-06 17:33:42 +00:00
|
|
|
status=;lines=; #; populated by bats run()
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
IN_REPO=(.bash_profile .hammerspoon/init.lua .vimrc)
|
|
|
|
SUBDIR=".hammerspoon"
|
|
|
|
IN_SUBDIR=(init.lua)
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
destroy_tmp
|
|
|
|
build_repo "${IN_REPO[@]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Command 'list' -a" {
|
|
|
|
echo "
|
|
|
|
When 'list' command is provided,
|
|
|
|
and '-a' is provided,
|
|
|
|
List tracked files
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run list -a
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" list -a
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
local line=0
|
|
|
|
for f in "${IN_REPO[@]}"; do
|
|
|
|
[ "${lines[$line]}" = "$f" ]
|
|
|
|
((line++)) || true
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Command 'list' (outside of worktree)" {
|
|
|
|
echo "
|
|
|
|
When 'list' command is provided,
|
|
|
|
and while outside of the worktree
|
|
|
|
List tracked files
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run list
|
2016-04-06 17:33:42 +00:00
|
|
|
run "${T_YADM_Y[@]}" list
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
local line=0
|
|
|
|
for f in "${IN_REPO[@]}"; do
|
|
|
|
[ "${lines[$line]}" = "$f" ]
|
|
|
|
((line++)) || true
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Command 'list' (in root of worktree)" {
|
|
|
|
echo "
|
|
|
|
When 'list' command is provided,
|
|
|
|
and while in root of the worktree
|
|
|
|
List tracked files
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run list
|
2016-04-06 17:33:42 +00:00
|
|
|
run bash -c "(cd '$T_DIR_WORK'; ${T_YADM_Y[*]} list)"
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
local line=0
|
|
|
|
for f in "${IN_REPO[@]}"; do
|
|
|
|
[ "${lines[$line]}" = "$f" ]
|
|
|
|
((line++)) || true
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Command 'list' (in subdirectory of worktree)" {
|
|
|
|
echo "
|
|
|
|
When 'list' command is provided,
|
|
|
|
and while in subdirectory of the worktree
|
|
|
|
List tracked files for current directory
|
|
|
|
Exit with 0
|
|
|
|
"
|
|
|
|
|
|
|
|
#; run list
|
2016-04-06 17:33:42 +00:00
|
|
|
run bash -c "(cd '$T_DIR_WORK/$SUBDIR'; ${T_YADM_Y[*]} list)"
|
2016-03-24 00:18:33 +00:00
|
|
|
|
|
|
|
#; validate status and output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
local line=0
|
|
|
|
for f in "${IN_SUBDIR[@]}"; do
|
|
|
|
echo "'${lines[$line]}' = '$f'"
|
|
|
|
[ "${lines[$line]}" = "$f" ]
|
|
|
|
((line++)) || true
|
|
|
|
done
|
|
|
|
}
|