From: Stefan Sperling Subject: -portable: fix some cmdline test failures To: gameoftrees@openbsd.org Date: Sun, 19 Sep 2021 19:04:24 +0200 This patch fixes test failures related the date(1) utility. In the long term we could add a wrapper function to detect valid options for date(1) and use the variant which works on the current OS. For now, this makes some tests pass and shows us where the problems are. diff --git a/regress/cmdline/blame.sh b/regress/cmdline/blame.sh index a9916124..243a3bc4 100755 --- a/regress/cmdline/blame.sh +++ b/regress/cmdline/blame.sh @@ -65,7 +65,7 @@ test_blame_basic() { local short_commit2=`trim_obj_id 32 $commit2` local short_commit3=`trim_obj_id 32 $commit3` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected @@ -113,7 +113,7 @@ test_blame_tag() { local short_commit1=`trim_obj_id 32 $commit1` local short_commit2=`trim_obj_id 32 $commit2` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected @@ -149,7 +149,7 @@ test_blame_file_single_line() { local short_commit1=`trim_obj_id 32 $commit1` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout @@ -184,7 +184,7 @@ test_blame_file_single_line_no_newline() { local short_commit1=`trim_obj_id 32 $commit1` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout @@ -213,7 +213,7 @@ test_blame_all_lines_replaced() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit1 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected @@ -265,7 +265,7 @@ test_blame_lines_shifted_up() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit3 $d $GOT_AUTHOR_8 foo" >> $testroot/stdout.expected @@ -321,7 +321,7 @@ test_blame_lines_shifted_down() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "01) $short_commit1 $d $GOT_AUTHOR_8 1" \ > $testroot/stdout.expected echo "02) $short_commit1 $d $GOT_AUTHOR_8 2" \ @@ -394,7 +394,7 @@ EOF local commit1=`git_show_head $testroot/repo` local short_commit1=`trim_obj_id 32 $commit1` local author_time1=`git_show_author_time $testroot/repo` - local d1=`date -u -r $author_time1 +"%G-%m-%d"` + local d1=`date -u -d "@$author_time1" +"%G-%m-%d"` cat > $testroot/wt/alpha < $testroot/wt/alpha < $testroot/wt/alpha < $testroot/stdout) @@ -718,7 +718,7 @@ test_blame_added_on_branch() { local short_commit2=`trim_obj_id 32 $commit2` local short_commit3=`trim_obj_id 32 $commit3` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected @@ -788,7 +788,7 @@ test_blame_symlink() { return 1 fi - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit0 $d $GOT_AUTHOR_8 alpha" \ > $testroot/stdout.expected @@ -809,7 +809,7 @@ test_blame_symlink() { return 1 fi - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit0 $d $GOT_AUTHOR_8 beta" \ > $testroot/stdout.expected @@ -958,7 +958,7 @@ EOF (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -d "@$author_time" +"%G-%m-%d"` echo "1) $short_commit5 $d $GOT_AUTHOR_8 X" > $testroot/stdout.expected echo "2) $short_commit1 $d $GOT_AUTHOR_8 A" >> $testroot/stdout.expected echo "3) $short_commit1 $d $GOT_AUTHOR_8 B" >> $testroot/stdout.expected diff --git a/regress/cmdline/commit.sh b/regress/cmdline/commit.sh index d2b9ef37..7ec03bec 100755 --- a/regress/cmdline/commit.sh +++ b/regress/cmdline/commit.sh @@ -1399,7 +1399,7 @@ EOF fi local author_time=`git_show_author_time $testroot/repo` - d=`date -u -r $author_time +"%a %b %e %X %Y UTC"` + d=`env LC_TIME=C date -u -d "@$author_time" +"%a %b %e %X %Y UTC"` echo "-----------------------------------------------" > $testroot/stdout.expected echo "commit $head_rev (master)" >> $testroot/stdout.expected echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected @@ -1438,7 +1438,7 @@ EOF fi local author_time=`git_show_author_time $testroot/repo` - d=`date -u -r $author_time +"%a %b %e %X %Y UTC"` + d=`env LC_TIME=C date -u -d "@$author_time" +"%a %b %e %X %Y UTC"` echo "-----------------------------------------------" \ > $testroot/stdout.expected echo "commit $head_rev (master)" >> $testroot/stdout.expected diff --git a/regress/cmdline/histedit.sh b/regress/cmdline/histedit.sh index 8c612faf..f17f516a 100755 --- a/regress/cmdline/histedit.sh +++ b/regress/cmdline/histedit.sh @@ -152,9 +152,9 @@ test_histedit_no_op() { # We should have a backup of old commits (cd $testroot/repo && got histedit -l > $testroot/stdout) - d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"` - d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"` - d_orig=`date -u -r $orig_author_time +"%G-%m-%d"` + d_orig2=`LC_TIME=C date -u -d "@$old_author_time2" +"%a %b %e %X %Y UTC"` + d_new2=`date -u -d "@$new_author_time2" +"%G-%m-%d"` + d_orig=`date -u -d "@$orig_author_time" +"%G-%m-%d"` cat > $testroot/stdout.expected < $testroot/stdout) - d_orig2=`date -u -r $orig_author_time2 +"%a %b %e %X %Y UTC"` - d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"` - d_0=`date -u -r $commit0_author_time +"%G-%m-%d"` + d_orig2=`env LC_TIME=C date -u -d "@$orig_author_time2" +"%a %b %e %X %Y UTC"` + d_new2=`date -u -d "@$new_author_time2" +"%G-%m-%d"` + d_0=`date -u -d "@$commit0_author_time" +"%G-%m-%d"` cat > $testroot/stdout.expected < $testroot/stdout @@ -184,11 +184,11 @@ test_tag_list_lightweight() { tag_id=`got ref -r $testroot/repo -l \ | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2` local tagger_time=`git_show_author_time $testroot/repo $tag` - d1=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"` + d1=`env LC_TIME=C date -u -d "@$tagger_time" +"%a %b %e %X %Y UTC"` tag_id2=`got ref -r $testroot/repo -l \ | grep "^refs/tags/$tag2" | tr -d ' ' | cut -d: -f2` local tagger_time2=`git_show_author_time $testroot/repo $tag2` - d2=`date -u -r $tagger_time2 +"%a %b %e %X %Y UTC"` + d2=`env LC_TIME=C date -u -d "@$tagger_time2" +"%a %b %e %X %Y UTC"` got tag -r $testroot/repo -l > $testroot/stdout