ya2 · news · projects · code · about

fixes for building
authorFlavio Calva <f.calva@gmail.com>
Tue, 10 May 2022 17:48:10 +0000 (18:48 +0100)
committerFlavio Calva <f.calva@gmail.com>
Tue, 10 May 2022 17:48:10 +0000 (18:48 +0100)
lib/engine/functional.py
lib/tools/functional_test.py

index 667e41bf22c809098a7dfb7ad08d5f7a0f0bd07c..4098a2aef040ab8f692ce223371c0c0cecc5a6d8 100644 (file)
@@ -39,6 +39,8 @@ class ListenerThread(Thread):
                     taskMgr.doMethodLater(.01, self._callbacks[1], 'cb1', [msg[1]])
                 elif msg[0] == 'verify':
                     taskMgr.doMethodLater(.01, self._callbacks[2], 'cb2')
+                elif msg[0] == 'set_idx':
+                    taskMgr.doMethodLater(.01, self._callbacks[3], 'cb3', [msg[1]])
             except EOFError:
                 running = False
 
@@ -47,7 +49,7 @@ class FunctionalTest(GameObject):
 
     def __init__(self, ref):
         super().__init__()
-        self._listener = ListenerThread([self._do_screenshot, self._do_enforce_res, self.__verify])
+        self._listener = ListenerThread([self._do_screenshot, self._do_enforce_res, self.__verify, self._set_idx])
         self._listener.start()
         self.txt = OnscreenText('', fg=(1, 0, 0, 1), scale=.16)
         #self._path = ''
@@ -64,14 +66,16 @@ class FunctionalTest(GameObject):
             self._path = join(
                 Filename().get_user_appdata_directory(),
                 'pmachines/tests/functional_ref_%s/' % _branch())
-        #if int(idx) == 1:
-        #    rmtree(self._path, ignore_errors=True)
-        info('creating dir: %s' % self._path)
-        makedirs(self._path, exist_ok=True)
         self._fnames = []
         #taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
         #self._do_screenshots(idx)
 
+    def _set_idx(self, idx):
+        if int(idx) == 1:
+            rmtree(self._path, ignore_errors=True)
+        info('creating dir: %s' % self._path)
+        makedirs(self._path, exist_ok=True)
+
     def _do_screenshot(self, name):
         self._fnames += [self._path + name]
         #time = datetime.datetime.now().strftime('%y%m%d%H%M%S')
index 3d596bfae8b1daa1486f141c246045872686a0a4..0e2cefeeb8db8793386e0bc4a1e1e632449a923b 100644 (file)
@@ -1,8 +1,8 @@
 '''Create ref:
 * M-x fla-set-fun-test
 * rm options.ini
-* python main.py --functional-test 1 --functional-ref
-* python main.py --functional-test 2 --functional-ref
+* python main.py --functional-test --functional-ref & python -m lib.tools.functional_test.py 1
+* python main.py --functional-test --functional-ref & python -m lib.tools.functional_test.py 2
 * M-x fla-unset-fun-test'''
 from panda3d.core import load_prc_file_data
 load_prc_file_data('', 'window-type none')
@@ -42,6 +42,7 @@ class FunctionalTest(GameObject):
         self._tasks = []
         self._prev_time = 0
         taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
+        self._conn.send(['set_idx', idx])
         self._do_screenshots(idx)
 
     def _do_screenshot(self, name):