From 067d48e54ce83a4299c0b505a84f554afc1dfbe8 Mon Sep 17 00:00:00 2001 From: Lenny Truong Date: Sat, 19 Oct 2024 16:10:59 -0400 Subject: [PATCH] Use tempfile for tests --- examples/riscv_mini/tests/test_alu.py | 11 +++++--- examples/riscv_mini/tests/test_cache.py | 36 ++++++++++++++----------- setup.py | 2 +- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/examples/riscv_mini/tests/test_alu.py b/examples/riscv_mini/tests/test_alu.py index ba4b45940..5a0f5bcac 100644 --- a/examples/riscv_mini/tests/test_alu.py +++ b/examples/riscv_mini/tests/test_alu.py @@ -1,3 +1,4 @@ +import tempfile import pytest import fault @@ -33,7 +34,9 @@ def test_alu_basic(alu): tester.eval() tester.circuit.O.expect(py_op(A, B)) - tester.compile_and_run("verilator", flags=["-Wno-unused"], - magma_opts={"disallow_local_variables": True, - "check_circt_opt_version": False}, - magma_output="mlir-verilog") + with tempfile.TemporaryDirectory() as tempdir: + tester.compile_and_run("verilator", flags=["-Wno-unused"], + directory=tempdir, + magma_opts={"disallow_local_variables": True, + "check_circt_opt_version": False}, + magma_output="mlir-verilog") diff --git a/examples/riscv_mini/tests/test_cache.py b/examples/riscv_mini/tests/test_cache.py index 22bfc2d18..69c99e843 100644 --- a/examples/riscv_mini/tests/test_cache.py +++ b/examples/riscv_mini/tests/test_cache.py @@ -1,5 +1,7 @@ import itertools import random +import tempfile + from hwtypes import BitVector import magma as m from magma.mantle.counter import Counter @@ -597,19 +599,21 @@ class TestState(m.Enum): tester = ResetTester(DUT, DUT.CLK) tester.reset() tester.wait_until_high(DUT.done) - tester.compile_and_run( - "verilator", - magma_opts={ - "flatten_all_tuples": True, - "disallow_local_variables": True, - "check_circt_opt_version": False, - }, - flags=[ - '-Wno-unused', - '-Wno-PINCONNECTEMPTY', - '--assert', - '-Wno-width', - ], - disp_type="realtime", - magma_output="mlir-verilog", - ) + with tempfile.TemporaryDirectory() as tempdir: + tester.compile_and_run( + "verilator", + directory=tempdir, + magma_opts={ + "flatten_all_tuples": True, + "disallow_local_variables": True, + "check_circt_opt_version": False, + }, + flags=[ + '-Wno-unused', + '-Wno-PINCONNECTEMPTY', + '--assert', + '-Wno-width', + ], + disp_type="realtime", + magma_output="mlir-verilog", + ) diff --git a/setup.py b/setup.py index e593ee429..faaf185fa 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ "staticfg", "networkx", "uinspect", - "circt==1.66.0", + # "circt==1.66.0", ], python_requires='>=3.6', long_description=long_description,