]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor a little
authorJim Meyering <jim@meyering.net>
Tue, 14 Jan 2003 16:19:09 +0000 (16:19 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 14 Jan 2003 16:19:09 +0000 (16:19 +0000)
tests/ls-2/tests

index c63c05e635bdd260de263bba8d93bdaf07473a0b..55a6fd56d10351a2b0018178528a75ab50deb20f 100755 (executable)
@@ -32,14 +32,19 @@ my $rmdir2 = {POST => sub {rmdir 'd/e' or die "d/e: $!\n";
 my $slink_d = {PRE => sub {symlink '/', 'd' or die "d: $!\n";
                            $ENV{LS_COLORS}='ln=01;36:di=01;34:or=40;31;01'
                            }};
-my $exe_in_subdir =
-  {PRE => sub { mkdir 'j', 0700 or die "creating j: $!\n";
-               (open F, '>j/d') && close F or die "creating j/d: $!\n";
-                chmod 0555, 'j/d' or die "making j/d executable: $!\n";
-                $ENV{LS_COLORS}='ex=01;32'
-                }};
 my $unlink_d = {POST => sub {unlink 'd' or die "d: $!\n"}};
 
+sub make_j_d ()
+{
+  mkdir 'j', 0700 or die "creating j: $!\n";
+  (open F, '>j/d') && close F or die "creating j/d: $!\n";
+  chmod 0555, 'j/d' or die "making j/d executable: $!\n";
+}
+
+my $exe_in_subdir = {PRE => sub { make_j_d (); $ENV{LS_COLORS}='ex=01;32' }};
+my $remove_j = {POST => sub {unlink 'j/d' or die "j/d: $!\n";
+                             rmdir 'j' or die "j: $!\n" }};
+
 my $q_bell = {IN => {"q\a" => ''}};
 my @Tests =
     (
@@ -84,11 +89,9 @@ my @Tests =
      # Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5.
      # To demonstrate it, the file in question (with executable bit set)
      # must not be a command line argument.
-     ['color-exe', '--color=always j',
+     ['color-exe1', '--color=always j',
                                 {OUT => "\e[0m\e[01;32md\e[0m\n\e[m"},
-                                 $exe_in_subdir,
-                                {POST => sub {unlink 'j/d' or die "j/d: $!\n";
-                                               rmdir 'j' or die "j: $!\n" }}],
+                                 $exe_in_subdir, $remove_j],
 
      # From Stéphane Chazelas.
      ['no-a-isdir-b', 'no-dir d',