"""TDD: builder must use -scheme and derivedDataPath, not -target incompatible form."""
from pathlib import Path
import tempfile
def test_builder_uses_scheme_and_derived_data_path():
from reyna_cli import app_bundle as ab
repo_root = Path(tempfile.mkdtemp()) / "repo"
(repo_root / "native" / "ReynaCLIHost" / "ReynaCLIHost.xcodeproj").mkdir(parents=True)
(repo_root / "native" / "ReynaCLIHost" / "ReynaCLIHost").mkdir(parents=True, exist_ok=True)
(repo_root / "native" / "ReynaCLIHost" / "ReynaCLIHost" / "Info.plist").write_text("")
derived = repo_root / "custom" / "DerivedData"
cmd = ab.build_xcodebuild_command(repo_root=repo_root, derived_data_path=derived, disable_code_signing=True)
# Must use -scheme with valid scheme name
assert "-scheme" in cmd, f"expected -scheme in {cmd}, got {cmd}"
scheme_idx = cmd.index("-scheme")
assert cmd[scheme_idx + 1] == "Reyna CLI", f"scheme name mismatch {cmd}"
# Must have derivedDataPath
assert "-derivedDataPath" in cmd
dd_idx = cmd.index("-derivedDataPath")
assert cmd[dd_idx + 1] == str(derived)
# Must NOT use -target with -derivedDataPath (invalid, RC 64)
assert "-target" not in cmd, f"must not use -target when using -derivedDataPath, got {cmd}"
# Must still contain configuration Release and build verb
assert "-configuration" in cmd
assert "Release" in cmd
assert "build" in cmd
assert "CODE_SIGNING_ALLOWED=NO" in cmd
def test_builder_unsigned_variant_still_uses_scheme():
from reyna_cli import app_bundle as ab
repo_root = Path(tempfile.mkdtemp()) / "repo"
(repo_root / "native" / "ReynaCLIHost" / "ReynaCLIHost.xcodeproj").mkdir(parents=True)
(repo_root / "native" / "ReynaCLIHost" / "ReynaCLIHost").mkdir(parents=True, exist_ok=True)
(repo_root / "native" / "ReynaCLIHost" / "ReynaCLIHost" / "Info.plist").write_text("")
derived = repo_root / "custom" / "DerivedData"
cmd_signed = ab.build_xcodebuild_command(repo_root=repo_root, derived_data_path=derived, disable_code_signing=False)
assert "-scheme" in cmd_signed
assert "-target" not in cmd_signed