| | @@ -2,6 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | import importlib.util |
| 4 | 4 | import os |
| 5 | +추가: import re |
| 5 | 6 | from pathlib import Path |
| 6 | 7 | import subprocess |
| 7 | 8 | import tempfile |
| | @@ -14,9 +15,16 @@ SMOKE = importlib.util.module_from_spec(SPEC) |
| 14 | 15 | SPEC.loader.exec_module(SMOKE) |
| 15 | 16 | |
| 16 | 17 | |
| 18 | +추가: def test_work_root(): |
| 19 | +추가: job = os.environ.get("ZIPELO_CI_JOB", "rust-local") |
| 20 | +추가: if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]{0,63}", job): |
| 21 | +추가: raise ValueError("안전한 작업명이 필요함") |
| 22 | +추가: return SMOKE.work_root() / job / "tmp" |
| 23 | +추가: |
| 24 | +추가: |
| 17 | 25 | class LifecycleTests(unittest.TestCase): |
| 18 | 26 | def setUp(self): |
| 19 | | -삭제: work = Path(os.environ.get("TMPDIR", SMOKE.work_root() / "ubuntu-lifecycle")) |
| 27 | +추가: work = test_work_root() |
| 20 | 28 | work.mkdir(parents=True, exist_ok=True) |
| 21 | 29 | temporary = tempfile.TemporaryDirectory(dir=work) |
| 22 | 30 | self.addCleanup(temporary.cleanup) |
| | @@ -29,6 +37,14 @@ class LifecycleTests(unittest.TestCase): |
| 29 | 37 | settings.start() |
| 30 | 38 | self.addCleanup(settings.stop) |
| 31 | 39 | |
| 40 | +추가: def test_default_work_path_uses_common_job_directory(self): |
| 41 | +추가: with patch.dict(os.environ, {"ZIPELO_CI_JOB": "lifecycle-regression"}): |
| 42 | +추가: os.environ.pop("TMPDIR", None) |
| 43 | +추가: os.environ.pop("ZIPELO_TEST_WORK_DIR", None) |
| 44 | +추가: self.assertEqual( |
| 45 | +추가: test_work_root(), SMOKE.work_root() / "lifecycle-regression/tmp" |
| 46 | +추가: ) |
| 47 | +추가: |
| 32 | 48 | def test_only_first_configuration_sets_defaults(self): |
| 33 | 49 | commands = self.directory / "bin" |
| 34 | 50 | commands.mkdir() |