summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-09-01 21:30:10 +0200
committerJim Meyering <meyering@redhat.com>2011-09-02 14:08:40 +0200
commitd8945c8d8f7f4505e9beb61a1005b1ece09e2790 (patch)
treec98aa9f0b3d731f202487658a3593ad40e0610bb /tests/misc
parent832c85e3f79387752a563a31c3e9764c488bd6f1 (diff)
downloadcoreutils-d8945c8d8f7f4505e9beb61a1005b1ece09e2790.tar.xz
tests: cut: exercise distro-added multibyte code paths
* tests/misc/cut: Repeat each test using a multibyte locale, if the configure-time test found such a locale. Adjust the tests so that they also accept a slightly different diagnostic that is specific to the MB-patched cut.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/cut33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/misc/cut b/tests/misc/cut
index c905ba9a3..7ed413448 100755
--- a/tests/misc/cut
+++ b/tests/misc/cut
@@ -23,6 +23,10 @@ use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+my $mb_locale = $ENV{LOCALE_FR_UTF8};
+! defined $mb_locale || $mb_locale eq 'none'
+ and $mb_locale = 'C';
+
my $prog = 'cut';
my $try = "Try \`$prog --help' for more information.\n";
my $from_1 = "$prog: fields and positions are numbered from 1\n$try";
@@ -156,6 +160,35 @@ my @Tests =
['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}],
);
+if ($mb_locale ne 'C')
+ {
+ # Duplicate each test vector, appending "-mb" to the test name and
+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we
+ # provide coverage for the distro-added multi-byte code paths.
+ my @new;
+ foreach my $t (@Tests)
+ {
+ my @new_t = @$t;
+ my $test_name = shift @new_t;
+
+ # Depending on whether cut is multi-byte-patched,
+ # it emits different diagnostics:
+ # non-MB: invalid byte or field list
+ # MB: invalid byte, character or field list
+ # Adjust the expected error output accordingly.
+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
+ (@new_t))
+ {
+ my $sub = {ERR_SUBST => 's/, character//'};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
+ }
+
+
@Tests = triple_test \@Tests;
my $save_temps = $ENV{DEBUG};