Files
troupe-standup/wizard-work/ledger/test_scratch_manifest.py
T

26 lines
1011 B
Python

#!/usr/bin/env python3
"""Isolated scratch test of gen_manifest.py."""
import os
import sys
# make scratch dirs
os.makedirs("/tmp/scratch_wiz", exist_ok=True)
open("/tmp/scratch_wiz/a.txt", "w").write("hello")
open("/tmp/scratch_wiz/b.sh", "w").write("#!/bin/bash\necho hi\n")
open("/tmp/scratch_wiz/beam/CHECK", "w").write("#!/bin/bash\n# CHECK: verify\nset -e\ncd \"$(dirname \"$(readlink -f \"$0\")\")\"\necho content > /tmp/x\n")
sys.path.insert(0, "/root/troupe-standup/wizard-work/ledger")
import importlib.util
spec = importlib.util.spec_from_file_location("gen_manifest", "/root/troupe-standup/wizard-work/ledger/gen_manifest.py")
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
m.ROOT = "/tmp/scratch_wiz"
m.OUT = "/tmp/scratch_wiz_out"
m.build()
print("--- scratch manifest ---")
with open("/tmp/scratch_wiz_out/wizardwork-file-manifest.tsv") as f:
print(f.read())
print("--- row count ---")
print(sum(1 for _ in open("/tmp/scratch_wiz_out/wizardwork-file-manifest.tsv")))