|
1 | 1 | #! /usr/bin/env python3 |
2 | 2 | from pathlib import Path |
| 3 | +from urllib.parse import urljoin |
3 | 4 | import argparse |
4 | | -import errno |
5 | 5 | import json |
6 | 6 | import os |
7 | 7 | import random |
|
30 | 30 |
|
31 | 31 | ROOT_DIR = Path(__file__).parent.parent |
32 | 32 | SUITE_ROOT_DIR = ROOT_DIR / "tests" |
| 33 | + |
33 | 34 | REMOTES_DIR = ROOT_DIR / "remotes" |
| 35 | +REMOTES_BASE_URL = "http://localhost:1234/" |
34 | 36 |
|
35 | 37 | TESTSUITE_SCHEMA = json.loads((ROOT_DIR / "test-schema.json").read_text()) |
36 | 38 |
|
@@ -68,6 +70,16 @@ def collect(root_dir): |
68 | 70 | return root_dir.glob("**/*.json") |
69 | 71 |
|
70 | 72 |
|
| 73 | +def url_for_path(path): |
| 74 | + """ |
| 75 | + Return the assumed remote URL for a file in the remotes/ directory. |
| 76 | +
|
| 77 | + Tests in the refRemote.json file reference this URL, and assume the |
| 78 | + corresponding contents are available at the URL. |
| 79 | + """ |
| 80 | + return urljoin(REMOTES_BASE_URL, str(path.relative_to(REMOTES_DIR))) |
| 81 | + |
| 82 | + |
71 | 83 | class SanityTests(unittest.TestCase): |
72 | 84 | @classmethod |
73 | 85 | def setUpClass(cls): |
@@ -243,10 +255,10 @@ def main(arguments): |
243 | 255 |
|
244 | 256 | json.dump(selected_cases, sys.stdout, indent=4, sort_keys=True) |
245 | 257 | elif arguments.command == "remotes": |
246 | | - remotes = {} |
247 | | - for path in collect(REMOTES_DIR): |
248 | | - relative_path = os.path.relpath(path, REMOTES_DIR) |
249 | | - remotes[relative_path] = json.loads(path.read_text()) |
| 258 | + remotes = { |
| 259 | + url_for_path(path): json.loads(path.read_text()) |
| 260 | + for path in collect(REMOTES_DIR) |
| 261 | + } |
250 | 262 | json.dump(remotes, sys.stdout, indent=4, sort_keys=True) |
251 | 263 | elif arguments.command == "dump_remotes": |
252 | 264 | if arguments.update: |
|
0 commit comments