Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

30 rindas
1.6KB

  1. #!/usr/bin/env python3
  2. """regress.py - build each test program with and without the optimizer, run both in VICE and
  3. compare the final screens (ignoring the blinking cursor cell). Needs PIL (pip install pillow).
  4. python tools/regress.py [tests/sem.c tests/uge.c ...]
  5. """
  6. import os, sys, subprocess
  7. from PIL import Image, ImageChops
  8. HERE = os.path.dirname(os.path.abspath(__file__))
  9. ROOT = os.path.normpath(os.path.join(HERE, '..'))
  10. tests = sys.argv[1:] or [os.path.join(ROOT, 'tests', t) for t in ('sem.c',)]
  11. ok = True
  12. for src in tests:
  13. name = os.path.splitext(os.path.basename(src))[0]
  14. shots = {}
  15. for mode in ('orig', 'opt'):
  16. d = os.path.join(ROOT, 'work', 'regress_%s_%s' % (name, mode))
  17. cmd = ['powershell', '-NoProfile', '-File', os.path.join(HERE, 'pcbuild.ps1'), '-Src', src, '-Name', name,
  18. '-Dir', d, '-Run', '\n', '-Settle', '60'] + (['-NoOpt'] if mode == 'orig' else [])
  19. r = subprocess.run(cmd, capture_output=True, text=True)
  20. size = [l for l in r.stdout.splitlines() if 'linked' in l]
  21. shots[mode] = (os.path.join(d, 'run.png'), size[-1] if size else 'LINK FAILED')
  22. a = Image.open(shots['orig'][0]).convert('RGB'); b = Image.open(shots['opt'][0]).convert('RGB')
  23. diff = ImageChops.difference(a, b).getbbox()
  24. # the blinking cursor is a single 8x8 cell
  25. same = diff is None or (diff[2] - diff[0] <= 8 and diff[3] - diff[1] <= 8)
  26. print('%-8s orig: %-24s opt: %-24s screens %s' % (name, shots['orig'][1], shots['opt'][1], 'IDENTICAL' if same else 'DIFFER %s' % (diff,)))
  27. ok &= same
  28. sys.exit(0 if ok else 1)

Powered by TurnKey Linux.