From 40bb6efaa7865e6cebdf8aa00e6bd2a44b928a31 Mon Sep 17 00:00:00 2001 From: Ben Turrubiates Date: Sun, 14 Dec 2014 23:33:24 -0600 Subject: Run hooks on rcdn as indicated by the manpage - Make sure IFS in rcup and rcdn isn't left in an incorrect state when the output of lsrc is empty. - Add tests to check that hooks run on rcdn and rcup by default. --- bin/rcdn.in | 3 ++- bin/rcup.in | 1 + test/Makefile.am | 5 ++++- test/rcdn-hooks.t | 19 +++++++++++++++++++ test/rcup-hooks.t | 18 ++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 test/rcdn-hooks.t create mode 100644 test/rcup-hooks.t diff --git a/bin/rcdn.in b/bin/rcdn.in index 90cfcd6..ae7aad8 100755 --- a/bin/rcdn.in +++ b/bin/rcdn.in @@ -31,7 +31,7 @@ handle_command_line() { local arg_tags= local verbosity=0 local version=0 - local run_hooks=0 + local run_hooks=1 local dotfiles_dirs= local files= local excludes= @@ -124,4 +124,5 @@ for dest_and_src in $dests_and_srcs; do remove_link "$dest" "$dest" "$sigil" done +IFS="$saved_ifs" run_hooks post down diff --git a/bin/rcup.in b/bin/rcup.in index e5c5cdb..f818258 100755 --- a/bin/rcup.in +++ b/bin/rcup.in @@ -302,4 +302,5 @@ for dest_and_src in $dests_and_srcs; do handle_file "$GENERATE" "$src" "$dest" "$sigil" done +IFS="$saved_ifs" run_hooks post up diff --git a/test/Makefile.am b/test/Makefile.am index 3aec9d7..065b2d1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,7 +24,10 @@ TESTS = \ rcup-hostname.t \ rcup-standalone.t \ rcup-symlink-dirs.t \ - rcup-usage.t + rcup-usage.t \ + rcdn-hooks.t \ + rcup-hooks.t + dist_check_SCRIPTS = $(TESTS) dist_check_DATA = helper.sh diff --git a/test/rcdn-hooks.t b/test/rcdn-hooks.t new file mode 100644 index 0000000..1edde40 --- /dev/null +++ b/test/rcdn-hooks.t @@ -0,0 +1,19 @@ + $ . "$TESTDIR/helper.sh" + +Pre-down and post-down hooks should run by default + + $ mkdir -p .dotfiles/hooks + > touch .dotfiles/hooks/pre-down .dotfiles/hooks/post-down + > chmod +x .dotfiles/hooks/pre-down .dotfiles/hooks/post-down + + $ echo 'echo "example" > /tmp/test' > .dotfiles/hooks/pre-down + > echo 'cat /tmp/test; rm /tmp/test' > .dotfiles/hooks/post-down + + $ rcdn + example + +Ensure that hooks run when output of lsrc is non-empty + $ touch .dotfiles/testrc + > rcup + > rcdn + example diff --git a/test/rcup-hooks.t b/test/rcup-hooks.t new file mode 100644 index 0000000..8890f7b --- /dev/null +++ b/test/rcup-hooks.t @@ -0,0 +1,18 @@ + $ . "$TESTDIR/helper.sh" + +Pre-up and post-up hooks should run by default + + $ mkdir -p .dotfiles/hooks + > touch .dotfiles/hooks/pre-up .dotfiles/hooks/post-up + > chmod +x .dotfiles/hooks/pre-up .dotfiles/hooks/post-up + + $ echo 'echo "example" > /tmp/test' > .dotfiles/hooks/pre-up + > echo 'cat /tmp/test; rm /tmp/test' > .dotfiles/hooks/post-up + + $ rcup + example + +Ensure that hooks run when output of lsrc is non-empty + $ touch .dotfiles/testrc + > rcup + example -- cgit v1.2.3