1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Support yadm.cygwin-copy configuration (#62)

With `yadm.cygwin-copy` set to "true", alternate files will be copies
instead of symlinks, but only when running on Cygwin.
This commit is contained in:
Tim Byrne
2017-05-29 00:17:55 -05:00
parent 68937f3cad
commit f8e0bd593d
5 changed files with 134 additions and 2 deletions

View File

@@ -73,7 +73,7 @@ function count_introspect() {
Exit with 0
"
count_introspect "configs" 0 11 'yadm\.auto-alt'
count_introspect "configs" 0 12 'yadm\.auto-alt'
}
@test "Command 'introspect' (repo)" {

View File

@@ -0,0 +1,102 @@
load common
load_fixtures
IN_REPO=(alt*)
export TEST_TREE_WITH_CYGWIN=1
export SIMULATED_CYGWIN="CYGWIN_NT-6.1-WOW64"
setup() {
destroy_tmp
build_repo "${IN_REPO[@]}"
}
test_alt() {
local cygwin_copy="$1"
local is_cygwin="$2"
local expect_link="$3"
case "$cygwin_copy" in
true|false)
git config --file="$T_YADM_CONFIG" "yadm.cygwin-copy" "$cygwin_copy"
;;
esac
if [ "$is_cygwin" = "true" ]; then
echo '#!/bin/sh' > "$T_TMP/uname"
echo "echo $SIMULATED_CYGWIN" >> "$T_TMP/uname"
chmod a+x "$T_TMP/uname"
fi
local expected_content
expected_content="$T_DIR_WORK/alt-test##$(PATH="$T_TMP:$PATH" uname -s)"
PATH="$T_TMP:$PATH" run "${T_YADM_Y[@]}" alt
if [ -L "$T_DIR_WORK/alt-test" ] && [ "$expect_link" != 'true' ] ; then
echo "ERROR: Alt should be a simple file, but isn't"
return 1
fi
if [ ! -L "$T_DIR_WORK/alt-test" ] && [ "$expect_link" = 'true' ] ; then
echo "ERROR: Alt should use symlink, but doesn't"
return 1
fi
if ! diff "$T_DIR_WORK/alt-test" "$expected_content"; then
echo "ERROR: Alt contains different data than expected"
return 1
fi
}
@test "Option 'yadm.cygwin-copy' (unset, non-cygwin)" {
echo "
When the option 'yadm.cygwin-copy' is unset
and the OS is not CYGWIN
Verify alternate is a symlink
"
test_alt 'unset' 'false' 'true'
}
@test "Option 'yadm.cygwin-copy' (true, non-cygwin)" {
echo "
When the option 'yadm.cygwin-copy' is true
and the OS is not CYGWIN
Verify alternate is a symlink
"
test_alt 'true' 'false' 'true'
}
@test "Option 'yadm.cygwin-copy' (false, non-cygwin)" {
echo "
When the option 'yadm.cygwin-copy' is false
and the OS is not CYGWIN
Verify alternate is a symlink
"
test_alt 'false' 'false' 'true'
}
@test "Option 'yadm.cygwin-copy' (unset, cygwin)" {
echo "
When the option 'yadm.cygwin-copy' is unset
and the OS is CYGWIN
Verify alternate is a symlink
"
test_alt 'unset' 'true' 'true'
}
@test "Option 'yadm.cygwin-copy' (true, cygwin)" {
echo "
When the option 'yadm.cygwin-copy' is true
and the OS is CYGWIN
Verify alternate is a copy
"
test_alt 'true' 'true' 'false'
}
@test "Option 'yadm.cygwin-copy' (false, cygwin)" {
echo "
When the option 'yadm.cygwin-copy' is false
and the OS is CYGWIN
Verify alternate is a symlink
"
test_alt 'false' 'true' 'true'
}

View File

@@ -205,6 +205,18 @@ function create_worktree() {
echo "{{ YADM_CLASS }}-{{ YADM_OS }}-{{ YADM_HOSTNAME }}-{{ YADM_USER }}" > "$DIR_WORKTREE/alt-jinja##yadm.j2"
fi
#; for some cygwin tests
if [ ! -z "$TEST_TREE_WITH_CYGWIN" ] ; then
for f in \
"alt-test##" \
"alt-test##$T_SYS" \
"alt-test##$SIMULATED_CYGWIN" \
;
do
make_parents "$DIR_WORKTREE/$f"
echo "$f" > "$DIR_WORKTREE/$f"
done
fi
if [ ! -z "$TEST_TREE_WITH_WILD" ] ; then
#; wildcard test data - yes this is a big mess :(