team-ljyzipelo

공개
42줄1.6 KB
1import importlib.util
2import os
3import subprocess
4from pathlib import Path
5import unittest
6from unittest.mock import patch
7
8ROOT = Path(__file__).resolve().parents[2]
9SPEC = importlib.util.spec_from_file_location(
10 "native_smoke", ROOT / "tests/rust-app-ui/native_smoke.py"
11)
12SMOKE = importlib.util.module_from_spec(SPEC)
13SPEC.loader.exec_module(SMOKE)
14
15
16class NativeSmokePathsTests(unittest.TestCase):
17 def test_default_binary_uses_common_work_target(self):
18 common = Path(subprocess.check_output(
19 ["git", "rev-parse", "--path-format=absolute", "--git-common-dir"],
20 cwd=ROOT, text=True,
21 ).strip()).resolve()
22 expected = common.parent / "tests/work/rust-local"
23 with patch.dict(os.environ):
24 os.environ.pop("ZIPELO_CI_JOB", None)
25 os.environ.pop("CARGO_TARGET_DIR", None)
26 work = SMOKE.work_directory()
27 self.assertEqual(work, expected)
28 self.assertEqual(SMOKE.binary_path(work),
29 work / "target/debug/zipelo-ui-memory-app")
30
31 def test_job_and_target_overrides_are_honored(self):
32 work = SMOKE.work_directory().parent / "native-smoke-paths"
33 target = work / "custom-target"
34 with patch.dict(os.environ, {"ZIPELO_CI_JOB": "native-smoke-paths",
35 "CARGO_TARGET_DIR": str(target)}):
36 self.assertEqual(SMOKE.work_directory(), work)
37 self.assertEqual(SMOKE.binary_path(work),
38 target / "debug/zipelo-ui-memory-app")
39
40
41if __name__ == "__main__":
42 unittest.main()