Skip to content
Browse files

Add a test that verifies that lists with comments and blank lines can…

… be parsed
  • Loading branch information...
1 parent aecd733 commit fdbe673ca88e8f1a46d33297de525e9653221b00 @xtaran committed May 5, 2012
Showing with 68 additions and 0 deletions.
  1. +2 −0 debian/changelog
  2. +66 −0 t/parse-comments-and-blank-lines.t
View
2 debian/changelog
@@ -12,6 +12,8 @@ unburden-home-dir (0.1.1~0.20120505) UNRELEASED; urgency=low
* Update list of caches in the example unburden-home-dir.list for the
following applications: Opera, Mozilla based browsers
* Comment the example unburden-home-dir.list, group entries by category
+ * Add a test that verifies that lists with comments and blank lines can
+ be parsed
-- Axel Beckert <abe@debian.org> Sat, 05 May 2012 13:48:49 +0200
View
66 t/parse-comments-and-blank-lines.t
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -wl
+
+use Test::Simple tests => 16;
+use File::Path qw(mkpath rmtree);
+use File::Slurp;
+use Data::Dumper;
+
+my $BASE = 't/parse-comments-and-blank-lines';
+my $HOME = "$BASE/1";
+my $TARGET = "$BASE/2";
+my $PREFIX = "u";
+
+# Set a debug environment
+$ENV{HOME} = $HOME;
+
+# Clean up possible remainders of aborted tests
+rmtree("$BASE");
+
+# 1 - 3
+ok( mkpath("$HOME/.foobar/fnord/bla", "$TARGET", {}), "Create test environment (directories)" );
+ok( -d "$HOME/.foobar/fnord/bla", "Original directory has been created" );
+ok( -d "$TARGET", "Target directory has been created" );
+
+# 4 - 7
+ok( symlink("$HOME/.foobar/fnord", "$HOME/.fnord"), "Create test environment (Symlink 1)" );
+ok( -l "$HOME/.fnord", "Symlink 1 has been created" );
+ok( symlink("fnord", "$HOME/.foobar/blafasel"), "Create test environment (Symlink 2)" );
+ok( -l "$HOME/.foobar/blafasel", "Symlink 2 has been created" );
+
+# 8 + 9
+ok( write_file("$BASE/list", "m d .foobar/fnord/bla foobar-fnord-bla\n# Comment\n\n \n \nm d .fnord/bla fnord-bla\nm d .foobar/blafasel/bla foobar-blafasel-bla\n") );
+ok( write_file("$BASE/config", "TARGETDIR=$TARGET\nFILELAYOUT=$PREFIX-\%s") );
+
+# 10
+my $cmd = "bin/unburden-home-dir -C $BASE/config -L $BASE/list > $BASE/output 2> $BASE/stderr";
+ok( system($cmd) == 0, "Call '$cmd'" );
+
+# 11
+my $wanted = "Skipping '$HOME/.fnord/bla' due to symlink in path: $HOME/.fnord
+Skipping '$HOME/.foobar/blafasel/bla' due to symlink in path: $HOME/.foobar/blafasel
+";
+
+my $stderr = read_file("$BASE/stderr");
+print "Want:\n\n$wanted\nGot:\n\n$stderr\n";
+ok( $stderr eq $wanted, "Check command STDERR output" );
+
+# 12
+$wanted = "Moving $HOME/.foobar/fnord/bla -> $TARGET/u-foobar-fnord-bla
+sending incremental file list
+created directory $TARGET/u-foobar-fnord-bla
+./
+Symlinking $TARGET/u-foobar-fnord-bla -> $HOME/.foobar/fnord/bla
+";
+
+my $output = read_file("$BASE/output");
+print "Want:\n\n$wanted\nGot:\n\n$output\n";
+ok( $output eq $wanted, "Check command STDOUT" );
+
+# 13 - 15
+ok( -d "$TARGET/$PREFIX-foobar-fnord-bla", "First directory moved" );
+ok( ! -e "$TARGET/$PREFIX-fnord-bla", "Symlink 1 not moved" );
+ok( ! -e "$TARGET/$PREFIX-foobar-blafasel-bla", "Symlink 2 not moved" );
+
+
+# 16
+ok( rmtree("$BASE"), "Clean up" );

0 comments on commit fdbe673

Please sign in to comment.
Something went wrong with that request. Please try again.