| ... | @@ -271,6 +271,7 @@ class MirrorTests(unittest.TestCase): | ... | @@ -271,6 +271,7 @@ class MirrorTests(unittest.TestCase): |
| 271 | self.assertEqual(self.cache.root.stat().st_mtime_ns, stamp) | 271 | self.assertEqual(self.cache.root.stat().st_mtime_ns, stamp) |
| 272 | self.assertFalse(list(self.cache.root.rglob('.download-*'))) | 272 | self.assertFalse(list(self.cache.root.rglob('.download-*'))) |
| 273 | self.assertIn('Signature for '+name, (artifact.parent/'preadme.md').read_text()) | 273 | self.assertIn('Signature for '+name, (artifact.parent/'preadme.md').read_text()) |
| | 274 | self.assertIn('[All development builds](/mirrors/zig/0.18.0/dev/)', (artifact.parent/'preadme.md').read_text()) |
| 274 | self.assertIn('this release only has [development builds]', (artifact.parent.parent.parent/'preadme.md').read_text()) | 275 | self.assertIn('this release only has [development builds]', (artifact.parent.parent.parent/'preadme.md').read_text()) |
| 275 | | 276 | |
| 276 | @unittest.skipUnless(ctypes.util.find_library('sodium'), 'libsodium required') | 277 | @unittest.skipUnless(ctypes.util.find_library('sodium'), 'libsodium required') |
| ... | @@ -381,8 +382,8 @@ class MirrorTests(unittest.TestCase): | ... | @@ -381,8 +382,8 @@ class MirrorTests(unittest.TestCase): |
| 381 | self.assertNotIn(f'[{labels[key]}]({url})', text) | 382 | self.assertNotIn(f'[{labels[key]}]({url})', text) |
| 382 | else: | 383 | else: |
| 383 | self.assertIn(f'- [{labels[key]}]({url})', text) | 384 | self.assertIn(f'- [{labels[key]}]({url})', text) |
| 384 | self.assertLess(text.index(url), text.index('[Development builds]')) | 385 | self.assertLess(text.index(url), text.index('<div ')) |
| 385 | self.assertLess(text.index('[Development builds]'), text.index('<div ')) | 386 | self.assertNotIn('[Development builds]', text) |
| 386 | with patch.object(mirror, 'index', return_value={'0.19.0': {'notes': 'https://example.org/notes', 'docs': None, 'stdDocs': 'https://ziglang.org/bad)link'}}): | 387 | with patch.object(mirror, 'index', return_value={'0.19.0': {'notes': 'https://example.org/notes', 'docs': None, 'stdDocs': 'https://ziglang.org/bad)link'}}): |
| 387 | text = mirror.version_readme('0.19.0', [artifact]).decode() | 388 | text = mirror.version_readme('0.19.0', [artifact]).decode() |
| 388 | for label in labels.values(): | 389 | for label in labels.values(): |
| ... | @@ -393,17 +394,26 @@ class MirrorTests(unittest.TestCase): | ... | @@ -393,17 +394,26 @@ class MirrorTests(unittest.TestCase): |
| 393 | artifact = self.cache.path('zig-x86_64-linux-0.17.0.tar.xz') | 394 | artifact = self.cache.path('zig-x86_64-linux-0.17.0.tar.xz') |
| 394 | artifact.parent.mkdir() | 395 | artifact.parent.mkdir() |
| 395 | artifact.write_bytes(b'already verified archive') | 396 | artifact.write_bytes(b'already verified archive') |
| | 397 | (artifact.parent / 'dev').mkdir() |
| 396 | stamp = mirror.stable_time('0.17.0') | 398 | stamp = mirror.stable_time('0.17.0') |
| 397 | for path in [artifact, artifact.parent, self.cache.root]: | 399 | for path in [artifact, artifact.parent, self.cache.root]: |
| 398 | mirror.set_mtime(path, stamp) | 400 | mirror.set_mtime(path, stamp) |
| 399 | self.cache.write_readmes(artifact.parent) | 401 | release = {'date': '2026-10-01', 'docs': 'https://ziglang.org/documentation/0.17.0/', |
| | 402 | 'src': {'tarball': mirror.upstream(artifact.name), 'shasum': 'unused-cached-hash'}} |
| | 403 | with patch.object(mirror, 'index', return_value={'0.17.0': release}): |
| | 404 | self.cache.write_readmes(artifact.parent) |
| 400 | mirror.set_mtime(artifact.parent, stamp) | 405 | mirror.set_mtime(artifact.parent, stamp) |
| 401 | readme = artifact.parent / 'preadme.md' | 406 | readme = artifact.parent / 'preadme.md' |
| | 407 | custom = readme.read_text().replace('| Architecture |', '| Target |') + '\nCustom table notes.\n' |
| | 408 | readme.write_text(custom.replace('<div ', '[Development builds](/mirrors/zig/0.17.0/dev/)\n\n<div ', 1)) |
| | 409 | with patch.object(mirror, 'index', return_value={'0.17.0': release}): |
| | 410 | change = self.cache.directory_readme(artifact.parent) |
| | 411 | self.assertEqual(mirror.base64.b64decode(change['previous']), readme.read_bytes()) |
| 402 | original = {path: path.stat().st_mtime_ns for path in [artifact, artifact.parent, self.cache.root, readme]} | 412 | original = {path: path.stat().st_mtime_ns for path in [artifact, artifact.parent, self.cache.root, readme]} |
| 403 | release = {'date': '2026-10-01', 'docs': 'https://ziglang.org/documentation/0.17.0/', | | |
| 404 | 'src': {'tarball': mirror.upstream(artifact.name), 'shasum': 'unused-cached-hash'}} | | |
| 405 | with patch.object(mirror, 'index', return_value={'0.17.0': release, 'master': {}}) as metadata, patch.object(mirror, 'fetch', side_effect=AssertionError('cached refresh must not redownload')): | 413 | with patch.object(mirror, 'index', return_value={'0.17.0': release, 'master': {}}) as metadata, patch.object(mirror, 'fetch', side_effect=AssertionError('cached refresh must not redownload')): |
| 406 | self.cache.refresh() | 414 | self.cache.refresh() |
| | 415 | self.assertNotIn('[Development builds]', readme.read_text()) |
| | 416 | self.assertEqual(readme.read_text(), custom) |
| 407 | self.assertIn('[Language Reference](' + release['docs'] + ')', readme.read_text()) | 417 | self.assertIn('[Language Reference](' + release['docs'] + ')', readme.read_text()) |
| 408 | self.assertIsNone(self.cache.directory_readme(artifact.parent)) | 418 | self.assertIsNone(self.cache.directory_readme(artifact.parent)) |
| 409 | metadata.assert_any_call(refresh=True) | 419 | metadata.assert_any_call(refresh=True) |