Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/fleet/repo-universe/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,14 @@ def main(argv: list[str] | None = None) -> int:
# build time — the census row was the only sign).
user_repos = fetch_live("user/repos?per_page=100&affiliation=owner")
else:
# Both captures are required offline: a missing one would
# silently regenerate with that source emptied, deleting its
# GitHub-only repos from the artifact.
# All three captures are required offline: a missing one
# would silently regenerate with that source emptied,
# deleting its GitHub-only repos from the artifact.
missing = [
flag
for flag, value in (
("--org-json", args.org_json),
("--forks-org-json", args.forks_org_json),
("--user-json", args.user_json),
)
if not value
Expand Down
45 changes: 31 additions & 14 deletions scripts/fleet/repo-universe/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,44 @@ def fake_run(cmd, **kwargs):
self.assertIn("developing-today-forks/some-tool", out)
self.assertIn("developing-today-forks/opencode", out)

def run_gen_omitting(self, *omit: str) -> subprocess.CompletedProcess:
captures = {
"--org-json": "org.json",
"--forks-org-json": "forks-org.json",
"--user-json": "user.json",
}
argv = [sys.executable, str(GENERATE)]
for flag, filename in captures.items():
if flag not in omit:
argv += [flag, str(self.dir / filename)]
argv += [
"--census",
str(self.dir / "census.md"),
"--output",
str(self.out),
]
return subprocess.run(argv, capture_output=True, text=True)

def test_offline_mode_requires_both_captures(self) -> None:
# Omitting a capture without --live must fail, not silently
# regenerate with that source emptied (deleting every
# GitHub-only repo from the omitted source).
proc = subprocess.run(
[
sys.executable,
str(GENERATE),
"--org-json",
str(self.dir / "org.json"),
"--census",
str(self.dir / "census.md"),
"--output",
str(self.out),
],
capture_output=True,
text=True,
)
proc = self.run_gen_omitting("--forks-org-json", "--user-json")
self.assertNotEqual(proc.returncode, 0)
self.assertFalse(self.out.exists())

def test_offline_mode_requires_each_capture_singly(self) -> None:
# Each capture omitted on its own must fail, name the missing
# flag, and write no output (#6612: omitting only
# --forks-org-json used to exit 0 with the whole forks org
# silently dropped from the artifact).
for flag in ("--org-json", "--forks-org-json", "--user-json"):
with self.subTest(flag=flag):
proc = self.run_gen_omitting(flag)
self.assertNotEqual(proc.returncode, 0)
self.assertIn(flag, proc.stderr)
self.assertFalse(self.out.exists())

def test_idempotent_zero_diff_on_unchanged_inputs(self) -> None:
first = self.run_gen()
second = self.run_gen()
Expand Down
Loading