[diffoscope] 01/01: Reset mtimes of test directories and ignore ctimes
Reiner Herrmann
reiner at reiner-h.de
Wed Feb 24 21:47:55 CET 2016
This is an automated email from the git hooks/post-receive script.
deki-guest pushed a commit to branch master
in repository diffoscope.
commit b47d7cda8c5907fe71371e44d3f63669fd9ffce9
Author: Reiner Herrmann <reiner at reiner-h.de>
Date: Wed Feb 24 20:29:29 2016 +0100
Reset mtimes of test directories and ignore ctimes
The mtimes of the directories were not normalized to the same
value, which had the effect that diffoscope would also output
their time difference if it was measurable. This leads to a
test failure, as this output is not expected.
On fast systems the successive mkdir calls only sometimes resulted
in different mtimes, while on slow systems this was more often the
case (like on the armhf nodes). By adding a time.sleep(1) between
the mkdir calls, I was able to reproduce the test failure every time.
Additionally the ctimes have to be ignored, as the user has no
control over it and mkdir or os.utime calls also result in changed
ctimes (which differ if Python is not fast enough).
Closes: #815171
---
diffoscope/comparators/directory.py | 2 ++
tests/comparators/test_directory.py | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index 139e0b6..bd91eb0 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -48,6 +48,7 @@ class Stat(Command):
DEVICE_RE = re.compile(r'Device: [0-9a-f]+h/[0-9]+d')
INODE_RE = re.compile(r'Inode: [0-9]+')
ACCESS_TIME_RE = re.compile(r'^Access: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$')
+ CHANGE_TIME_RE = re.compile(r'^Change: [0-9]{4}-[0-9]{2}-[0-9]{2}.*$')
def filter(self, line):
line = line.decode('utf-8')
@@ -55,6 +56,7 @@ class Stat(Command):
line = Stat.DEVICE_RE.sub('', line)
line = Stat.INODE_RE.sub('', line)
line = Stat.ACCESS_TIME_RE.sub('', line)
+ line = Stat.CHANGE_TIME_RE.sub('', line)
return line.encode('utf-8')
diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
index 9416538..2e1cb4d 100644
--- a/tests/comparators/test_directory.py
+++ b/tests/comparators/test_directory.py
@@ -45,6 +45,10 @@ def differences(tmpdir):
shutil.copy(TEST_FILE2_PATH, str(tmpdir.join('b/dir/text')))
os.utime(str(tmpdir.join('a/dir/text')), (0, 0))
os.utime(str(tmpdir.join('b/dir/text')), (0, 0))
+ os.utime(str(tmpdir.join('a/dir')), (0, 0))
+ os.utime(str(tmpdir.join('b/dir')), (0, 0))
+ os.utime(str(tmpdir.join('a')), (0, 0))
+ os.utime(str(tmpdir.join('b')), (0, 0))
return compare_directories(str(tmpdir.join('a')), str(tmpdir.join('b'))).details
def test_content(differences):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list