| | @@ -11,6 +11,7 @@ ROOT = Path(__file__).resolve().parents[2] |
| 11 | 11 | class IconBuildTests(unittest.TestCase): |
| 12 | 12 | @classmethod |
| 13 | 13 | def setUpClass(cls): |
| 14 | +추가: (ROOT / "tests/work").mkdir(parents=True, exist_ok=True) |
| 14 | 15 | cls.scratch = tempfile.TemporaryDirectory(dir=ROOT / "tests/work") |
| 15 | 16 | cls.addClassCleanup(cls.scratch.cleanup) |
| 16 | 17 | cls.root = Path(cls.scratch.name) |
| | @@ -28,7 +29,7 @@ class IconBuildTests(unittest.TestCase): |
| 28 | 29 | for source, output in ((ROOT / "experiments/rust-ui-memory-app/build.rs", cls.builder), |
| 29 | 30 | (fake, cls.compiler)): |
| 30 | 31 | subprocess.run(["rustc", "+1.99.1", "--edition=2024", str(source), "-o", str(output)], |
| 31 | | -삭제: check=True, capture_output=True, text=True) |
| 32 | +추가: check=True, capture_output=True, text=True, encoding="utf-8") |
| 32 | 33 | |
| 33 | 34 | def setUp(self): |
| 34 | 35 | self.directory = tempfile.TemporaryDirectory(dir=self.root) |
| | @@ -45,15 +46,14 @@ class IconBuildTests(unittest.TestCase): |
| 45 | 46 | return path |
| 46 | 47 | |
| 47 | 48 | def run_build(self, target="msvc", **overrides): |
| 48 | | -삭제: environment = dict(os.environ) |
| 49 | | -삭제: for key in ("RC", "ProgramFiles", "ProgramFiles(x86)", "FAKE_RC_FAIL"): |
| 50 | | -삭제: environment.pop(key, None) |
| 49 | +추가: excluded = {key.casefold() for key in ("RC", "ProgramFiles", "ProgramFiles(x86)", "FAKE_RC_FAIL", "PATH")} |
| 50 | +추가: environment = {key: value for key, value in os.environ.items() if key.casefold() not in excluded} |
| 51 | 51 | environment.update({"CARGO_CFG_TARGET_OS": "windows", "CARGO_CFG_TARGET_ENV": target, |
| 52 | 52 | "CARGO_FEATURE_UI": "1", "OUT_DIR": str(self.output), |
| 53 | 53 | "CARGO_MANIFEST_DIR": str(ROOT / "experiments/rust-ui-memory-app"), |
| 54 | 54 | "ProgramFiles(x86)": str(self.programs), "PATH": ""}) |
| 55 | 55 | environment.update(overrides) |
| 56 | | -삭제: return subprocess.run([str(self.builder)], env=environment, capture_output=True, text=True) |
| 56 | +추가: return subprocess.run([str(self.builder)], env=environment, capture_output=True, text=True, encoding="utf-8") |
| 57 | 57 | |
| 58 | 58 | def test_sdk_uses_highest_numeric_version_with_x64_compiler(self): |
| 59 | 59 | self.sdk("10.0.9.0") |
| | @@ -62,13 +62,13 @@ class IconBuildTests(unittest.TestCase): |
| 62 | 62 | result = self.run_build() |
| 63 | 63 | self.assertEqual(result.returncode, 0, result.stderr) |
| 64 | 64 | self.assertIn("cargo:rustc-link-arg-bin=", result.stdout) |
| 65 | | -삭제: self.assertEqual((self.output / "zipelo.res").read_text(), str(latest)) |
| 65 | +추가: self.assertTrue(Path((self.output / "zipelo.res").read_text()).samefile(latest)) |
| 66 | 66 | |
| 67 | 67 | def test_explicit_rc_overrides_sdk(self): |
| 68 | 68 | self.sdk("10.0.99.0") |
| 69 | 69 | result = self.run_build(RC=str(self.compiler)) |
| 70 | 70 | self.assertEqual(result.returncode, 0, result.stderr) |
| 71 | | -삭제: self.assertEqual((self.output / "zipelo.res").read_text(), str(self.compiler)) |
| 71 | +추가: self.assertTrue(Path((self.output / "zipelo.res").read_text()).samefile(self.compiler)) |
| 72 | 72 | |
| 73 | 73 | def test_path_compiler_remains_available_without_sdk(self): |
| 74 | 74 | path = self.work / "bin/rc.exe" |
| | @@ -76,7 +76,7 @@ class IconBuildTests(unittest.TestCase): |
| 76 | 76 | shutil.copy2(self.compiler, path) |
| 77 | 77 | result = self.run_build(PATH=str(path.parent)) |
| 78 | 78 | self.assertEqual(result.returncode, 0, result.stderr) |
| 79 | | -삭제: self.assertEqual((self.output / "zipelo.res").read_text(), str(path)) |
| 79 | +추가: self.assertTrue(Path((self.output / "zipelo.res").read_text()).samefile(path)) |
| 80 | 80 | |
| 81 | 81 | def test_missing_msvc_compiler_warns_without_linking(self): |
| 82 | 82 | result = self.run_build() |