| | @@ -24,6 +24,27 @@ class RunnerTests(unittest.TestCase): |
| 24 | 24 | run_rust.work_directory(run_rust.ROOT, name) |
| 25 | 25 | self.assertEqual(run_rust.work_directory(run_rust.ROOT, os.environ["ZIPELO_CI_JOB"]), TEST_WORK) |
| 26 | 26 | |
| 27 | +추가: def test_work_directory_rejects_symlinked_parents_before_creation(self): |
| 28 | +추가: for link_name in ("tests", "tests/work"): |
| 29 | +추가: with self.subTest(link_name=link_name), tempfile.TemporaryDirectory( |
| 30 | +추가: dir=TEST_WORK |
| 31 | +추가: ) as directory: |
| 32 | +추가: base = Path(directory) |
| 33 | +추가: project = base / "project" |
| 34 | +추가: project.mkdir() |
| 35 | +추가: outside = base / "outside" |
| 36 | +추가: outside.mkdir() |
| 37 | +추가: link = project / link_name |
| 38 | +추가: link.parent.mkdir(parents=True, exist_ok=True) |
| 39 | +추가: link.symlink_to(outside, target_is_directory=True) |
| 40 | +추가: with patch.object( |
| 41 | +추가: run_rust.subprocess, "check_output", return_value=str(project / ".git") |
| 42 | +추가: ): |
| 43 | +추가: with self.assertRaisesRegex(ValueError, "안전한 작업 디렉터리"): |
| 44 | +추가: run_rust.work_directory(project, "task") |
| 45 | +추가: self.assertFalse((outside / "task").exists()) |
| 46 | +추가: self.assertFalse((outside / "work").exists()) |
| 47 | +추가: |
| 27 | 48 | def test_output_paths_reject_symlinks_outside_job(self): |
| 28 | 49 | with tempfile.TemporaryDirectory(dir=TEST_WORK) as directory: |
| 29 | 50 | work = Path(directory) |
| | @@ -189,6 +210,28 @@ class RunnerTests(unittest.TestCase): |
| 189 | 210 | str(binaries / "x86_64-w64-mingw32-gcc-posix"), |
| 190 | 211 | ) |
| 191 | 212 | |
| 213 | +추가: @unittest.skipUnless(sys.platform == "linux", "Linux MinGW 실행 파일 탐색 시험임") |
| 214 | +추가: def test_default_checkout_reuses_existing_setup_tools(self): |
| 215 | +추가: with tempfile.TemporaryDirectory(dir=TEST_WORK) as directory: |
| 216 | +추가: root = Path(directory) |
| 217 | +추가: tools = root / "tests/ci/tools" |
| 218 | +추가: binaries = tools / "mingw/usr/bin" |
| 219 | +추가: binaries.mkdir(parents=True) |
| 220 | +추가: executable = binaries / "x86_64-w64-mingw32-gcc-posix" |
| 221 | +추가: executable.write_text("#!/bin/sh\nexit 0\n") |
| 222 | +추가: executable.chmod(0o700) |
| 223 | +추가: rustup = tools / "rustup" |
| 224 | +추가: (rustup / "toolchains/1.99.1-x86_64-unknown-linux-gnu").mkdir(parents=True) |
| 225 | +추가: with ( |
| 226 | +추가: patch.dict(run_rust.os.environ, {"PATH": ""}, clear=True), |
| 227 | +추가: patch.object(run_rust.subprocess, "check_output", return_value=str(root / ".git")), |
| 228 | +추가: ): |
| 229 | +추가: run_rust.prepare_tools(root) |
| 230 | +추가: self.assertEqual(run_rust.os.environ["RUSTUP_HOME"], str(rustup)) |
| 231 | +추가: self.assertTrue(run_rust.os.environ["PATH"].startswith(str(binaries))) |
| 232 | +추가: self.assertEqual(run_rust.shutil.which("x86_64-w64-mingw32-gcc-posix"), |
| 233 | +추가: str(executable)) |
| 234 | +추가: |
| 192 | 235 | def test_local_bootstraps_missing_cross_tools_and_reloads_paths(self): |
| 193 | 236 | for root in (Path("/repo"), PurePosixPath("/repo"), PureWindowsPath("C:/repo")): |
| 194 | 237 | with self.subTest(root=root): |