~sircmpwn/public-inbox

scdoc: Fix incorrectly failing tests v1 PROPOSED

I had to patch some failing tests when porting this to OpenBSD. I
believe these tests to be failing incorrectly rather than exposing
failures in the program, and I am upstreaming my patchset herein.

Raymond E. Pasco (2):
  Fix timezone-dependent tests
  Fix `date --date` dependent test

 test/preamble | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

-- 
2.25.0
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/public-inbox/patches/9572/mbox | git am -3
Learn more about email & git

[PATCH scdoc 1/2] Fix timezone-dependent tests Export this patch

These tests fail depending on timezone and current time if the date
differs from the UTC date. This was remedied by using `date -u`, which
is POSIX.
---
test/preamble | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/preamble b/test/preamble
index 71f1372..8f9de2a 100755
--- a/test/preamble
+++ b/test/preamble
@@ -41,31 +41,31 @@ end 0
unset SOURCE_DATE_EPOCH

begin "Writes the appropriate header"
scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date +'%F')"'"' >/dev/null
scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date -u +'%F')"'"' >/dev/null
test(8)
EOF
end 0

begin "Preserves dashes"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'"' >/dev/null
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'"' >/dev/null
test-manual(8)
EOF
end 0

begin "Handles extra footer field"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'" "Footer"' >/dev/null
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'" "Footer"' >/dev/null
test-manual(8) "Footer"
EOF
end 0

begin "Handles both extra fields"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'" "Footer" "Header"' >/dev/null
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'" "Footer" "Header"' >/dev/null
test-manual(8) "Footer" "Header"
EOF
end 0

begin "Emits empty footer correctly"
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'" "" "Header"' >/dev/null
scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date -u +'%F')"'" "" "Header"' >/dev/null
test-manual(8) "" "Header"
EOF
end 0
-- 
2.25.0

[PATCH scdoc 2/2] Fix `date --date` dependent test Export this patch

This test depends on a nonportable option for date(1). I am not sure
that there is a good portable way to do this, so I just directly
included the seconds since epoch that it would have computed. We're
testing scdoc, not testing the local system's date command.
---
 test/preamble | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/preamble b/test/preamble
index 8f9de2a..1634877 100755
--- a/test/preamble
+++ b/test/preamble
@@ -70,8 +70,7 @@ test-manual(8) "" "Header"
EOF
end 0

export TZ=UTC
export SOURCE_DATE_EPOCH=$(date --date="2017-12-09 23:18:57" +'%s')
export SOURCE_DATE_EPOCH=1512861537

begin "Supports \$SOURCE_DATE_EPOCH"
scdoc <<EOF | grep '^\.TH "reproducible-manual" "8" "2017-12-09"' >/dev/null
-- 
2.25.0
View this thread in the archives