diff options
Diffstat (limited to 'scripts/test_vendor_libghostty_vt.py')
| -rw-r--r-- | scripts/test_vendor_libghostty_vt.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/test_vendor_libghostty_vt.py b/scripts/test_vendor_libghostty_vt.py new file mode 100644 index 00000000..9a9806b3 --- /dev/null +++ b/scripts/test_vendor_libghostty_vt.py @@ -0,0 +1,50 @@ +from __future__ import annotations + +import io +import tarfile +import tempfile +import unittest +from pathlib import Path + +from scripts.vendor_libghostty_vt import parse_archive_root + + +class VendorLibghosttyVtTests(unittest.TestCase): + def test_parse_archive_root_returns_single_top_level_directory(self) -> None: + with tempfile.TemporaryDirectory() as temp_dir: + archive = Path(temp_dir) / "libghostty-vt.tar.gz" + with tarfile.open(archive, "w:gz") as tar: + data = b"hello" + info = tarfile.TarInfo("libghostty-vt-1.0.0/README.md") + info.size = len(data) + tar.addfile(info, io.BytesIO(data)) + + self.assertEqual(parse_archive_root(archive), "libghostty-vt-1.0.0") + + def test_vendored_tree_contains_required_upstream_files(self) -> None: + root = Path(__file__).resolve().parent.parent / "vendor" / "libghostty-vt" + required = [ + root / "build.zig", + root / "build.zig.zon", + root / "CMakeLists.txt", + root / "dist" / "cmake" / "ghostty-vt-config.cmake.in", + root / "include" / "ghostty" / "vt.h", + root / "include" / "ghostty" / "vt" / "render.h", + root / "src" / "lib_vt.zig", + ] + + missing = [str(path.relative_to(root)) for path in required if not path.exists()] + self.assertEqual(missing, []) + + def test_vendor_metadata_exists_and_points_at_vendored_tree(self) -> None: + project_root = Path(__file__).resolve().parent.parent + metadata = project_root / "vendor" / "libghostty-vt.vendor.json" + self.assertTrue(metadata.exists()) + text = metadata.read_text() + self.assertIn('"source_commit"', text) + self.assertIn('"dist_archive"', text) + self.assertIn('"extracted_dir"', text) + + +if __name__ == "__main__": + unittest.main() |
