Manifest
Every run writes manifest.json beside its files. It lists every file with its size, its
SHA-256 and what your system should do with it, so a test reads the expectation instead of hard
coding it. It is written even when a run is stopped part way.
What a manifest looks like
This is the manifest of tfg generate --format png --size 2mb --out ./out, shortened:
{
"manifest_version": "1.0",
"tool": { "name": "testing-files-generator", "version": "0.6.0-rc1" },
"run": {
"id": "run_b359aa8d94",
"seed": 0,
"command": "tfg generate --format png --size 2mb --out ./out",
"platform": { "os": "windows", "arch": "amd64" },
"complete": true
},
"summary": {
"file_count": 1,
"total_bytes": 2097152,
"by_format": { "png": 1 },
"by_expected": { "unspecified": 1 }
},
"files": [
{
"path": "files_0001.png",
"bytes": 2097152,
"format": "png",
"fidelity": "full",
"determinism": "byte",
"seed": "8dc2d18c",
"hashes": { "sha256": "1a1f7c..." },
"properties": { "width": 640, "height": 480 },
"expected": {
"outcome": "unspecified",
"detail": "No expectation was declared for this file.",
"confidence": "policy_dependent"
}
}
]
}
How a test reads it
Go through files, give each file to your system, and compare what it did with
expected.outcome. When send_as is there, give the file under that name. A
sketch in Python, with your own upload in place of upload:
import json, pathlib
folder = pathlib.Path("fixtures")
manifest = json.loads((folder / "manifest.json").read_text(encoding="utf-8"))
for f in manifest["files"]:
if f["expected"]["outcome"] == "unspecified":
continue
result = upload(folder / f["path"], name=f.get("send_as", f["name"]))
assert result == f["expected"]["outcome"], f["path"]
The packages for pytest and Node do this for you: Test frameworks.
An outcome of unspecified means the right reaction depends on how your system is set up.
policy_options lists the answers left open, for a test that settles them by your policy.
Every field
Every field a manifest can carry, read from the program when this page is built. []
stands for each entry of a list, and * for each key of an object whose keys are yours,
such as the names of the flags in run.overrides. A field marked as present only in some
runs is left out of the others rather than written empty.
| Field | What it holds |
|---|---|
manifest_version | The version of the manifest format, 1.0. New fields are added without changing it, so a reader ignores the fields it does not know. |
generated_at | When the manifest was written, in UTC. |
tool | What made the files. |
tool.name | Always testing-files-generator. |
tool.version | The version of tfg that made the files. |
tool.go | The version of Go tfg was built with, so a hash that changed after an upgrade can be traced to it. |
tool.generators | The version of the generator of each format the run used, by format. It moves when the bytes a generator writes change. |
run | The settings that shaped this run. |
run.id | An identifier of this run. |
run.seed | The seed of the run. The same seed and the same settings give the same files. |
run.command | The command that started the run, as it was typed. |
run.platform | Where the run happened. |
run.platform.os | The operating system, such as windows, linux or darwin. |
run.platform.arch | The processor architecture, such as amd64 or arm64. |
run.complete | false when the run stopped early, for example after Ctrl+C. The manifest is written even then, so cleanup can remove what was made. |
run.recipe_hash | The hash of the recipe in its settled shape, so reformatting the recipe keeps it. Present when the run came from a recipe. |
run.overrides | The values a flag took over from the recipe, by name. Present when a flag replaced a value of the recipe. |
run.overrides.*.from_recipe | The value the recipe gave. |
run.overrides.*.from_flag | The value the flag gave, which the run used. |
run.preset | The preset the run came from. Present only for a run of a preset. |
run.preset.id | The id of the preset. |
run.preset.question | The question the preset answers. |
run.preset.parameters | Every setting of the preset as the run used it, the ones you gave and its defaults together. |
run.preset.defaulted | The settings you did not give, which took the default of the preset. A limit that came from a default is not the limit of your system. |
run.instructions | The name of the file written beside the manifest that says in words what each file is and why it is in the set. Present when a file has a purpose. |
summary | Counts over the whole run, for a quick check. |
summary.file_count | How many entries the manifest has. A run stopped part way lists only the files it finished or that failed, so it can be lower than the files that were planned. |
summary.total_bytes | How many bytes the run wrote to disk, in all. |
summary.materialized | How many files are on disk. Lower than file_count when a name could not be written or a file failed. |
summary.by_format | How many files of each format. |
summary.by_expected | How many files of each outcome. |
summary.by_target | How many files each target made, by target id. |
files | One entry for each file of the run. |
files[].id | The handle of the file in this manifest, such as f_0001, numbered across the whole run. |
files[].path | Where the file is, relative to the directory of the manifest. verify and cleanup find the file by this. |
files[].name | The file name, the last part of path. |
files[].send_as | The name to give the file to your system under, when the recipe asked for one no disk stores. Present only then. |
files[].materialized | Whether the file is on disk. A name the system refused is still a test case, and still has its entry. |
files[].target_id | The id of the target the file came from. |
files[].bytes | The size of the file in bytes. |
files[].format | The format of the file. |
files[].fidelity | How faithful the file is to its format. tfg formats says it for each format. |
files[].hashes | The hashes of the file. |
files[].hashes.sha256 | The SHA-256 of the file, which verify compares. |
files[].seed | The seed this file was made from, which comes from the seed of the run and the id of the target. |
files[].generator | The generator that made the file. |
files[].generator.name | The name of the generator. |
files[].generator.version | The version of the generator. |
files[].determinism | Whether the same seed gives the same bytes, byte, or only the same size. |
files[].properties | The settings of the format the file was made with, such as its width and height. |
files[].expected | What your system should do with the file. |
files[].expected.outcome | accept, reject, sanitize or unspecified. |
files[].expected.reason | The rule in play, from the closed list, such as size_limit. |
files[].expected.detail | The expectation in words. |
files[].expected.confidence | certain, or policy_dependent when the right reaction depends on how your system is set up. |
files[].expected.policy_options | The answers an outcome that depends on your system leaves open, for a test that settles it by your own policy. |
files[].group | The group the recipe or the preset gave the file. |
files[].purpose | What the file is and why it is in the set, in words. |
files[].label_embedded | Whether the file carries the label that says which run made it. |
files[].damage | What was broken on purpose, in the order it was done. Absent for a file nothing damaged. |
files[].damage[].type | The damage, such as truncate. |
files[].damage[].settings | Its settings as the run used them, the defaults included. |
files[].damage[].cut | Where a cut fell in the file. Present for truncate. |
files[].damage[].cut.in | What the first byte cut away was part of: content, padding, structure or end. |
files[].damage[].cut.content_bytes | How long the content of the whole file was, where that is known. |
files[].damage[].cut.content_kept_bytes | How much of the content is still in the file. |
files[].notes | Things worth knowing about this file, such as a label that did not fit. |
files[].notes[].code | A short code for the note, such as cut_in_padding. |
files[].notes[].detail | The note in words. |
files[].failed | true for a file the run could not make. The run carries on and ends with exit code 8. |
files[].error | Why the file could not be made. |
What else is written beside it
When the files of a run have a purpose, from a preset or from purpose in a recipe, a
second file is written beside the manifest, manifest.instructions.md. It says in words
what each file is and why it is in the set, for the person running the test by hand.
verify and cleanup know about it.
tfg verify manifest.json checks that every file is still there and still has its SHA-256.
tfg cleanup manifest.json --yes removes exactly the files the manifest lists, and
nothing else, so it is safe in a folder that holds other things too.
Can I rely on the format?
Yes. manifest_version is 1.0, and the format grows only by adding fields.
A field never changes its meaning within a version, so a reader written today keeps working if it
ignores the fields it does not know.