| File: | t/replacement-order-dryrun.t |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | #!/usr/bin/perl -wl | ||||||
| 2 | |||||||
| 3 | 1 1 1 | 5054 74442 94 | use Test::More; | ||||
| 4 | 1 1 1 | 2919 35723 396 | use Test::Differences; | ||||
| 5 | 1 1 1 | 26 9 329 | use File::Path qw(mkpath rmtree); | ||||
| 6 | 1 1 1 | 1552 61669 206 | use File::Slurp; | ||||
| 7 | 1 1 1 | 1092 17939 563946 | use Data::Dumper; | ||||
| 8 | |||||||
| 9 | 1 | 13 | my $BASE = 't/replacement-order-dryrun'; | ||||
| 10 | 1 | 36 | my $HOME = "$BASE/1"; | ||||
| 11 | 1 | 13 | my $TARGET = "$BASE/2"; | ||||
| 12 | 1 | 8 | my $PREFIX = "u"; | ||||
| 13 | |||||||
| 14 | # Set a debug environment | ||||||
| 15 | 1 | 20 | $ENV{HOME} = $HOME; | ||||
| 16 | |||||||
| 17 | 1 | 2229 | ok( mkpath("$HOME/.foobar/blatest/barba", "$TARGET") ); | ||||
| 18 | |||||||
| 19 | 1 | 5498 | ok( write_file("$BASE/list", 'm d .foo*/bla*/bar* bar%3-bla%2-foo%1') ); | ||||
| 20 | 1 | 2381 | ok( write_file("$BASE/config", "TARGETDIR=$TARGET\nFILELAYOUT=$PREFIX-\%s") ); | ||||
| 21 | |||||||
| 22 | 1 | 2972900 | ok( system("bin/unburden-home-dir -n -C $BASE/config -L $BASE/list > $BASE/output" ) == 0 ); | ||||
| 23 | |||||||
| 24 | 1 | 1258 | my $wanted = <<EOF; | ||||
| 25 | Create parent directories for $TARGET/u-barba-blatest-foobar | ||||||
| 26 | Moving $HOME/.foobar/blatest/barba -> $TARGET/u-barba-blatest-foobar | ||||||
| 27 | Symlinking $TARGET/u-barba-blatest-foobar -> $HOME/.foobar/blatest/barba | ||||||
| 28 | EOF | ||||||
| 29 | |||||||
| 30 | 1 | 70 | my $output = read_file("$BASE/output"); | ||||
| 31 | 1 | 407 | eq_or_diff_text( $output, $wanted, "Check output if as expected" ); | ||||
| 32 | |||||||
| 33 | 1 | 2257 | ok( ! -e "$TARGET/$PREFIX-barba-blatest-foobar" ); | ||||
| 34 | 1 | 1330 | ok( ! -l "$HOME/.foobar/blatest/barba" ); | ||||
| 35 | 1 | 1188 | ok( -d "$HOME/.foobar/blatest/barba" ); | ||||
| 36 | |||||||
| 37 | 1 | 4861 | ok( rmtree("$BASE") ); | ||||
| 38 | |||||||
| 39 | 1 | 1178 | done_testing(); | ||||