From d7013065ad5a66228fe595018fedcc76d97f36bd Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 16 Feb 2013 14:20:04 +0100 Subject: [PATCH] Fix tex2lyx file format comparison This is an important part of the tests. If updating the test cases is really a problem there are two better solutions than not testing the format: Convert the references with lyx2lyx on the fly, or remove the hard coupling of tex2lyx and LyX versions again. Both increase additional possible error sources, but these errors could at least be detected. If the test machinery is made blind for versions, file format errors are impossible to detect. --- src/tex2lyx/test/runtests.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/tex2lyx/test/runtests.py b/src/tex2lyx/test/runtests.py index 39e91f1222..c9c8e7380a 100755 --- a/src/tex2lyx/test/runtests.py +++ b/src/tex2lyx/test/runtests.py @@ -95,22 +95,18 @@ def main(argv): os.path.join(outputdir, base + ".lyx2.lyx"), uselyx2lyx) if lyxfile2 is None: errors.append(f) - else: + elif not filecmp.cmp(lyxfile1, lyxfile2, False): t1 = time.ctime(os.path.getmtime(lyxfile1)) t2 = time.ctime(os.path.getmtime(lyxfile2)) f1 = open(lyxfile1, 'r') f2 = open(lyxfile2, 'r') lines1 = f1.readlines() lines2 = f2.readlines() + diff = difflib.unified_diff(lines1, lines2, lyxfile1, lyxfile2, t1, t2) f1.close() f2.close() - # ignore the first 2 lines - # e.g. '#LyX file created ...' - # '\lyxformat ...' - if lines1[2:] != lines2[2:]: - diff = difflib.unified_diff(lines1, lines2, lyxfile1, lyxfile2, t1, t2) - sys.stdout.writelines(diff) - errors.append(f) + sys.stdout.writelines(diff) + errors.append(f) if len(errors) > 0: error('Converting the following files failed: %s' % ', '.join(errors)) -- 2.39.5