Add workaround for system dependent date comparison
The date injection used in the tests for the main view's "show-changes"
feature fails on some systems either because the TZ environment variable
does not work as expected or because the time to execute the test causes
the generated timestamp to be off (Cygwin). Fix both issues by simply
replacing the dates with a dummy string.
As reported by Ramsay Jones, the recent commit
bac9dcef ("Add test for
displayment of index changes in the main view", 15-06-2014) adds a test
that fails on Linux (Mint 17).
The failures (5 failed assertions in the test/main/show-changes-test
test), are all due to the test expecting the timestamp on Un/staged
changes to be in UTC but they are actually in BST (DST for my timezone).
If I change the test, like so:
$ git diff
diff --git a/test/main/show-changes-test b/test/main/show-changes-test
index
df3c318..
c337def 100755
--- a/test/main/show-changes-test
+++ b/test/main/show-changes-test
@@ -59,7 +59,7 @@ in_work_dir prepare_git_repo
test_tig
-YYY_MM_DD_HH_MM="$(date +"%Y-%m-%d %H:%M")"
+YYY_MM_DD_HH_MM="$(unset TZ; date +"%Y-%m-%d %H:%M")"
assert_equals 'main-with-unstaged.screen' <<EOF
$YYY_MM_DD_HH_MM Unknown o Unstaged changes
$
... then the test passes. This is not the fix, of course, it just helps
diagnose the problem. Note that if I run tig thus:
$ TZ=UTC ./src/tig
... with an unstaged change, then the timestamp still shows as BST.
So, the handling of the tz data in main_add_changes_commit() seems
to be off somehow. (Isn't use of the tz parameter in gettimeofday()
discouraged because it's not portable/reliable?).
I should note that (on a different laptop) on 64-bit cygwin, the test
runs just fine - most of the time! :-P Occasionally, it will fail with
the timestamp differing by one minute ...