윈도 수동 시험의 기본 작업 경로를 고침
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
1f848e38de51820bf5b29f9f868c320cd5694e1b- 부모
- cc63769
변경된 파일 8개
+107-17| @@ -59,7 +59,10 @@ def output_directory(work, name, create=False): | ||
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | def test_work_directory(root): |
| 62 | 삭제: return Path(os.environ.get("ZIPELO_TEST_WORK_DIR", root / "tests/work/rust-local")) | |
| 62 | 추가: configured = os.environ.get("ZIPELO_TEST_WORK_DIR") | |
| 63 | 추가: if configured: | |
| 64 | 추가: return Path(configured) | |
| 65 | 추가: return work_directory(root, os.environ.get("ZIPELO_CI_JOB", "rust-local")) | |
| 63 | 66 | |
| 64 | 67 | |
| 65 | 68 |
| @@ -7,13 +7,15 @@ import subprocess | ||
| 7 | 7 | import tempfile |
| 8 | 8 | import unittest |
| 9 | 9 | |
| 10 | 추가: import run_rust | |
| 11 | 추가: | |
| 10 | 12 | ROOT = Path(__file__).resolve().parents[2] |
| 11 | 13 | HELPER = ROOT / "packaging/ubuntu/rust/default-apps" |
| 12 | 14 | |
| 13 | 15 | |
| 14 | 16 | class DefaultAppsTests(unittest.TestCase): |
| 15 | 17 | def setUp(self): |
| 16 | 삭제: work = Path(os.environ["ZIPELO_TEST_WORK_DIR"]) | |
| 18 | 추가: work = run_rust.test_work_directory(ROOT) | |
| 17 | 19 | work.mkdir(exist_ok=True) |
| 18 | 20 | self.temporary = tempfile.TemporaryDirectory(dir=work) |
| 19 | 21 | self.addCleanup(self.temporary.cleanup) |
| @@ -5,13 +5,15 @@ import subprocess | ||
| 5 | 5 | import tempfile |
| 6 | 6 | import unittest |
| 7 | 7 | |
| 8 | 추가: import run_rust | |
| 9 | 추가: | |
| 8 | 10 | ROOT = Path(__file__).resolve().parents[2] |
| 9 | 11 | |
| 10 | 12 | |
| 11 | 13 | class IconBuildTests(unittest.TestCase): |
| 12 | 14 | @classmethod |
| 13 | 15 | def setUpClass(cls): |
| 14 | 삭제: work = Path(os.environ["ZIPELO_TEST_WORK_DIR"]) | |
| 16 | 추가: work = run_rust.test_work_directory(ROOT) | |
| 15 | 17 | cls.scratch = tempfile.TemporaryDirectory(dir=work) |
| 16 | 18 | cls.addClassCleanup(cls.scratch.cleanup) |
| 17 | 19 | cls.root = Path(cls.scratch.name) |
| @@ -12,6 +12,8 @@ from unittest.mock import patch | ||
| 12 | 12 | import zipfile |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 추가: import run_rust | |
| 16 | 추가: | |
| 15 | 17 | ROOT = Path(__file__).resolve().parents[2] |
| 16 | 18 | SPEC = importlib.util.spec_from_file_location( |
| 17 | 19 | "large_fixture_generator", ROOT / "tests/large-archive-fixtures/generate.py" |
| @@ -22,7 +24,7 @@ SPEC.loader.exec_module(GENERATOR) | ||
| 22 | 24 | |
| 23 | 25 | class LargeArchiveFixtureTests(unittest.TestCase): |
| 24 | 26 | def test_standalone_generator_uses_common_work_directory(self): |
| 25 | 삭제: expected = Path(os.environ["ZIPELO_TEST_WORK_DIR"]) | |
| 27 | 추가: expected = run_rust.test_work_directory(ROOT) | |
| 26 | 28 | with tempfile.TemporaryDirectory(dir=expected) as scratch: |
| 27 | 29 | relative = Path(scratch).name + "/corpus" |
| 28 | 30 | environment = dict(os.environ, ZIPELO_CI_JOB=expected.name) |
| @@ -36,7 +38,7 @@ class LargeArchiveFixtureTests(unittest.TestCase): | ||
| 36 | 38 | self.assertIn("11 cases", result.stdout) |
| 37 | 39 | |
| 38 | 40 | def test_standalone_verifier_uses_work_target(self): |
| 39 | 삭제: job = Path(os.environ["ZIPELO_TEST_WORK_DIR"]).name | |
| 41 | 추가: job = run_rust.test_work_directory(ROOT).name | |
| 40 | 42 | with patch.dict(os.environ, {"ZIPELO_CI_JOB": job}), patch.dict(sys.modules, {"generate": GENERATOR}): |
| 41 | 43 | os.environ.pop("ZIPELO_TEST_WORK_DIR", None) |
| 42 | 44 | os.environ.pop("CARGO_TARGET_DIR", None) |
| @@ -48,7 +50,7 @@ class LargeArchiveFixtureTests(unittest.TestCase): | ||
| 48 | 50 | self.assertEqual(verifier.default_target(), GENERATOR.work_root() / "target/debug") |
| 49 | 51 | |
| 50 | 52 | def test_boundary_archives_are_valid_and_expectations_straddle_limit(self): |
| 51 | 삭제: with tempfile.TemporaryDirectory(dir=os.environ["ZIPELO_TEST_WORK_DIR"]) as scratch: | |
| 53 | 추가: with tempfile.TemporaryDirectory(dir=run_rust.test_work_directory(ROOT)) as scratch: | |
| 52 | 54 | directory = Path(scratch) / "corpus" |
| 53 | 55 | manifest = GENERATOR.build(directory) |
| 54 | 56 | self.assertEqual(len(manifest["cases"]), 11) |
| @@ -82,7 +84,7 @@ class LargeArchiveFixtureTests(unittest.TestCase): | ||
| 82 | 84 | self.assertEqual(case["expected"]["created_count"], 0 if failed else 1) |
| 83 | 85 | |
| 84 | 86 | def test_former_ratio_samples_all_expect_success(self): |
| 85 | 삭제: with tempfile.TemporaryDirectory(dir=os.environ["ZIPELO_TEST_WORK_DIR"]) as scratch: | |
| 87 | 추가: with tempfile.TemporaryDirectory(dir=run_rust.test_work_directory(ROOT)) as scratch: | |
| 86 | 88 | manifest = GENERATOR.build(Path(scratch) / "corpus") |
| 87 | 89 | for suffix, delta in (("below", -1), ("equal", 0), ("above", 1)): |
| 88 | 90 | name = "ratio-" + suffix + ".gz" |
| @@ -96,7 +98,7 @@ class LargeArchiveFixtureTests(unittest.TestCase): | ||
| 96 | 98 | self.assertEqual(payload, bytes(artifact["payload_bytes"])) |
| 97 | 99 | |
| 98 | 100 | def test_generator_rejects_existing_destination_without_changes(self): |
| 99 | 삭제: with tempfile.TemporaryDirectory(dir=os.environ["ZIPELO_TEST_WORK_DIR"]) as scratch: | |
| 101 | 추가: with tempfile.TemporaryDirectory(dir=run_rust.test_work_directory(ROOT)) as scratch: | |
| 100 | 102 | directory = Path(scratch) |
| 101 | 103 | marker = directory / "keep" |
| 102 | 104 | marker.write_bytes(b"preserve") |
| @@ -107,7 +109,7 @@ class LargeArchiveFixtureTests(unittest.TestCase): | ||
| 107 | 109 | |
| 108 | 110 | def test_generator_requires_project_test_directory(self): |
| 109 | 111 | with self.assertRaises(ValueError): |
| 110 | 삭제: GENERATOR.build(Path(os.environ["ZIPELO_TEST_WORK_DIR"]).parent / "outside-tests") | |
| 112 | 추가: GENERATOR.build(run_rust.test_work_directory(ROOT).parent / "outside-tests") | |
| 111 | 113 | |
| 112 | 114 | def test_payload_source_enforces_bounded_reads(self): |
| 113 | 115 | source = GENERATOR.ZeroStream(GENERATOR.GIB) |
| @@ -0,0 +1,42 @@ | ||
| 1 | 추가: import importlib.util | |
| 2 | 추가: import os | |
| 3 | 추가: import subprocess | |
| 4 | 추가: from pathlib import Path | |
| 5 | 추가: import unittest | |
| 6 | 추가: from unittest.mock import patch | |
| 7 | 추가: | |
| 8 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 9 | 추가: SPEC = importlib.util.spec_from_file_location( | |
| 10 | 추가: "native_smoke", ROOT / "tests/rust-app-ui/native_smoke.py" | |
| 11 | 추가: ) | |
| 12 | 추가: SMOKE = importlib.util.module_from_spec(SPEC) | |
| 13 | 추가: SPEC.loader.exec_module(SMOKE) | |
| 14 | 추가: | |
| 15 | 추가: | |
| 16 | 추가: class 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 | 추가: | |
| 41 | 추가: if __name__ == "__main__": | |
| 42 | 추가: unittest.main() |
| @@ -22,7 +22,9 @@ class RunnerTests(unittest.TestCase): | ||
| 22 | 22 | for name in ("../escape", "other/job", "", ".hidden", "bad name"): |
| 23 | 23 | with self.subTest(name=name), self.assertRaises(ValueError): |
| 24 | 24 | run_rust.work_directory(run_rust.ROOT, name) |
| 25 | 삭제: self.assertEqual(run_rust.work_directory(run_rust.ROOT, os.environ["ZIPELO_CI_JOB"]), TEST_WORK) | |
| 25 | 추가: self.assertEqual(run_rust.work_directory( | |
| 26 | 추가: run_rust.ROOT, os.environ.get("ZIPELO_CI_JOB", "rust-local") | |
| 27 | 추가: ), TEST_WORK) | |
| 26 | 28 | |
| 27 | 29 | def test_work_directory_rejects_symlinked_parents_before_creation(self): |
| 28 | 30 | for link_name in ("tests", "tests/work"): |
| @@ -68,6 +70,8 @@ class RunnerTests(unittest.TestCase): | ||
| 68 | 70 | self.assertEqual(run_rust.output_directory(work, "tmp", create=True), link) |
| 69 | 71 | |
| 70 | 72 | def test_cargo_and_temp_paths_are_kept_in_job_directory(self): |
| 73 | 추가: if "ZIPELO_TEST_WORK_DIR" not in os.environ: | |
| 74 | 추가: self.skipTest("러너가 설정한 작업 경로에서 검사함") | |
| 71 | 75 | for key in ("CARGO_TARGET_DIR", "TMPDIR", "TMP", "TEMP", "ZIPELO_TEST_WORK_DIR"): |
| 72 | 76 | with self.subTest(key=key): |
| 73 | 77 | self.assertTrue(Path(os.environ[key]).resolve().is_relative_to(TEST_WORK)) |
| @@ -232,6 +236,15 @@ class RunnerTests(unittest.TestCase): | ||
| 232 | 236 | self.assertEqual(run_rust.shutil.which("x86_64-w64-mingw32-gcc-posix"), |
| 233 | 237 | str(executable)) |
| 234 | 238 | |
| 239 | 추가: def test_unconfigured_work_directory_uses_common_project(self): | |
| 240 | 추가: with patch.dict(os.environ), patch.object( | |
| 241 | 추가: run_rust, "work_directory", return_value=TEST_WORK | |
| 242 | 추가: ) as directory: | |
| 243 | 추가: os.environ.pop("ZIPELO_TEST_WORK_DIR", None) | |
| 244 | 추가: os.environ.pop("ZIPELO_CI_JOB", None) | |
| 245 | 추가: self.assertEqual(run_rust.test_work_directory(run_rust.ROOT), TEST_WORK) | |
| 246 | 추가: directory.assert_called_once_with(run_rust.ROOT, "rust-local") | |
| 247 | 추가: | |
| 235 | 248 | def test_local_bootstraps_missing_cross_tools_and_reloads_paths(self): |
| 236 | 249 | for root in (Path("/repo"), PurePosixPath("/repo"), PureWindowsPath("C:/repo")): |
| 237 | 250 | with self.subTest(root=root): |
| @@ -239,6 +252,7 @@ class RunnerTests(unittest.TestCase): | ||
| 239 | 252 | patch.object(run_rust, "prepare_cross_build", side_effect=[ValueError("missing"), None]) as detect, |
| 240 | 253 | patch.object(run_rust.subprocess, "run") as setup, |
| 241 | 254 | patch.object(run_rust, "prepare_tools") as reload, |
| 255 | 추가: patch.object(run_rust, "test_work_directory", return_value=root / "tests/work/rust-local"), | |
| 242 | 256 | ): |
| 243 | 257 | run_rust.prepare_local_tools(root) |
| 244 | 258 | setup.assert_called_once_with( |
| @@ -11,6 +11,8 @@ import sys | ||
| 11 | 11 | from unittest.mock import patch |
| 12 | 12 | import unittest |
| 13 | 13 | |
| 14 | 추가: import run_rust | |
| 15 | 추가: | |
| 14 | 16 | ROOT = Path(__file__).resolve().parents[2] |
| 15 | 17 | SPEC = importlib.util.spec_from_file_location("windows_installer", ROOT / "packaging/windows/rust/build.py") |
| 16 | 18 | MODULE = importlib.util.module_from_spec(SPEC) |
| @@ -19,7 +21,7 @@ SPEC.loader.exec_module(MODULE) | ||
| 19 | 21 | |
| 20 | 22 | class InstallerInputTests(unittest.TestCase): |
| 21 | 23 | def setUp(self): |
| 22 | 삭제: runs = Path(os.environ["ZIPELO_TEST_WORK_DIR"]) / "fixtures/windows-installer" | |
| 24 | 추가: runs = run_rust.test_work_directory(ROOT) / "fixtures/windows-installer" | |
| 23 | 25 | runs.mkdir(parents=True, exist_ok=True) |
| 24 | 26 | self.directory = tempfile.TemporaryDirectory(dir=runs) |
| 25 | 27 | self.addCleanup(self.directory.cleanup) |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import os |
| 2 | 추가: import re | |
| 2 | 3 | from pathlib import Path |
| 3 | 4 | import select |
| 4 | 5 | import signal |
| @@ -7,11 +8,33 @@ import time | ||
| 7 | 8 | |
| 8 | 9 | |
| 9 | 10 | ROOT = Path(__file__).resolve().parents[2] |
| 10 | 삭제: OUTPUT = ROOT / "tests/rust-app-ui" / ("screens-" + str(time.time_ns())) | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: def work_directory(): | |
| 14 | 추가: common = Path(subprocess.check_output( | |
| 15 | 추가: ["git", "rev-parse", "--path-format=absolute", "--git-common-dir"], | |
| 16 | 추가: cwd=ROOT, text=True, | |
| 17 | 추가: ).strip()).resolve() | |
| 18 | 추가: if common.name != ".git": | |
| 19 | 추가: raise RuntimeError("프로젝트 Git 작업 폴더를 찾을 수 없음") | |
| 20 | 추가: job = os.environ.get("ZIPELO_CI_JOB", "rust-local") | |
| 21 | 추가: if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]{0,63}", job): | |
| 22 | 추가: raise ValueError("안전한 작업명이 필요함") | |
| 23 | 추가: work = common.parent / "tests/work" / job | |
| 24 | 추가: if work.is_symlink() or not work.resolve().is_relative_to(common.parent / "tests/work"): | |
| 25 | 추가: raise ValueError("작업 폴더 밖의 경로는 허용하지 않음") | |
| 26 | 추가: return work | |
| 27 | 추가: | |
| 28 | 추가: | |
| 29 | 추가: def binary_path(work): | |
| 30 | 추가: target = Path(os.environ.get("CARGO_TARGET_DIR", work / "target")) | |
| 31 | 추가: return target / "debug/zipelo-ui-memory-app" | |
| 11 | 32 | |
| 12 | 33 | |
| 13 | 34 | def main(): |
| 14 | 삭제: OUTPUT.mkdir(exist_ok=True) | |
| 35 | 추가: work = work_directory() | |
| 36 | 추가: output = work / "screens" / str(time.time_ns()) | |
| 37 | 추가: output.mkdir(mode=0o700, parents=True) | |
| 15 | 38 | display = subprocess.Popen( |
| 16 | 39 | ["Xvfb", "-displayfd", "1", "-screen", "0", "1280x900x24", "-nolisten", "tcp"], |
| 17 | 40 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True, |
| @@ -25,9 +48,9 @@ def main(): | ||
| 25 | 48 | raise RuntimeError("Xvfb display 응답 오류") |
| 26 | 49 | env = {**os.environ, "DISPLAY": ":" + number, "WINIT_UNIX_BACKEND": "x11"} |
| 27 | 50 | env.pop("WAYLAND_DISPLAY", None) |
| 28 | 삭제: with (OUTPUT / "app.stdout").open("wb") as stdout, (OUTPUT / "app.stderr").open("wb") as stderr: | |
| 51 | 추가: with (output / "app.stdout").open("wb") as stdout, (output / "app.stderr").open("wb") as stderr: | |
| 29 | 52 | app = subprocess.Popen( |
| 30 | 삭제: [str(ROOT / "tests/ci/target/debug/zipelo-ui-memory-app"), "--ui-fixture", "/synthetic/example.zip"], | |
| 53 | 추가: [str(binary_path(work)), "--ui-fixture", "/synthetic/example.zip"], | |
| 31 | 54 | env=env, stdout=stdout, stderr=stderr, start_new_session=True, |
| 32 | 55 | ) |
| 33 | 56 | deadline = time.monotonic() + 30 |
| @@ -41,9 +64,9 @@ def main(): | ||
| 41 | 64 | raise RuntimeError("소유 창 표시 시간 초과") |
| 42 | 65 | time.sleep(0.1) |
| 43 | 66 | time.sleep(1) |
| 44 | 삭제: subprocess.run(["import", "-window", "root", str(OUTPUT / "list.png")], env=env, timeout=10, check=True) | |
| 67 | 추가: subprocess.run(["import", "-window", "root", str(output / "list.png")], env=env, timeout=10, check=True) | |
| 45 | 68 | subprocess.run(["xdotool", "search", "--pid", str(app.pid), "--name", "Zipelo"], env=env, timeout=10, check=True) |
| 46 | 삭제: print(str(OUTPUT / "list.png")) | |
| 69 | 추가: print(str(output / "list.png")) | |
| 47 | 70 | finally: |
| 48 | 71 | for process in [app, display]: |
| 49 | 72 | if process is not None: |