OpenSkopos

Conformance cases

These files, together with the JSON Schema in schema/artifact/0.2.json, define the correct behavior for format 0.2. If an implementation in any language passes all cases, it is correct. Section 13 of the specification gives the cases that each type of tool must pass.

Layout

conformance/
  valid/                 Documents that every checker must accept
    index.json
  invalid/               Documents that every checker must reject
    index.json
  markdown/
    index.json
    round-trip/<case>/   A document and the same document in Markdown
    generous/<case>/     A hand-written Markdown file and the document that a reader makes from it
    next-version/<case>/ A stored version, an edited Markdown file and what the tool stores
    invalid/<case>/      Markdown files that a reader must reject
  history/
    index.json
    <case>/              Documents in any order and the history that a tool reads from them
  merge/
    index.json
    <case>/              Two documents, maybe a base, and the merged document
  runner/                A check of the cases themselves (Rust)

valid/

Each file is a document in JSON or YAML. index.json lists each file with a short description. The files use all twelve item types, all evidence kinds, all constraint modalities, the two parent forms and x- keys.

invalid/

Each file is a document with one fault. index.json lists each file with these keys:

Key Meaning
check schema if the JSON Schema rejects the document. semantic if the document passes the schema, but does not obey a rule that the schema cannot express (specification section 9).
rule A short name for the rule. For a semantic case, it is one of the names in section 9.
reason The reason why the document must fail.

A checker must reject all cases. Its messages can be different from the messages of other checkers.

markdown/

index.json lists the cases of each folder with a description. Section 13 of the specification tells how to compare documents.

Folder Files Test
round-trip/<case>/ document.json, document.md, and inputs/ if the file copies data from other artifacts If you read document.md, the result is document.json. If you write document.json and read it again, the result is document.json.
generous/<case>/ A hand-written file, for example INTENT.md, and expected.json If you read the file, the result is expected.json. The index gives the file name and the number of warnings.
next-version/<case>/ stored.json, edited.md, expected.json If you read edited.md with the stored version, the result is expected.json (specification 10.8).
invalid/<case>/ One Markdown file The reader reports an error. The index gives the file name and the reason.

history/

Each case is a folder with documents and expected.json. Section 8.3 of the specification says how to read a history, and section 13 describes expected.json. A tool that reads histories can use the cases. A checker does not need them.

merge/

Each case is a folder with main.json, other.json, base.json if the documents have a common earlier version, and expected.json, the merged document. Section 8.4 of the specification says how a tool merges, and section 13 says how to compare. A tool that merges documents can use the cases. A checker does not need them.

The runner

The runner in runner/ is a small Rust program. CI uses it on each pull request. It does these checks:

The runner does not read or write Markdown. The reference implementation in crates/ does that work.

The tests of the reference implementation also use the cases in valid/, invalid/ and markdown/. They use them through the library skopos-core and through the skopos command line tool. They also write each document in valid/ as Markdown and read it again. To run them, run cargo test from the root of the repository.

With Rust installed, run the runner from the root of the repository:

cargo run --locked --manifest-path conformance/runner/Cargo.toml

If Rust is not installed, use Docker:

docker run --rm -v "$PWD":/repo -w /repo -e CARGO_TARGET_DIR=/tmp/target rust:1 cargo run --locked --manifest-path conformance/runner/Cargo.toml

Adding a case

  1. Add the file or the folder.
  2. Add an entry to the index.json of its folder.
  3. Run the runner.

Make each invalid case break only one rule, so that a failure points to one cause. Start with a valid document and change one thing.