According to Jim Meyering on 1/1/2010 8:12 AM: > Thanks for writing that. > I'll bet it's right, but I haven't looked carefully yet. > >> I still need to figure out how to enhance the testsuite to catch this. >> Any hints on the best approach to take? > > You might want to add one to tests/misc/ls-misc.
Here's what I came up with. OK to squash this with the previous, and push
the fix? Prior to the fix in ls.c, sl-dangle2 fails; sl-dangle3 and
sl-dangle4 just add more coverage to ensure no regressions (it took me a
while to figure out the difference between ORPHAN and MISSING in the
dircolors input file - the coreutils.texi could really use some details
there. ORPHAN is used for dangling symlinks in short listings, and for
the symlink on the left side of the -> in long listings; MISSING is used
for the target of dangling symlinks on the right side of -> in long
listings. If omitted, MISSING defaults to ORPHAN).
Here is the failure, pre-patch:
*** 1,2 ****
! ESC[0mESC[targetmlESC[0m -> nowhere
! ESC[m
\ No newline at end of file
--- 1 ----
! l -> nowhere
diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc
index a077482..ee9b417 100755
--- a/tests/misc/ls-misc
+++ b/tests/misc/ls-misc
@@ -185,6 +185,35 @@ my @Tests =
restore_ls_colors; }},
],
+ # Test for a bug fixed after coreutils-8.2.
+ ['sl-dangle2', '-o --color=always l',
+ {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+ {OUT => "l -> nowhere\n"},
+ {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
+ push_ls_colors('ln=target')
+ }},
+ {POST => sub {unlink 'l' or die "l: $!\n";
+ restore_ls_colors; }},
+ ],
+ ['sl-dangle3', '-o --color=always l',
+ {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+ {OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n\e[m"},
+ {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
+ push_ls_colors('ln=target:or=40:mi=34:')
+ }},
+ {POST => sub {unlink 'l' or die "l: $!\n";
+ restore_ls_colors; }},
+ ],
+ ['sl-dangle4', '-o --color=always l',
+ {OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
+ {OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n\e[m"},
+ {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
+ push_ls_colors('ln=34:mi=35:or=36:')
+ }},
+ {POST => sub {unlink 'l' or die "l: $!\n";
+ restore_ls_colors; }},
+ ],
+
# 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.
--
Don't work too hard, make some time for fun as well!
Eric Blake [email protected]
signature.asc
Description: OpenPGP digital signature
