Selaa lähdekoodia

fix-test-route-6400-cli-to-v1-verification

root 3 kuukautta sitten
vanhempi
commit
7d0a5dd993
3 muutettua tiedostoa jossa 48 lisäystä ja 8 poistoa
  1. 22 0
      tests/unit/test_fw_6400_v1_entrypoint.py
  2. 23 6
      tools/fw_cli.py
  3. 3 2
      tools/run_6400_v1.py

+ 22 - 0
tests/unit/test_fw_6400_v1_entrypoint.py

@@ -0,0 +1,22 @@
+from __future__ import annotations
+
+import inspect
+import sys
+from unittest import mock
+
+from tools import fw_cli
+
+
+def test_fw_test_6400_uses_current_v1_runner() -> None:
+    expected_actions = ["unit"] if sys.platform == "win32" else ["all"]
+
+    with (
+        mock.patch("tools.fw_cli._generate_one"),
+        mock.patch("tools.run_6400_v1.main", return_value=0) as current_runner,
+    ):
+        assert fw_cli.main(["test", "6400"]) == 0
+
+    current_runner.assert_called_once_with(expected_actions)
+    dispatch_source = inspect.getsource(fw_cli._run_6400_verify)
+    assert "from tools.run_6400_v1 import" in dispatch_source
+    assert "from tools.run_6400_verify import" not in dispatch_source

+ 23 - 6
tools/fw_cli.py

@@ -74,9 +74,26 @@ def cmd_generate(args: argparse.Namespace) -> int:
 
 
 
 
 def _python() -> str:
 def _python() -> str:
-    from tools.run_6400_verify import _python as verify_python
-
-    return verify_python()
+    for candidate in (
+        os.environ.get("PRODU2_VERIFY_PYTHON"),
+        "/data/prod2u/venvs/verify/bin/python",
+        "/data/prod2u/bin/python3",
+        sys.executable,
+    ):
+        if not candidate:
+            continue
+        path = Path(candidate)
+        if not path.is_file():
+            continue
+        probe = subprocess.run(
+            [str(path), "-c", "import pytest"],
+            stdout=subprocess.DEVNULL,
+            stderr=subprocess.DEVNULL,
+            check=False,
+        )
+        if probe.returncode == 0:
+            return str(path)
+    return sys.executable
 
 
 
 
 def cmd_build(args: argparse.Namespace) -> int:
 def cmd_build(args: argparse.Namespace) -> int:
@@ -121,10 +138,10 @@ def _run_mrdimm_matrix(lanes: str) -> int:
 
 
 
 
 def _run_6400_verify() -> int:
 def _run_6400_verify() -> int:
-    from tools.run_6400_verify import main as verify_6400
+    from tools.run_6400_v1 import main as verify_6400
 
 
-    lanes = ["unit"] if sys.platform == "win32" else ["unit", "icarus", "formal"]
-    return verify_6400(lanes)
+    actions = ["unit"] if sys.platform == "win32" else ["all"]
+    return verify_6400(actions)
 
 
 
 
 def cmd_test(args: argparse.Namespace) -> int:
 def cmd_test(args: argparse.Namespace) -> int:

+ 3 - 2
tools/run_6400_v1.py

@@ -91,6 +91,7 @@ def unit() -> None:
         "tests/unit/test_6400_v1_contract.py",
         "tests/unit/test_6400_v1_contract.py",
         "tests/unit/test_6400_v1_source_closure.py",
         "tests/unit/test_6400_v1_source_closure.py",
         "tests/unit/test_encode_6400_hex.py",
         "tests/unit/test_encode_6400_hex.py",
+        "tests/unit/test_fw_6400_v1_entrypoint.py",
     ])
     ])
 
 
 
 
@@ -106,13 +107,13 @@ def pi_differential() -> None:
     run(["python3", "tests/cocotb/run_6400_pi_differential.py"])
     run(["python3", "tests/cocotb/run_6400_pi_differential.py"])
 
 
 
 
-def main() -> int:
+def main(argv: list[str] | None = None) -> int:
     parser = argparse.ArgumentParser()
     parser = argparse.ArgumentParser()
     parser.add_argument(
     parser.add_argument(
         "action",
         "action",
         choices=("generate", "lint", "sim", "cocotb", "bmc", "pwm", "pi", "unit", "all"),
         choices=("generate", "lint", "sim", "cocotb", "bmc", "pwm", "pi", "unit", "all"),
     )
     )
-    args = parser.parse_args()
+    args = parser.parse_args(argv)
     if args.action in ("generate", "all"):
     if args.action in ("generate", "all"):
         generate()
         generate()
     if args.action in ("lint", "all"):
     if args.action in ("lint", "all"):