summaryrefslogtreecommitdiff
path: root/tests/misc/date
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-08-17 20:20:33 +0000
committerJim Meyering <jim@meyering.net>2005-08-17 20:20:33 +0000
commita8819700e1264757eae815e6d088bd42691d29d3 (patch)
treec4be764bfc9dae83c2357b9cbdcb144f8c222462 /tests/misc/date
parent8305377e27e7a32819ba21536484c42312740305 (diff)
downloadcoreutils-a8819700e1264757eae815e6d088bd42691d29d3.tar.xz
Remove terminating "\n"s once again.
Automatically add them whenever EXIT != 0.
Diffstat (limited to 'tests/misc/date')
-rwxr-xr-xtests/misc/date168
1 files changed, 92 insertions, 76 deletions
diff --git a/tests/misc/date b/tests/misc/date
index 13527e1ce..b490c0cc5 100755
--- a/tests/misc/date
+++ b/tests/misc/date
@@ -38,9 +38,9 @@ my $fmt = "'+%Y-%m-%d %T'";
my @Tests =
(
- # test-name, [option, option, ...] {OUT=>"expected-output\n"}
+ # test-name, [option, option, ...] {OUT=>"expected-output"}
#
- ['1', "-d '$d1' +'%% %a %A %b %B'", {OUT=>"% Sun Sunday Jan January\n"}],
+ ['1', "-d '$d1' +'%% %a %A %b %B'", {OUT=>"% Sun Sunday Jan January"}],
# [Actually, skip it on *all* systems. -- this Perl code is run at
# distribution-build-time, not at configure/test time. ]
@@ -50,135 +50,135 @@ my @Tests =
# properly. GNU strftime must rely on the underlying host library
# function to get locale-dependent behavior, as strftime is the only
# portable interface to that behavior.
- # ['2', "-d '$d1' +'%c'", {OUT=>"Sun Jan 19 $t0 1997\n"}],
+ # ['2', "-d '$d1' +'%c'", {OUT=>"Sun Jan 19 $t0 1997"}],
- ['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08\n"}],
- ['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {OUT=>"08_019_ 8_ 8_01\n"}],
- ['5', "-d '$d1' +'%M_%n_%p_%r'", {OUT=>"17_\n_AM_$t0 AM\n"}],
- ['6', "-d '$d1' +'%s_%S_%t_%T'", {OUT=>"853661868_48_\t_$t0\n"}],
- ['7', "-d '$d1' +'%U_%V_%w_%W'", {OUT=>"03_03_0_02\n"}],
- ['8', "-d '$d1' +'%x_%X_%y_%Y'", {OUT=>"01/19/97_${t0}_97_1997\n"}],
- ['9', "-d '$d1' +'%z'", {OUT=>"+0000\n"}],
+ ['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08"}],
+ ['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {OUT=>"08_019_ 8_ 8_01"}],
+ ['5', "-d '$d1' +'%M_%n_%p_%r'", {OUT=>"17_\n_AM_$t0 AM"}],
+ ['6', "-d '$d1' +'%s_%S_%t_%T'", {OUT=>"853661868_48_\t_$t0"}],
+ ['7', "-d '$d1' +'%U_%V_%w_%W'", {OUT=>"03_03_0_02"}],
+ ['8', "-d '$d1' +'%x_%X_%y_%Y'", {OUT=>"01/19/97_${t0}_97_1997"}],
+ ['9', "-d '$d1' +'%z'", {OUT=>"+0000"}],
- ['leap-1', "--date '02/29/1996 1 year' +%Y-%m-%d", {OUT=>"1997-03-01\n"}],
+ ['leap-1', "--date '02/29/1996 1 year' +%Y-%m-%d", {OUT=>"1997-03-01"}],
- ['U95-1', "--date '1995-1-1' +%U", {OUT=>"01\n"}],
- ['U95-2', "--date '1995-1-7' +%U", {OUT=>"01\n"}],
- ['U95-3', "--date '1995-1-8' +%U", {OUT=>"02\n"}],
+ ['U95-1', "--date '1995-1-1' +%U", {OUT=>"01"}],
+ ['U95-2', "--date '1995-1-7' +%U", {OUT=>"01"}],
+ ['U95-3', "--date '1995-1-8' +%U", {OUT=>"02"}],
- ['U92-1', "--date '1992-1-1' +%U", {OUT=>"00\n"}],
- ['U92-2', "--date '1992-1-4' +%U", {OUT=>"00\n"}],
- ['U92-3', "--date '1992-1-5' +%U", {OUT=>"01\n"}],
+ ['U92-1', "--date '1992-1-1' +%U", {OUT=>"00"}],
+ ['U92-2', "--date '1992-1-4' +%U", {OUT=>"00"}],
+ ['U92-3', "--date '1992-1-5' +%U", {OUT=>"01"}],
- ['V92-1', "--date '1992-1-1' +%V", {OUT=>"01\n"}],
- ['V92-2', "--date '1992-1-5' +%V", {OUT=>"01\n"}],
- ['V92-3', "--date '1992-1-6' +%V", {OUT=>"02\n"}],
+ ['V92-1', "--date '1992-1-1' +%V", {OUT=>"01"}],
+ ['V92-2', "--date '1992-1-5' +%V", {OUT=>"01"}],
+ ['V92-3', "--date '1992-1-6' +%V", {OUT=>"02"}],
- ['W92-1', "--date '1992-1-1' +%W", {OUT=>"00\n"}],
- ['W92-2', "--date '1992-1-5' +%W", {OUT=>"00\n"}],
- ['W92-3', "--date '1992-1-6' +%W", {OUT=>"01\n"}],
+ ['W92-1', "--date '1992-1-1' +%W", {OUT=>"00"}],
+ ['W92-2', "--date '1992-1-5' +%W", {OUT=>"00"}],
+ ['W92-3', "--date '1992-1-6' +%W", {OUT=>"01"}],
- ['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>"2001\n"}],
+ ['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>"2001"}],
- ['rel-0', "-d '$d1 now' '+%Y-%m-%d %T'", {OUT=>"$d0 $t0\n"}],
+ ['rel-0', "-d '$d1 now' '+%Y-%m-%d %T'", {OUT=>"$d0 $t0"}],
- ['rel-1a', "-d '$d1 yesterday' $fmt", {OUT=>"1997-01-18 $t0\n"}],
- ['rel-1b', "-d '$d1 tomorrow' $fmt", {OUT=>"1997-01-20 $t0\n"}],
+ ['rel-1a', "-d '$d1 yesterday' $fmt", {OUT=>"1997-01-18 $t0"}],
+ ['rel-1b', "-d '$d1 tomorrow' $fmt", {OUT=>"1997-01-20 $t0"}],
- ['rel-2a', "-d '$d1 6 years ago' $fmt", {OUT=>"1991-01-19 $t0\n"}],
- ['rel-2b', "-d '$d1 7 months ago' $fmt", {OUT=>"1996-06-19 $t0\n"}],
- ['rel-2c', "-d '$d1 8 weeks ago' $fmt", {OUT=>"1996-11-24 $t0\n"}],
- ['rel-2d', "-d '$d1 1 day ago' $fmt", {OUT=>"1997-01-18 $t0\n"}],
- ['rel-2e', "-d '$d1 2 hours ago' $fmt", {OUT=>"$d0 06:17:48\n"}],
- ['rel-2f', "-d '$d1 3 minutes ago' $fmt", {OUT=>"$d0 08:14:48\n"}],
- ['rel-2g', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44\n"}],
+ ['rel-2a', "-d '$d1 6 years ago' $fmt", {OUT=>"1991-01-19 $t0"}],
+ ['rel-2b', "-d '$d1 7 months ago' $fmt", {OUT=>"1996-06-19 $t0"}],
+ ['rel-2c', "-d '$d1 8 weeks ago' $fmt", {OUT=>"1996-11-24 $t0"}],
+ ['rel-2d', "-d '$d1 1 day ago' $fmt", {OUT=>"1997-01-18 $t0"}],
+ ['rel-2e', "-d '$d1 2 hours ago' $fmt", {OUT=>"$d0 06:17:48"}],
+ ['rel-2f', "-d '$d1 3 minutes ago' $fmt", {OUT=>"$d0 08:14:48"}],
+ ['rel-2g', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}],
- ['rel-3a', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44\n"}],
+ ['rel-3a', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}],
- ['next-s', "-d '$d1 next second' '+%Y-%m-%d %T'", {OUT=>"$d0 $ts\n"}],
- ['next-m', "-d '$d1 next minute' '+%Y-%m-%d %T'", {OUT=>"$d0 $tm\n"}],
- ['next-h', "-d '$d1 next hour' '+%Y-%m-%d %T'", {OUT=>"$d0 $th\n"}],
- ['next-d', "-d '$d1 next day' '+%Y-%m-%d %T'", {OUT=>"$dd $t0\n"}],
- ['next-w', "-d '$d1 next week' '+%Y-%m-%d %T'", {OUT=>"$dw $t0\n"}],
- ['next-mo', "-d '$d1 next month' '+%Y-%m-%d %T'", {OUT=>"$dm $t0\n"}],
- ['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {OUT=>"$dy $t0\n"}],
+ ['next-s', "-d '$d1 next second' '+%Y-%m-%d %T'", {OUT=>"$d0 $ts"}],
+ ['next-m', "-d '$d1 next minute' '+%Y-%m-%d %T'", {OUT=>"$d0 $tm"}],
+ ['next-h', "-d '$d1 next hour' '+%Y-%m-%d %T'", {OUT=>"$d0 $th"}],
+ ['next-d', "-d '$d1 next day' '+%Y-%m-%d %T'", {OUT=>"$dd $t0"}],
+ ['next-w', "-d '$d1 next week' '+%Y-%m-%d %T'", {OUT=>"$dw $t0"}],
+ ['next-mo', "-d '$d1 next month' '+%Y-%m-%d %T'", {OUT=>"$dm $t0"}],
+ ['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {OUT=>"$dy $t0"}],
- ['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {OUT=>"08/01/97,06:00\n"},
+ ['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {OUT=>"08/01/97,06:00"},
{ENV => 'TZ=UTC+4'}],
['utc-0a', "-u -d '08/01/97 6:00 UTC +4 hours' '+%D,%H:%M'",
- {OUT=>"08/01/97,10:00\n"}],
+ {OUT=>"08/01/97,10:00"}],
# Make sure --file=FILE works with -u.
['utc-1', "-u --file=f '+%Y-%m-%d %T'",
- {AUX=>{f=>"$d0 $t0\n$d0 $t0\n"}},
- {OUT=>"$d0 $t0\n$d0 $t0\n"},
+ {AUX=>{f=>"$d0 $t0\n$d0 $t0"}},
+ {OUT=>"$d0 $t0\n$d0 $t0"},
{ENV => 'TZ=UTC+1'}],
['utc-1a', "-u --file=f '+%Y-%m-%d %T'",
- {AUX=>{f=>"$d0 $t0 UTC +1 hour\n$d0 $t0 UTC +1 hour\n"}},
- {OUT=>"$d0 $th\n$d0 $th\n"}],
+ {AUX=>{f=>"$d0 $t0 UTC +1 hour\n$d0 $t0 UTC +1 hour"}},
+ {OUT=>"$d0 $th\n$d0 $th"}],
# From the examples in the documentation.
- ['date2sec-0', "-d '1970-01-01 00:00:01' +%s", {OUT=>"7201\n"},
+ ['date2sec-0', "-d '1970-01-01 00:00:01' +%s", {OUT=>"7201"},
{ENV => 'TZ=UTC+2'}],
# Same as above, but don't rely on TZ in environment.
['date2sec-0a', "-d '1970-01-01 00:00:01 UTC +2 hours' +%s",
- {OUT=>"7201\n"}],
+ {OUT=>"7201"}],
- ['date2sec-1', "-d 2000-01-01 +%s", {OUT=>"946684800\n"}],
+ ['date2sec-1', "-d 2000-01-01 +%s", {OUT=>"946684800"}],
['sec2date-0', "-d '1970-01-01 UTC 946684800 sec' +'%Y-%m-%d %T %z'",
- {OUT=>"2000-01-01 00:00:00 +0000\n"}],
+ {OUT=>"2000-01-01 00:00:00 +0000"}],
- ['this-m', "-d '$d0 $t0 this minute' $fmt", {OUT=>"$d0 $t0\n"}],
- ['this-h', "-d '$d0 $t0 this hour' $fmt", {OUT=>"$d0 $t0\n"}],
- ['this-w', "-d '$d0 $t0 this week' $fmt", {OUT=>"$d0 $t0\n"}],
- ['this-mo', "-d '$d0 $t0 this month' $fmt", {OUT=>"$d0 $t0\n"}],
- ['this-y', "-d '$d0 $t0 this year' $fmt", {OUT=>"$d0 $t0\n"}],
+ ['this-m', "-d '$d0 $t0 this minute' $fmt", {OUT=>"$d0 $t0"}],
+ ['this-h', "-d '$d0 $t0 this hour' $fmt", {OUT=>"$d0 $t0"}],
+ ['this-w', "-d '$d0 $t0 this week' $fmt", {OUT=>"$d0 $t0"}],
+ ['this-mo', "-d '$d0 $t0 this month' $fmt", {OUT=>"$d0 $t0"}],
+ ['this-y', "-d '$d0 $t0 this year' $fmt", {OUT=>"$d0 $t0"}],
- ['risks-1', "-d 'Nov 10 1996' $fmt", {OUT=>"1996-11-10 00:00:00\n"}],
+ ['risks-1', "-d 'Nov 10 1996' $fmt", {OUT=>"1996-11-10 00:00:00"}],
# This one would pass if TZ (with any, or even no, value) were in
# the environment.
['regress-1', "-u -d '1996-11-10 0:00:00 +0' $fmt",
- {OUT=>"1996-11-10 00:00:00\n"},
+ {OUT=>"1996-11-10 00:00:00"},
{ENV =>'LANG=C'}],
- ['datevtime-1', "-d 000909 $fmt", {OUT=>"2000-09-09 00:00:00\n"}],
+ ['datevtime-1', "-d 000909 $fmt", {OUT=>"2000-09-09 00:00:00"}],
# test for RFC-822 conformance
- ['rfc822-1', "-R -d '$d1'", {OUT=>"Sun, 19 Jan 1997 08:17:48 +0000\n"},
+ ['rfc822-1', "-R -d '$d1'", {OUT=>"Sun, 19 Jan 1997 08:17:48 +0000"},
{ENV => 'LC_ALL=de_DE TZ=UTC0'}],
# Relative seconds, with time. fixed in 2.0j
['relative-1', "--utc -d '1970-01-01 00:00:00 UTC +961062237 sec' $fmt",
- {OUT=>"2000-06-15 09:43:57\n"}],
+ {OUT=>"2000-06-15 09:43:57"}],
# Relative seconds, no time.
['relative-2', "--utc -d '1970-01-01 UTC +961062237 sec' $fmt",
- {OUT=>"2000-06-15 09:43:57\n"},
+ {OUT=>"2000-06-15 09:43:57"},
{ENV => 'TZ=UTC+1'}],
# This would infloop (or appear to) prior to coreutils-4.5.5,
# due to a bug in strftime.c.
- ['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . "1999\n"}],
+ ['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . "1999"}],
# Ensure that we can parse MONTHNAME-DAY-YEAR.
- ['moname-d-y', '--iso -d May-23-2003', {OUT=>"2003-05-23\n"}],
+ ['moname-d-y', '--iso -d May-23-2003', {OUT=>"2003-05-23"}],
['epoch', '--iso=sec -d @31536000',
- {OUT=>"1971-01-01T00:00:00+0000\n"}],
+ {OUT=>"1971-01-01T00:00:00+0000"}],
['ns-10', '--iso=ns', '-d "1969-12-31 13:00:00.00000001-1100"',
- {OUT=>"1970-01-01T00:00:00,000000010+0000\n"}],
+ {OUT=>"1970-01-01T00:00:00,000000010+0000"}],
['ns-max32', '--iso=ns', '-d "2038-01-19 03:14:07.999999999"',
- {OUT=>"2038-01-19T03:14:07,999999999+0000\n"}],
+ {OUT=>"2038-01-19T03:14:07,999999999+0000"}],
['ns-relative',
'--iso=ns', "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'",
- {OUT=>"2000-06-15T09:43:58,111111021+0000\n"}],
+ {OUT=>"2000-06-15T09:43:58,111111021+0000"}],
# Since coreutils/lib/getdate.y revision 1.96 (post-coreutils-5.3.0),
# a command like the following would mistakenly exit nonzero with an
@@ -186,17 +186,17 @@ my @Tests =
# which daylight savings time is in effect for the starting date.
# Unfortunately (for ease of testing), if you set TZ at all, this
# failure is not triggered, hence the removal of TZ from the environment.
- ['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>"2005\n"},
+ ['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>"2005"},
{ENV_DEL => 'TZ'},
],
- ['empty-fmt', '+', {OUT=>"\n"}],
+ ['empty-fmt', '+', {OUT=>""}],
- ['neg-secs', '-d @-22 +%05s', {OUT=>"-0022\n"}],
+ ['neg-secs', '-d @-22 +%05s', {OUT=>"-0022"}],
# Before today's fix, date would print uninitialized data
# to standard output for an out-of-range date:
- # $ /p/bin/date -d @$(echo 2^56-1|bc) 2> /dev/null | od -a -N3
+ # $ date -d @$(echo 2^56-1|bc) 2> /dev/null | od -a -N3
# 0000000 p 4 6
# 0000003
['uninit-64', '-d @72057594037927935',
@@ -216,10 +216,28 @@ my @Tests =
foreach my $i (1..364)
{
push @Tests, ["cross-dst$i",
- "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005\n"},
+ "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005"},
{ENV_DEL => 'TZ'},
];
}
+use Data::Dumper;
+
+# Append "\n" to each OUT=> RHS if the expected exit value is either
+# zero or not specified (defaults to zero).
+foreach my $t (@Tests)
+ {
+ my $exit_val;
+ foreach my $e (@$t)
+ {
+ ref $e && ref $e eq 'HASH' && defined $e->{EXIT}
+ and $exit_val = $e->{EXIT};
+ }
+ foreach my $e (@$t)
+ {
+ ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val
+ and $e->{OUT} .= "\n";
+ }
+ }
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
@@ -228,5 +246,3 @@ my $prog = 'date';
my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
EOF
-
-j