summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2020-01-03 16:07:44 -0500
committerAnish Athalye <me@anishathalye.com>2020-01-03 16:45:35 -0500
commit320d5d0123b045fe922cf576d8d65e2db0517910 (patch)
tree2f6faf19519ac2207b03ecfa259a794f112acf90
parent138fdbc8d7f42bd54e0a1d0c07d5858b1055ea50 (diff)
Add tests for canonicalize-path
-rw-r--r--dotbot/cli.py4
-rw-r--r--test/tests/link-canonicalize.bash20
-rw-r--r--test/tests/link-no-canonicalize.bash23
3 files changed, 45 insertions, 2 deletions
diff --git a/dotbot/cli.py b/dotbot/cli.py
index 2680acf..77bd439 100644
--- a/dotbot/cli.py
+++ b/dotbot/cli.py
@@ -73,10 +73,10 @@ def main():
if not isinstance(tasks, list):
raise ReadingError('Configuration file must be a list of tasks')
if options.base_directory:
- base_directory = options.base_directory
+ base_directory = os.path.abspath(options.base_directory)
else:
# default to directory of config file
- base_directory = os.path.dirname(os.path.realpath(options.config_file))
+ base_directory = os.path.dirname(os.path.abspath(options.config_file))
os.chdir(base_directory)
dispatcher = Dispatcher(base_directory)
success = dispatcher.dispatch(tasks)
diff --git a/test/tests/link-canonicalize.bash b/test/tests/link-canonicalize.bash
new file mode 100644
index 0000000..34015c8
--- /dev/null
+++ b/test/tests/link-canonicalize.bash
@@ -0,0 +1,20 @@
+test_description='linking canonicalizes path by default'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/f &&
+ln -s dotfiles dotfiles-symlink
+'
+
+test_expect_success 'run' '
+cat > "${DOTFILES}/${INSTALL_CONF}" <<EOF
+- link:
+ ~/.f:
+ path: f
+EOF
+${DOTBOT_EXEC} -c dotfiles-symlink/${INSTALL_CONF}
+'
+
+test_expect_success 'test' '
+[ "$(readlink ~/.f | cut -d/ -f4-)" = "dotfiles/f" ]
+'
diff --git a/test/tests/link-no-canonicalize.bash b/test/tests/link-no-canonicalize.bash
new file mode 100644
index 0000000..f9ccb99
--- /dev/null
+++ b/test/tests/link-no-canonicalize.bash
@@ -0,0 +1,23 @@
+test_description='linking path canonicalization can be disabled'
+. '../test-lib.bash'
+
+test_expect_success 'setup' '
+echo "apple" > ${DOTFILES}/f &&
+ln -s dotfiles dotfiles-symlink
+'
+
+test_expect_success 'run' '
+cat > "${DOTFILES}/${INSTALL_CONF}" <<EOF
+- defaults:
+ link:
+ canonicalize-path: false
+- link:
+ ~/.f:
+ path: f
+EOF
+${DOTBOT_EXEC} -c ./dotfiles-symlink/${INSTALL_CONF}
+'
+
+test_expect_success 'test' '
+[ "$(readlink ~/.f | cut -d/ -f4-)" = "dotfiles-symlink/f" ]
+'