Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

… be parsed
  • Loading branch information...
commit fdbe673ca88e8f1a46d33297de525e9653221b00 1 parent aecd733
Axel Beckert authored

Showing 2 changed files with 68 additions and 0 deletions. Show diff stats Hide diff stats

  1. +2 0  debian/changelog
  2. +66 0 t/parse-comments-and-blank-lines.t
2  debian/changelog
@@ -12,6 +12,8 @@ unburden-home-dir (0.1.1~0.20120505) UNRELEASED; urgency=low
12 12 * Update list of caches in the example unburden-home-dir.list for the
13 13 following applications: Opera, Mozilla based browsers
14 14 * Comment the example unburden-home-dir.list, group entries by category
  15 + * Add a test that verifies that lists with comments and blank lines can
  16 + be parsed
15 17
16 18 -- Axel Beckert <abe@debian.org> Sat, 05 May 2012 13:48:49 +0200
17 19
66 t/parse-comments-and-blank-lines.t
... ... @@ -0,0 +1,66 @@
  1 +#!/usr/bin/perl -wl
  2 +
  3 +use Test::Simple tests => 16;
  4 +use File::Path qw(mkpath rmtree);
  5 +use File::Slurp;
  6 +use Data::Dumper;
  7 +
  8 +my $BASE = 't/parse-comments-and-blank-lines';
  9 +my $HOME = "$BASE/1";
  10 +my $TARGET = "$BASE/2";
  11 +my $PREFIX = "u";
  12 +
  13 +# Set a debug environment
  14 +$ENV{HOME} = $HOME;
  15 +
  16 +# Clean up possible remainders of aborted tests
  17 +rmtree("$BASE");
  18 +
  19 +# 1 - 3
  20 +ok( mkpath("$HOME/.foobar/fnord/bla", "$TARGET", {}), "Create test environment (directories)" );
  21 +ok( -d "$HOME/.foobar/fnord/bla", "Original directory has been created" );
  22 +ok( -d "$TARGET", "Target directory has been created" );
  23 +
  24 +# 4 - 7
  25 +ok( symlink("$HOME/.foobar/fnord", "$HOME/.fnord"), "Create test environment (Symlink 1)" );
  26 +ok( -l "$HOME/.fnord", "Symlink 1 has been created" );
  27 +ok( symlink("fnord", "$HOME/.foobar/blafasel"), "Create test environment (Symlink 2)" );
  28 +ok( -l "$HOME/.foobar/blafasel", "Symlink 2 has been created" );
  29 +
  30 +# 8 + 9
  31 +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") );
  32 +ok( write_file("$BASE/config", "TARGETDIR=$TARGET\nFILELAYOUT=$PREFIX-\%s") );
  33 +
  34 +# 10
  35 +my $cmd = "bin/unburden-home-dir -C $BASE/config -L $BASE/list > $BASE/output 2> $BASE/stderr";
  36 +ok( system($cmd) == 0, "Call '$cmd'" );
  37 +
  38 +# 11
  39 +my $wanted = "Skipping '$HOME/.fnord/bla' due to symlink in path: $HOME/.fnord
  40 +Skipping '$HOME/.foobar/blafasel/bla' due to symlink in path: $HOME/.foobar/blafasel
  41 +";
  42 +
  43 +my $stderr = read_file("$BASE/stderr");
  44 +print "Want:\n\n$wanted\nGot:\n\n$stderr\n";
  45 +ok( $stderr eq $wanted, "Check command STDERR output" );
  46 +
  47 +# 12
  48 +$wanted = "Moving $HOME/.foobar/fnord/bla -> $TARGET/u-foobar-fnord-bla
  49 +sending incremental file list
  50 +created directory $TARGET/u-foobar-fnord-bla
  51 +./
  52 +Symlinking $TARGET/u-foobar-fnord-bla -> $HOME/.foobar/fnord/bla
  53 +";
  54 +
  55 +my $output = read_file("$BASE/output");
  56 +print "Want:\n\n$wanted\nGot:\n\n$output\n";
  57 +ok( $output eq $wanted, "Check command STDOUT" );
  58 +
  59 +# 13 - 15
  60 +ok( -d "$TARGET/$PREFIX-foobar-fnord-bla", "First directory moved" );
  61 +ok( ! -e "$TARGET/$PREFIX-fnord-bla", "Symlink 1 not moved" );
  62 +ok( ! -e "$TARGET/$PREFIX-foobar-blafasel-bla", "Symlink 2 not moved" );
  63 +
  64 +
  65 +# 16
  66 +ok( rmtree("$BASE"), "Clean up" );

0 comments on commit fdbe673

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