From e3999d33c0347ca000fdafc2e9169701a9d69e0f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 13 Apr 2019 11:40:37 +0200 Subject: Squashed 'waflib/' changes from e7a29b6..cddbcb5 cddbcb5 Pass file comparison test if difflib finds no changes 6e4e92b Seek to end before checking the size of stderr output git-subtree-dir: waflib git-subtree-split: cddbcb577dad255414b6454d8680a6cd80ad7458 --- extras/autowaf.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/extras/autowaf.py b/extras/autowaf.py index 51077d1..d779967 100644 --- a/extras/autowaf.py +++ b/extras/autowaf.py @@ -807,11 +807,15 @@ def show_diff(from_lines, to_lines, from_filename, to_filename): import difflib import sys + same = True for line in difflib.unified_diff( from_lines, to_lines, fromfile=os.path.abspath(from_filename), tofile=os.path.abspath(to_filename)): sys.stderr.write(line) + same = False + + return same def test_file_equals(patha, pathb): import filecmp @@ -827,9 +831,7 @@ def test_file_equals(patha, pathb): with io.open(patha, 'rU', encoding='utf-8') as fa: with io.open(pathb, 'rU', encoding='utf-8') as fb: - show_diff(fa.readlines(), fb.readlines(), patha, pathb) - - return False + return show_diff(fa.readlines(), fb.readlines(), patha, pathb) def bench_time(): if hasattr(time, 'perf_counter'): # Added in Python 3.3 @@ -888,9 +890,10 @@ class TestScope: if 'stderr' in kwargs and kwargs['stderr'] == NONEMPTY: # Run with a temp file for stderr and check that it is non-empty import tempfile - with tempfile.TemporaryFile(mode='w') as stderr: + with tempfile.TemporaryFile() as stderr: kwargs['stderr'] = stderr output = self.run(test, **kwargs) + stderr.seek(0, 2) # Seek to end return (output if not output else self.run( lambda: stderr.tell() > 0, -- cgit v1.2.1