aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-02-12 22:02:12 -0800
committerRob Landley <rob@landley.net>2019-02-13 05:56:55 -0600
commit318e7009e92ede1dfcc49ff1249396fd43757619 (patch)
treeeb36fc50a08355567d6a0efa5e7733db825ae675
parentb928ec480cd73fd83511c0f5ca786d1b9f3167c3 (diff)
downloadtoybox-318e7009e92ede1dfcc49ff1249396fd43757619.tar.gz
date: more test cleanup.
Add the SKIP_HOST=1 for the POSIX inputs to -d that coreutils doesn't support. Fix some comments now Rob's pointed out that the "weird" format was just POSIX with implicit CCYY or CC. (I was confused because coreutils rejects them [as it rejects all POSIX input to -d], but busybox does accept them, but interprets them differently, as explained in the test comments.) Also rename the tests to make it clearer that these are all POSIX format.
-rw-r--r--tests/date.test23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/date.test b/tests/date.test
index e0da9a44..fd45773f 100644
--- a/tests/date.test
+++ b/tests/date.test
@@ -4,23 +4,26 @@
#testing "name" "command" "result" "infile" "stdin"
-# Use a consistent TZ for these tests, but not GMT/UTC because that makes mistakes harder to spot.
+# Use a consistent TZ for these tests, but not GMT/UTC because that
+# makes mistakes harder to spot.
tz=Europe/London
# Unix date parsing.
testing "-d @0" "TZ=$tz date -d @0 2>&1" "Thu Jan 1 01:00:00 BST 1970\n" "" ""
testing "-d @0x123 invalid" "TZ=$tz date -d @0x123 2>/dev/null || echo expected error" "expected error\n" "" ""
-# TODO: these are rejected by coreutils and interpreted differently by busybox.
-# busybox thinks this should use the current year, not 1900.
-testing "-d 06021234" "TZ=$tz date -d 06021234 2>&1" "Sun Jun 2 12:34:00 UTC 1900\n" "" ""
-# busybox thinks this is the year 603 (ISO time 0602-12-34 19:82 with out of range fields normalized).
-testing "-d 060212341982" "TZ=$tz date -d 060212341982 2>&1" "Sun Jun 2 12:34:00 UTC 1982\n" "" ""
-
# POSIX format with 2- and 4-digit years.
-# TODO: coreutils rejects POSIX format supplied to -d.
-testing "-d 1110143115.30" "TZ=$tz date -d 1110143115.30 2>&1" "Sun Nov 10 14:31:30 UTC 1915\n" "" ""
-testing "-d 111014312015.30" "TZ=$tz date -d 111014312015.30 2>&1" "Sun Nov 10 14:31:30 UTC 2015\n" "" ""
+# All SKIP_HOST=1 because coreutils rejects POSIX format dates supplied to -d.
+# TODO: busybox thinks this should use the current year, not 1900, which would make more sense?
+SKIP_HOST=1 testing "-d MMDDhhmm" \
+ "TZ=$tz date -d 06021234 2>&1" "Sun Jun 2 12:34:00 UTC 1900\n" "" ""
+SKIP_HOST=1 testing "-d MMDDhhmmYY.SS" \
+ "TZ=$tz date -d 1110143115.30 2>&1" "Sun Nov 10 14:31:30 UTC 1915\n" "" ""
+# busybox thinks this is the year 603 (ISO time 0602-12-34 19:82 with out of range fields normalized).
+SKIP_HOST=1 testing "-d MMDDhhmmCCYY" \
+ "TZ=$tz date -d 060212341982 2>&1" "Sun Jun 2 12:34:00 UTC 1982\n" "" ""
+SKIP_HOST=1 testing "-d MMDDhhmmCCYY.SS" \
+ "TZ=$tz date -d 111014312015.30 2>&1" "Sun Nov 10 14:31:30 UTC 2015\n" "" ""
# ISO date format.
testing "-d 1980-01-02" "TZ=$tz date -d 1980-01-02 2>&1" "Wed Jan 2 00:00:00 GMT 1980\n" "" ""