import pytest from scripts.msvc_harness.config import load_config from scripts.msvc_harness.discovery import DiscoveryError, discover_project from scripts.msvc_harness.models import ProjectKind def test_discover_project_skips_empty_repository(tmp_path): result = discover_project(tmp_path, load_config(tmp_path)) assert result.selection is None def test_discover_project_prefers_cmake(tmp_path): cmake_lists = tmp_path / "CMakeLists.txt" cmake_lists.write_text("cmake_minimum_required(VERSION 3.25)\n", encoding="utf-8") (tmp_path / "fallback.sln").write_text("", encoding="utf-8") result = discover_project(tmp_path, load_config(tmp_path)) assert result.selection is not None assert result.selection.kind is ProjectKind.CMAKE assert result.selection.project_file == cmake_lists def test_discover_project_rejects_orphan_cpp_project(tmp_path): (tmp_path / "orphan.cpp").write_text("int value = 0;\n", encoding="utf-8") with pytest.raises(DiscoveryError, match="C/C\\+\\+ files exist"): discover_project(tmp_path, load_config(tmp_path))