From 273a446d4507080e0f14842bab68b127c74bea69 Mon Sep 17 00:00:00 2001 From: Ivan Kosarev Date: Wed, 27 May 2020 10:49:01 +0300 Subject: [PATCH] [Tests] Use exceptions for quitting from the emulation loop. --- tests/runtime/check_test.py | 13 ++++++++++--- tests/runtime/update_test.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/runtime/check_test.py b/tests/runtime/check_test.py index 4d523d960..44ab2372d 100755 --- a/tests/runtime/check_test.py +++ b/tests/runtime/check_test.py @@ -5,6 +5,10 @@ import zx +class Stop(Exception): + pass + + class Tester(zx.Emulator): def __init__(self): # speed_factor=None results in maximum speed and @@ -13,7 +17,7 @@ def __init__(self): super().__init__(speed_factor=None) def on_breakpoint(self): - self.stop() + raise Stop def run_test(self, tape_filename, ram_filename): # Auto-load the tape. @@ -22,8 +26,11 @@ def run_test(self, tape_filename, ram_filename): # Catch the end of test. self.set_breakpoint(8) - # Run the main loop until self.done is raised. - self.run() + # Run the main loop. + try: + self.run() + except Stop: + pass # Get view to the video memory. screen = self.get_memory_view(0x4000, 6 * 1024 + 768) diff --git a/tests/runtime/update_test.py b/tests/runtime/update_test.py index e3f9413d3..84e124877 100755 --- a/tests/runtime/update_test.py +++ b/tests/runtime/update_test.py @@ -8,6 +8,10 @@ import zx +class Stop(Exception): + pass + + class TakeSnapshot(zx.Emulator): def __init__(self): # speed_factor=None results in maximum speed and @@ -25,13 +29,16 @@ def run_test(self, filename): # Catch the end of test. self.set_breakpoint(8) - # Run the main loop until self.done is raised. - self.run() + # Run the main loop. + try: + self.run() + except Stop: + pass # Get view to the video memory. screen = self.get_memory_view(0x4000, 6 * 1024 + 768) - # Compare it with the etalon screenshot. + # Take screenshot. with open(filename + '.scr', 'wb') as f: f.write(screen)