|
|
@@ -80,8 +80,8 @@ my @choices = (
|
|
|
},
|
|
|
);
|
|
|
my $nb_slaves = 4;
|
|
|
-plan tests => (4 * ($nb_slaves + 1) + 2) * 25 # number of check_choices
|
|
|
- + 70; # rest
|
|
|
+plan tests => (4 * ($nb_slaves + 1) + 2) * 26 # number of check_choices
|
|
|
+ + 100; # rest
|
|
|
|
|
|
sub cleanup {
|
|
|
system("rm -rf $tmpdir && mkdir -p $admindir && mkdir -p $altdir");
|
|
|
@@ -132,7 +132,9 @@ sub remove_all_choices {
|
|
|
sub set_choice {
|
|
|
my ($id, %opts) = @_;
|
|
|
my $alt = $choices[$id];
|
|
|
- my @params = ("--set", $main_name, $alt->{path});
|
|
|
+ my @params;
|
|
|
+ push @params, @{$opts{params}} if exists $opts{params};
|
|
|
+ push @params, "--set", $main_name, $alt->{path};
|
|
|
call_ua(\@params, %opts);
|
|
|
}
|
|
|
|
|
|
@@ -444,3 +446,42 @@ ok(-f $main_link, "removal keeps real file installed as master link");
|
|
|
ok(-f "$bindir/slave1", "removal keeps real files installed as slave links");
|
|
|
install_choice(0, params => ["--force"]);
|
|
|
check_choice(0, "auto", "install --force replaces files with links");
|
|
|
+
|
|
|
+# test management of pre-existing files #2
|
|
|
+cleanup();
|
|
|
+system("touch $main_link $bindir/slave2");
|
|
|
+install_choice(0);
|
|
|
+install_choice(1);
|
|
|
+ok(!-l $main_link, "inactive install preserves files that should be links");
|
|
|
+ok(!-l "$bindir/slave2", "inactive install preserves files that should be slave links");
|
|
|
+ok(-f $main_link, "inactive install keeps real file installed as master link");
|
|
|
+ok(-f "$bindir/slave2", "inactive install keeps real files installed as slave links");
|
|
|
+set_choice(1);
|
|
|
+ok(!-l $main_link, "manual switching preserves files that should be links");
|
|
|
+ok(!-l "$bindir/slave2", "manual switching preserves files that should be slave links");
|
|
|
+ok(-f $main_link, "manual switching keeps real file installed as master link");
|
|
|
+ok(-f "$bindir/slave2", "manual switching keeps real files installed as slave links");
|
|
|
+remove_choice(1);
|
|
|
+ok(!-l $main_link, "auto switching preserves files that should be links");
|
|
|
+ok(!-l "$bindir/slave2", "auto switching preserves files that should be slave links");
|
|
|
+ok(-f $main_link, "auto switching keeps real file installed as master link");
|
|
|
+ok(-f "$bindir/slave2", "auto switching keeps real files installed as slave links");
|
|
|
+
|
|
|
+# test management of pre-existing files #3
|
|
|
+cleanup();
|
|
|
+system("touch $main_link $bindir/slave2");
|
|
|
+install_choice(0);
|
|
|
+install_choice(1);
|
|
|
+remove_choice(0);
|
|
|
+ok(!-l $main_link, "removal + switching preserves files that should be links");
|
|
|
+ok(!-l "$bindir/slave2", "removal + switching preserves files that should be slave links");
|
|
|
+ok(-f $main_link, "removal + switching keeps real file installed as master link");
|
|
|
+ok(-f "$bindir/slave2", "removal + switching keeps real files installed as slave links");
|
|
|
+install_choice(0);
|
|
|
+ok(!-l $main_link, "install + switching preserves files that should be links");
|
|
|
+ok(!-l "$bindir/slave2", "install + switching preserves files that should be slave links");
|
|
|
+ok(-f $main_link, "install + switching keeps real file installed as master link");
|
|
|
+ok(-f "$bindir/slave2", "install + switching keeps real files installed as slave links");
|
|
|
+set_choice(1, params => ["--force"]);
|
|
|
+ok(!-e "$bindir/slave2", "forced switching w/o slave drops real files installed as slave links");
|
|
|
+check_choice(1, "manual", "set --force replaces files with links");
|