changeset 2608:898386e48243

Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Feb 2025 01:35:23 -0800
parents 6b3b411f3339
children fbb5115b1a27
files zcompare.py
diffstat 1 files changed, 37 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/zcompare.py	Fri Feb 14 19:51:01 2025 -0800
+++ b/zcompare.py	Sat Feb 15 01:35:23 2025 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from glob import glob
 import subprocess
 from sys import exit,argv
@@ -14,7 +14,7 @@
 				if part.endswith('.bin'):
 					skip.add(part)
 		f.close()
-		print 'Skipping',len(skip),'entries from previous report.'
+		print('Skipping',len(skip),'entries from previous report.')
 	else:
 		prefixes.append(argv[i])
 
@@ -31,28 +31,45 @@
 		if not good:
 			continue
 	try:
-		b = subprocess.check_output(['./ztestrun', path])
+		b = subprocess.check_output(['./ztestrun', path]).decode()
 		try:
-			m = subprocess.check_output(['gxz80/gxzrun', path])
+			m = subprocess.check_output(['../blastem_clean/ztestrun', path]).decode()
 			#_,_,b = b.partition('\n')
+			m = m.split('\n')
+			b = b.split('\n')
 			if b != m:
-				print '-----------------------------'
-				print 'Mismatch in ' + path
-				print 'blastem output:'
-				print b
-				print 'gxz80 output:'
-				print m
-				print '-----------------------------'
+				lastWasFlags = False
+				bdiff = []
+				mdiff = []
+				for i in range(0, max(len(b), len(m))):
+					bl = b[i] if i < len(b) else ''
+					ml = m[i] if i < len(m) else ''
+					if bl != ml:
+						if lastWasFlags:
+							bdiff.append(b[i - 1])
+							mdiff.append(m[i - 1])
+						bdiff.append(bl)
+						mdiff.append(ml)
+					lastWasFlags =  bl.startswith('Flags: ')
+				print('-----------------------------')
+				print('Mismatch in ' + path)
+				print('blastem output:')
+				for b in bdiff:
+					print(b)
+				print('clean output:')
+				for m in mdiff:
+					print(m)
+				print('-----------------------------')
 			else:
-				print path, 'passed'
+				print(path, 'passed')
 		except subprocess.CalledProcessError as e:
-			print '-----------------------------'
-			print 'gxz80 exited with code', e.returncode, 'for test', path
-			print 'blastem output:'
-			print b
-			print '-----------------------------'
+			print('-----------------------------')
+			print('clean exited with code', e.returncode, 'for test', path)
+			print('blastem output:')
+			print(b)
+			print('-----------------------------')
 	except subprocess.CalledProcessError as e:
-		print '-----------------------------'
-		print 'blastem exited with code', e.returncode, 'for test', path
-		print '-----------------------------'
+		print('-----------------------------')
+		print('blastem exited with code', e.returncode, 'for test', path)
+		print('-----------------------------')