docs: compare scraper output in the repo tmp/

This commit is contained in:
Abdessamad Derraz committed 2026-10-21 10:01:07 +02:00
1 parent e257504e20
commit 0b772fe255
2 files changed
+33 -3

No files matched your search

+27
View File
@@ -600,5 +600,32 @@ class CiTriggersPointToTheirLists(unittest.TestCase):
self.assertIn(f"`{named.rstrip('*')}`", section)
class ScratchFilesGoToRepoTmp(unittest.TestCase):
"""adding-a-scraper.md wrote its comparison to /tmp while two other
pages say /tmp is a RAM disk and send scratch files to the repo's tmp/."""
@staticmethod
def _code_lines(text: str) -> list[str]:
lines, inside = [], False
for line in text.splitlines():
if line.strip().startswith("```"):
inside = not inside
elif inside:
lines.append(line)
return lines
def test_no_command_writes_to_slash_tmp(self):
offenders = [
f"{page.name}: {line.strip()}"
for page in PUBLISHED
for line in self._code_lines(page.read_text(encoding="utf-8"))
if re.search(r"(?<![\w.])/tmp/", line)
]
self.assertEqual(offenders, [])
old = " ```bash\n python x.py --output /tmp/test.yml\n ```\n"
self.assertEqual(self._code_lines(old), [" python x.py --output /tmp/test.yml"])
self.assertIn("tmp/", (ROOT / ".gitignore").read_text(encoding="utf-8").splitlines())
if __name__ == "__main__":
unittest.main()
+6 -3
View File
@@ -396,11 +396,14 @@ manipulation rather than load-dump to maintain human-readable formatting.
python -m scripts.scraper.myplatform_scraper --json | python -m json.tool | head -50
```
3. **Compare with existing YAML** if updating a scraper:
3. **Compare with existing YAML** if updating a scraper. The output goes to the
repository's `tmp/`, listed in `.gitignore`, because `/tmp` is a RAM disk on
many systems:
```bash
python -m scripts.scraper.myplatform_scraper --output /tmp/test.yml
diff platforms/myplatform.yml /tmp/test.yml
mkdir -p tmp
python -m scripts.scraper.myplatform_scraper --output tmp/test.yml
diff platforms/myplatform.yml tmp/test.yml
```
4. **Run verification** after generating: