From ebc895a540e17058042250e351d33da083d5d1dd Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Thu, 14 Jul 2016 08:55:55 -0500 Subject: [PATCH] Add test for conflicting stowrc and cli args Why: * Want to add feature to stowrc parsing. * Missing regression test for conflicting cli and stowrc options. This change addresses the need by: * Add missing regression tests to rc_options.t * Two types of tests for the two types of options possible. * For scalar options such as --target, cli arguments should overwrite stowrc arguments. * For options that result in a list, such as --ignore, the arguments from cli and stowrc files should be merged. --- t/rc_options.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/rc_options.t b/t/rc_options.t index bf88c68..5f0fe87 100755 --- a/t/rc_options.t +++ b/t/rc_options.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 4; use testutil; @@ -46,6 +46,32 @@ is($options->{target}, "$OUT_DIR/target", "rc options different lines"); is($options->{dir}, "$OUT_DIR/stow", "rc options different lines"); # +# Test that scalar cli option overwrites conflicting stowrc option. +# +local @ARGV = ('-d', "$OUT_DIR/stow",'dummy'); +$rc_contents = <{dir}, "$OUT_DIR/stow", "cli overwrite scalar rc option."); + +# +# Test that list cli option merges with conflicting stowrc option. +# Documentation states that stowrc options are prepended to cli options. +# +local @ARGV = ( + '--defer=man', + 'dummy' +); +$rc_contents = <{defer}, [qr(\Ainfo), qr(\Aman)], + 'defer man and info'); + # Clean up files used for testing. # unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n";