1From 0251229bfd9617e8a35cf9dd7d338d63fff74a0c Mon Sep 17 00:00:00 2001
2From: Assaf Gordon <assafgordon@gmail.com>
3Date: Mon, 13 May 2019 16:37:40 -0600
4Subject: [PATCH] tests: avoid false-positive in date-debug test
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9When debugging an invalid date due to DST switching, the intermediate
10'normalized time' should not be checked - its value can differ between
11systems (e.g. glibc vs musl).
12
13Reported by Niklas Hambüchen in
14https://lists.gnu.org/r/coreutils/2019-05/msg00031.html
15Analyzed by Rich Felker in
16https://lists.gnu.org/r/coreutils/2019-05/msg00039.html
17
18* tests/misc/date-debug.sh: Replace the exact normalized time
19with 'XX:XX:XX' so different values would not trigger test failure.
20---
21 tests/misc/date-debug.sh | 11 +++++++++--
22 1 file changed, 9 insertions(+), 2 deletions(-)
23
24diff --git a/tests/misc/date-debug.sh b/tests/misc/date-debug.sh
25index aa47f1abb..2ce6f4ce8 100755
26--- a/tests/misc/date-debug.sh
27+++ b/tests/misc/date-debug.sh
28@@ -71,7 +71,7 @@ date: input timezone: TZ="America/Edmonton" in date string
29 date: using specified time as starting value: '02:30:00'
30 date: error: invalid date/time value:
31 date: user provided time: '(Y-M-D) 2006-04-02 02:30:00'
32-date: normalized time: '(Y-M-D) 2006-04-02 03:30:00'
33+date: normalized time: '(Y-M-D) 2006-04-02 XX:XX:XX'
34 date: --
35 date: possible reasons:
36 date: non-existing due to daylight-saving time;
37@@ -81,7 +81,14 @@ date: invalid date 'TZ="America/Edmonton" 2006-04-02 02:30:00'
38 EOF
39
40 # date should return 1 (error) for invalid date
41-returns_ 1 date --debug -d "$in2" >out2 2>&1 || fail=1
42+returns_ 1 date --debug -d "$in2" >out2-t 2>&1 || fail=1
43+
44+# The output line of "normalized time" can differ between systems
45+# (e.g. glibc vs musl) and should not be checked.
46+# See: https://lists.gnu.org/archive/html/coreutils/2019-05/msg00039.html
47+sed '/normalized time:/s/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ XX:XX:XX/' \
48+ out2-t > out2 || framework_failure_
49+
50 compare exp2 out2 || fail=1
51
52 ##