t/unstow.t: create a bunch of unowned files to make tests more robust

This should make it harder for Stow to do the right thing.
This commit is contained in:
Adam Spiers 2024-04-07 15:42:06 +01:00
parent afa50077c9
commit 8ed799a3a3

View file

@ -43,6 +43,20 @@ sub init_stow2 {
make_file('stow2/.stow'); make_file('stow2/.stow');
} }
sub create_unowned_files {
# Make things harder for Stow to figure out, by adding
# a bunch of alien files unrelated to Stow.
my @UNOWNED_DIRS = ('unowned-dir', '.unowned-dir', 'dot-unowned-dir');
for my $dir ('.', @UNOWNED_DIRS) {
for my $subdir ('.', @UNOWNED_DIRS) {
make_path("$dir/$subdir");
make_file("$dir/$subdir/unowned");
make_file("$dir/$subdir/.unowned");
make_file("$dir/$subdir/dot-unowned");
}
}
}
# Run a subtest twice, with compat off then on, in parallel test trees. # Run a subtest twice, with compat off then on, in parallel test trees.
# #
# Params: $name[, $setup], $test_code # Params: $name[, $setup], $test_code
@ -58,6 +72,7 @@ sub subtests {
$ENV{HOME} = $ABS_TEST_DIR; $ENV{HOME} = $ABS_TEST_DIR;
cd($repo); cd($repo);
cd("$TEST_DIR/target"); cd("$TEST_DIR/target");
create_unowned_files();
# cd first to allow setup to cd somewhere else. # cd first to allow setup to cd somewhere else.
my $opts = ref($setup) eq 'HASH' ? $setup : $setup->($TEST_DIR); my $opts = ref($setup) eq 'HASH' ? $setup : $setup->($TEST_DIR);
subtest($name, sub { subtest($name, sub {
@ -69,6 +84,7 @@ sub subtests {
$ENV{HOME} = $COMPAT_ABS_TEST_DIR; $ENV{HOME} = $COMPAT_ABS_TEST_DIR;
cd($repo); cd($repo);
cd("$COMPAT_TEST_DIR/target"); cd("$COMPAT_TEST_DIR/target");
create_unowned_files();
# cd first to allow setup to cd somewhere else. # cd first to allow setup to cd somewhere else.
$opts = ref $setup eq 'HASH' ? $setup : $setup->($COMPAT_TEST_DIR); $opts = ref $setup eq 'HASH' ? $setup : $setup->($COMPAT_TEST_DIR);
subtest("$name (compat mode)", sub { subtest("$name (compat mode)", sub {