summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-04-28 11:12:01 +0200
committerJim Meyering <meyering@redhat.com>2011-04-28 22:43:56 +0200
commit156084826533bf149db7dfd2b9466ab116b4ca4b (patch)
tree058d552d9d98129eadcb8cf830551e647a13c689 /tests/misc
parente3f814a773cf683309271b866d69dbfa968b104a (diff)
downloadcoreutils-156084826533bf149db7dfd2b9466ab116b4ca4b.tar.xz
tests: write skip explanation from perl scripts also to outer stderr
* tests/CuSkip.pm (skip): New file/module/function, to help the perl test scripts "skip" a test consistently, emitting a diagnostic both into the log file and into the outermost stderr stream that is more likely to be seen by a human. * tests/check.mk (TESTS_ENVIRONMENT): Add -MCuSkip. * tests/misc/date-next-dow: Use CuSkip::skip in place of warn+exit-77. * tests/misc/tty-eof: Likewise. * tests/misc/uniq: Likewise. * tests/rm/fail-eperm: Likewise. * tests/misc/md5sum-newline: Likewise. Also, s/program_name/ME/. * tests/misc/ls-misc (setuid_setup, main): Likewise. * tests/misc/pwd-long: Likewise, and add -I"$abs_srcdir" -MCuSkip to the $PERL invocation command. Inspired by a request from Bruno Haible regarding misc/tty-eof: http://debbugs.gnu.org/8570
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/date-next-dow2
-rwxr-xr-xtests/misc/ls-misc10
-rwxr-xr-xtests/misc/md5sum-newline6
-rwxr-xr-xtests/misc/pwd-long20
-rwxr-xr-xtests/misc/tty-eof4
-rwxr-xr-xtests/misc/uniq7
6 files changed, 20 insertions, 29 deletions
diff --git a/tests/misc/date-next-dow b/tests/misc/date-next-dow
index e61d405ad..fda213bd6 100755
--- a/tests/misc/date-next-dow
+++ b/tests/misc/date-next-dow
@@ -73,6 +73,6 @@ my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
# Skip the test if the starting and stopping day numbers differ.
my @d_post = localtime (time);
$d_post[7] == $d[7]
- or (warn "$ME: test straddled a day boundary; skipped"), exit 77;
+ or CuSkip::skip "$ME: test straddled a day boundary; skipped";
exit $fail;
diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc
index 7c3bc7894..8b356d4ae 100755
--- a/tests/misc/ls-misc
+++ b/tests/misc/ls-misc
@@ -17,7 +17,7 @@
use strict;
-(my $program_name = $0) =~ s|.*/||;
+(my $ME = $0) =~ s|.*/||;
my $prog = 'ls';
# Turn off localization of executable's output.
@@ -61,8 +61,8 @@ sub setuid_setup()
mkdir sticky && chmod +t sticky && $test -k sticky &&
mkdir owt && chmod +t,o+w owt && $test -k owt &&
mkdir owr && chmod o+w owr)) == 0
- or (warn "$program_name: cannot create setuid/setgid/sticky files,"
- . "so can't run this test\n"), exit 77;
+ or CuSkip::skip "$ME: cannot create setuid/setgid/sticky files,"
+ . "so can't run this test\n";
}
sub mk_file(@)
@@ -285,7 +285,7 @@ my $save_temps = $ENV{SAVE_TEMPS};
my $verbose = $ENV{VERBOSE};
setuid_setup;
-my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
+my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
$fail
and exit 1;
@@ -296,5 +296,5 @@ $env =~ s/\';.*//sm;
$ENV{LS_COLORS} = $env;
setuid_setup;
-$fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
+$fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
diff --git a/tests/misc/md5sum-newline b/tests/misc/md5sum-newline
index 3b6d2f46a..efd9fd3a1 100755
--- a/tests/misc/md5sum-newline
+++ b/tests/misc/md5sum-newline
@@ -18,7 +18,7 @@
use strict;
-(my $program_name = $0) =~ s|.*/||;
+(my $ME = $0) =~ s|.*/||;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@@ -26,7 +26,7 @@ use strict;
# See if we can create a file name that contains a newline.
# Use system, since Perl doesn't let you do this with "open".
system ('touch', "a\nb") == 0
- or (warn "$0: failed to create newline-containing file name\n"), exit 77;
+ or CuSkip::skip "$ME: failed to create newline-containing file name\n";
my $degenerate = "d41d8cd98f00b204e9800998ecf8427e";
my $t = '--text';
@@ -40,5 +40,5 @@ my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
my $prog = 'md5sum';
-my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
+my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long
index 7fa95abc0..3a5147d76 100755
--- a/tests/misc/pwd-long
+++ b/tests/misc/pwd-long
@@ -30,7 +30,7 @@ export ARGV_0
# Don't use CuTmpdir here, since File::Temp's use of rmtree can't
# remove the deep tree we create.
-$PERL -Tw -- - <<\EOF
+$PERL -Tw -I"$abs_srcdir" -MCuSkip -- - <<\EOF
# Show that pwd works even when the length of the resulting
# directory name is longer than PATH_MAX.
@@ -77,12 +77,9 @@ substr ($expected, 0, 1) = '';
my $i = 0;
do
{
- if (!mkdir $z, 0700)
- {
- warn "$ME: skipping this test; cannot create long directory name "
- . "at depth $i: $!\n";
- exit 77;
- }
+ mkdir $z, 0700
+ or CuSkip::skip "$ME: skipping this test; cannot create long "
+ . "directory name at depth $i: $!\n";
chdir $z
}
until (++$i == $n);
@@ -91,12 +88,9 @@ my $abs_top_builddir = $ENV{abs_top_builddir};
$abs_top_builddir
or die "$ME: envvar abs_top_builddir not defined\n";
my $build_src_dir = "$abs_top_builddir/src";
-if ($build_src_dir !~ m!^([-+.:/\w]+)$!)
- {
- warn "$ME: skipping this test; odd build source directory name:\n"
- . "$build_src_dir\n";
- exit 77;
- }
+$build_src_dir =~ m!^([-+.:/\w]+)$!
+ or CuSkip::skip "$ME: skipping this test; odd build source directory name:\n"
+ . "$build_src_dir\n";
$build_src_dir = $1;
my $pwd_binary = "$build_src_dir/pwd";
diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof
index 14910dcfc..23cb4d564 100755
--- a/tests/misc/tty-eof
+++ b/tests/misc/tty-eof
@@ -25,8 +25,8 @@ use strict;
# Some older versions of Expect.pm (e.g. 1.07) lack the log_user method,
# so check for that, too.
eval { require Expect; Expect->require_version('1.11') };
-$@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"),
- exit 77;
+$@
+ and CuSkip::skip "$ME: this script requires Perl's Expect package >=1.11\n";
{
my $fail = 0;
diff --git a/tests/misc/uniq b/tests/misc/uniq
index 1a260e498..99aa8edfe 100755
--- a/tests/misc/uniq
+++ b/tests/misc/uniq
@@ -82,11 +82,8 @@ sub add_z_variants($)
# I've only ever triggered the problem in a non-C locale.
my $locale = $ENV{LOCALE_FR};
-if (! defined $locale || $locale eq 'none')
- {
- warn "$prog: skipping this test -- no appropriate locale\n";
- exit 77;
- }
+! defined $locale || $locale eq 'none'
+ and CuSkip::skip "$prog: skipping this test -- no appropriate locale\n";
# See if isblank returns true for nbsp.
my $x = `env printf '\xa0'| LC_ALL=$locale tr '[:blank:]' x`;