Testing Files Generator
English

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.

FieldWhat it holds
manifest_versionThe 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_atWhen the manifest was written, in UTC.
toolWhat made the files.
tool.nameAlways testing-files-generator.
tool.versionThe version of tfg that made the files.
tool.goThe version of Go tfg was built with, so a hash that changed after an upgrade can be traced to it.
tool.generatorsThe version of the generator of each format the run used, by format. It moves when the bytes a generator writes change.
runThe settings that shaped this run.
run.idAn identifier of this run.
run.seedThe seed of the run. The same seed and the same settings give the same files.
run.commandThe command that started the run, as it was typed.
run.platformWhere the run happened.
run.platform.osThe operating system, such as windows, linux or darwin.
run.platform.archThe processor architecture, such as amd64 or arm64.
run.completefalse 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_hashThe hash of the recipe in its settled shape, so reformatting the recipe keeps it. Present when the run came from a recipe.
run.overridesThe values a flag took over from the recipe, by name. Present when a flag replaced a value of the recipe.
run.overrides.*.from_recipeThe value the recipe gave.
run.overrides.*.from_flagThe value the flag gave, which the run used.
run.presetThe preset the run came from. Present only for a run of a preset.
run.preset.idThe id of the preset.
run.preset.questionThe question the preset answers.
run.preset.parametersEvery setting of the preset as the run used it, the ones you gave and its defaults together.
run.preset.defaultedThe 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.instructionsThe 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.
summaryCounts over the whole run, for a quick check.
summary.file_countHow 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_bytesHow many bytes the run wrote to disk, in all.
summary.materializedHow many files are on disk. Lower than file_count when a name could not be written or a file failed.
summary.by_formatHow many files of each format.
summary.by_expectedHow many files of each outcome.
summary.by_targetHow many files each target made, by target id.
filesOne entry for each file of the run.
files[].idThe handle of the file in this manifest, such as f_0001, numbered across the whole run.
files[].pathWhere the file is, relative to the directory of the manifest. verify and cleanup find the file by this.
files[].nameThe file name, the last part of path.
files[].send_asThe name to give the file to your system under, when the recipe asked for one no disk stores. Present only then.
files[].materializedWhether the file is on disk. A name the system refused is still a test case, and still has its entry.
files[].target_idThe id of the target the file came from.
files[].bytesThe size of the file in bytes.
files[].formatThe format of the file.
files[].fidelityHow faithful the file is to its format. tfg formats says it for each format.
files[].hashesThe hashes of the file.
files[].hashes.sha256The SHA-256 of the file, which verify compares.
files[].seedThe seed this file was made from, which comes from the seed of the run and the id of the target.
files[].generatorThe generator that made the file.
files[].generator.nameThe name of the generator.
files[].generator.versionThe version of the generator.
files[].determinismWhether the same seed gives the same bytes, byte, or only the same size.
files[].propertiesThe settings of the format the file was made with, such as its width and height.
files[].expectedWhat your system should do with the file.
files[].expected.outcomeaccept, reject, sanitize or unspecified.
files[].expected.reasonThe rule in play, from the closed list, such as size_limit.
files[].expected.detailThe expectation in words.
files[].expected.confidencecertain, or policy_dependent when the right reaction depends on how your system is set up.
files[].expected.policy_optionsThe answers an outcome that depends on your system leaves open, for a test that settles it by your own policy.
files[].groupThe group the recipe or the preset gave the file.
files[].purposeWhat the file is and why it is in the set, in words.
files[].label_embeddedWhether the file carries the label that says which run made it.
files[].damageWhat was broken on purpose, in the order it was done. Absent for a file nothing damaged.
files[].damage[].typeThe damage, such as truncate.
files[].damage[].settingsIts settings as the run used them, the defaults included.
files[].damage[].cutWhere a cut fell in the file. Present for truncate.
files[].damage[].cut.inWhat the first byte cut away was part of: content, padding, structure or end.
files[].damage[].cut.content_bytesHow long the content of the whole file was, where that is known.
files[].damage[].cut.content_kept_bytesHow much of the content is still in the file.
files[].notesThings worth knowing about this file, such as a label that did not fit.
files[].notes[].codeA short code for the note, such as cut_in_padding.
files[].notes[].detailThe note in words.
files[].failedtrue for a file the run could not make. The run carries on and ends with exit code 8.
files[].errorWhy 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.