Am Sonntag, 9. Juni 2013 um 10:50:19, schrieb Georg Baum <georg.b...@post.rwth-aachen.de> > Kornel Benko wrote: > > > OK, so may I change runtests.py again? If yes, when? > > IMO Yes, but I can't answer the when question > > > Georg
Anyway, here is the proposed patch:
diff --git a/src/tex2lyx/test/runtests.py b/src/tex2lyx/test/runtests.py index 47db3cc..c14b1ab 100755 --- a/src/tex2lyx/test/runtests.py +++ b/src/tex2lyx/test/runtests.py @@ -20,6 +20,16 @@ import os, string, sys, time, difflib, filecmp, subprocess, re def usage(prog_name): return "Usage: %s [uselyx2lyx] [<tex2lyx binary> [[<script dir>] [[<output dir>] [testfile]]]]" % prog_name +pat_fl = re.compile(r'^#LyX file created by tex2lyx 2\.1.*$') + +def compareLyx(lines1, lines2): + if lines1[1:] != lines2[1:]: + return False + if not pat_fl.match(lines1[0]): + return False + if not pat_fl.match(lines2[0]): + return False + return True def main(argv): # Parse and manipulate the command line arguments. @@ -102,18 +112,22 @@ def main(argv): os.path.join(outputdir, base + ".lyx2.lyx"), uselyx2lyx) if lyxfile2 is None: errors.append(f) - elif not filecmp.cmp(lyxfile1, lyxfile2, False): + else: 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() - sys.stdout.writelines(diff) - errors.append(f) + # ignore the first lone + # e.g. the version of lyx + if not compareLyx(lines1, lines2): + diff = difflib.unified_diff(lines1, lines2, lyxfile1, lyxfile2, t1, t2) + sys.stdout.writelines(diff) + errors.append(f) + if len(errors) > 0: error('Converting the following files failed: %s' % ', '.join(errors))
signature.asc
Description: This is a digitally signed message part.