# ARJ fixtures (tools/fixtures.py): archives made by the open-source ARJ 3.10 (nixpkgs#arj, run as a tool) with methods # -m0 (stored) and -m1 .. -m4, recursing into a directory tree (-r), with an archive comment; the reference data is # what `arj x` extracts again. # tests/gen/arj.luau { cases = { { name, data, entries = { { name, size, crc } } } } } import importlib.util, os, zlib _s = importlib.util.spec_from_file_location("_arch2", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_arch2.py")) A = importlib.util.module_from_spec(_s) _s.loader.exec_module(A) INPUTS = ["tools/fixtures/_arch2.py"] def generate(ctx): rng = ctx.rng(31) tmp = A.tmpdir() try: work = os.path.join(tmp, "w") A.tree(A.FILES + [("dir/sub/text.txt", b"the quick brown fox jumps over the lazy dog\n" * 400), ("dir/rand.bin", rng.randbytes(40000)), ("dir/runs.bin", b"\0" * 30000 + b"\xff" * 7000)], work) names = [n for n, _ in A.FILES] + ["dir"] cases = [] for m in ("0", "1", "2", "3", "4"): arc = os.path.join(tmp, "m%s.arj" % m) A.tool(["arj"], ["arj", "a", "-m" + m, "-r", "-y", arc] + names, cwd=work) out = os.path.join(tmp, "x" + m) os.makedirs(out) A.tool(["arj"], ["arj", "x", "-y", arc], cwd=out) ents = [{"name": n, "size": os.path.getsize(os.path.join(out, n)), "crc": c} for n, c in A.read_tree(out).items()] cases.append({"name": "arj -m" + m, "data": open(arc, "rb").read(), "entries": ents}) ctx.emit("arj", {"cases": cases}) finally: A.rmtree(tmp)