eris/tests/worker_test.py
Andrew Hamilton eebb226b21 Use worker threads instead of subprocesses, bump to 2026.8.3
Convert each Worker from a subprocess to a thread running the tool in a
ThreadPoolExecutor, so eris can run free-threaded under CPython 3.14t.
Bump fill3 and lscolors deps to 2026.8.3 for the GIL-free cwcwidth chain.
2026-08-03 09:46:44 +10:00

39 lines
1 KiB
Python
Executable file

import asyncio
import os
import shutil
import tempfile
import unittest
import eris.tools as tools
import eris.worker as worker
class WorkerTestCase(unittest.TestCase):
def setUp(self):
self.temp_dir = tempfile.mkdtemp()
self.original_working_dir = os.getcwd()
os.chdir(self.temp_dir)
os.mkdir(tools.CACHE_PATH)
open("foo", "w").close()
def tearDown(self):
if hasattr(self, "worker_"):
self.worker_.kill()
shutil.rmtree(self.temp_dir)
os.chdir(self.original_working_dir)
def test_run_job(self):
loop = asyncio.new_event_loop()
compression = "none"
self.worker_ = worker.Worker(compression)
future = self.worker_.run_tool("foo", tools.metadata)
status = loop.run_until_complete(future)
self.assertEqual(status, tools.Status.ok)
result_path = os.path.join(tools.CACHE_PATH, "foo-metadata")
self.assertTrue(os.path.exists(result_path))
if __name__ == "__main__":
unittest.main()