chore: import upstream snapshot with attribution
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:03:19 +08:00
commit 91e75e620b
3227 changed files with 1307078 additions and 0 deletions
@@ -0,0 +1,31 @@
"""Tests for cua-driver wheel build helpers."""
import importlib.util
from pathlib import Path
def load_build_wheel_module():
module_path = Path(__file__).resolve().parents[1] / "build_wheel.py"
spec = importlib.util.spec_from_file_location("build_wheel", module_path)
module = importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(module)
return module
def test_wheel_tags_are_platform_specific():
build_wheel = load_build_wheel_module()
assert build_wheel.get_wheel_tag("darwin", "universal") == "py3-none-macosx_11_0_universal2"
assert build_wheel.get_wheel_tag("linux", "x86_64") == "py3-none-manylinux_2_31_x86_64"
assert build_wheel.get_wheel_tag("linux", "arm64") == "py3-none-manylinux_2_31_aarch64"
assert build_wheel.get_wheel_tag("windows", "x86_64") == "py3-none-win_amd64"
assert build_wheel.get_wheel_tag("windows", "arm64") == "py3-none-win_arm64"
def test_license_metadata_stays_legacy_upload_compatible():
pyproject = Path(__file__).resolve().parents[1] / "pyproject.toml"
pyproject_text = pyproject.read_text()
assert 'license = { text = "MIT" }' in pyproject_text
assert 'license = "MIT"' not in pyproject_text
@@ -0,0 +1,85 @@
"""Tests for the cua-driver Python wrapper."""
import subprocess
import sys
from pathlib import Path
from unittest.mock import Mock, patch
import pytest
def test_get_binary_path():
"""Test that get_binary_path returns a valid path."""
from cua_driver.wrapper import get_binary_path
# This will raise FileNotFoundError if binary doesn't exist
# In CI, we need to build the package first for this to pass
try:
binary_path = get_binary_path()
assert binary_path.exists()
assert binary_path.name in ("cua-driver", "cua-driver.exe")
except FileNotFoundError:
# Expected in development without building
pytest.skip("Binary not bundled yet (run build_wheel.py first)")
def test_run_cua_driver_version(monkeypatch):
"""Test running cua-driver --version through the wrapper."""
from cua_driver.wrapper import run_cua_driver, get_binary_path
try:
binary_path = get_binary_path()
except FileNotFoundError:
pytest.skip("Binary not bundled yet")
# Run with --version
exit_code = run_cua_driver(["--version"])
assert exit_code == 0
def test_wrapper_preserves_exit_code():
"""Test that the wrapper preserves the binary's exit code."""
from cua_driver.wrapper import run_cua_driver, get_binary_path
try:
binary_path = get_binary_path()
except FileNotFoundError:
pytest.skip("Binary not bundled yet")
# Invalid command should return non-zero
exit_code = run_cua_driver(["--this-flag-does-not-exist"])
assert exit_code != 0
@patch("cua_driver.wrapper.subprocess.run")
@patch("cua_driver.wrapper.get_binary_path")
def test_subprocess_args(mock_get_binary, mock_run):
"""Test that subprocess is called with correct arguments."""
from cua_driver.wrapper import run_cua_driver
mock_binary = Path("/fake/path/cua-driver")
mock_get_binary.return_value = mock_binary
mock_run.return_value = Mock(returncode=0)
run_cua_driver(["mcp", "--help"])
mock_run.assert_called_once()
call_args = mock_run.call_args
assert call_args[0][0] == [str(mock_binary), "mcp", "--help"]
assert call_args[1]["stdin"] == sys.stdin
assert call_args[1]["stdout"] == sys.stdout
assert call_args[1]["stderr"] == sys.stderr
@patch("cua_driver.wrapper.subprocess.run")
@patch("cua_driver.wrapper.get_binary_path")
def test_keyboard_interrupt_handling(mock_get_binary, mock_run):
"""Test that KeyboardInterrupt returns exit code 130."""
from cua_driver.wrapper import run_cua_driver
mock_binary = Path("/fake/path/cua-driver")
mock_get_binary.return_value = mock_binary
mock_run.side_effect = KeyboardInterrupt()
exit_code = run_cua_driver(["mcp"])
assert exit_code == 130