@@ -4,10 +4,12 @@ import pathlib
import subprocess
import sys
import typing
import re
from pathlib import Path
THIS_FILE = pathlib.Path(__file__).absolute().parent
REMOVE_REGEX = re.compile('PPU:\s*[-0-9]+,\s*[0-9]+')
def parse_args():
@@ -20,6 +22,8 @@ def parse_args():
default="nestest.nes")
parser.add_argument("--nestest-bin",
type=pathlib.Path)
parser.add_argument("--min-matching-lines",
type=int)
args = parser.parse_args()
return args
@@ -34,7 +38,7 @@ def run_nestest(nestest_bin: Path, nestest_rom: Path) -> typing.List[str]:
if 'Bad instruction' in l:
lines.append(l.strip())
break
line = l[0:l.index('PPU:')].strip()
line = REMOVE_REGEX.sub('', l).strip()
lines.append(line)
return lines
@@ -44,7 +48,7 @@ def load_log(nestest_log: Path) -> typing.List[str]:
lines = []
with nestest_log.open('r') as f:
for l in f:
line = l[0:l.index('PPU:')].strip()
line = REMOVE_REGEX.sub('', l).strip()
lines.append(line)
return lines
@@ -64,6 +68,12 @@ def main():
print(f'Missmatch detected on line: {line}')
print('\n'.join(diff))
if args.min_matching_lines:
if line < args.min_matching_lines:
print(f'Expected at least: {args.min_matching_lines} successful lines')
sys.exit(1)
else:
sys.exit(0)
sys.exit(0 if success else 1)