conformance

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package conformance runs the official OpenJD conformance test suite (https://github.com/OpenJobDescription/openjd-specifications) against sqi's internal/openjd implementation.

The suite is supplied by a pinned git submodule under third_party/ rather than vendored, because it is licensed CC BY-ND 4.0: verbatim redistribution is permitted but modified copies are not, and this repo's mandatory SPDX header would make every vendored fixture a derivative work.

File layout

Only suite_test.go and chunkingjobs_test.go, which read the real fixture tree, carry the `conformance` build tag, because only they need the submodule present. Everything else is untagged, so the harness's own unit tests run under `make test` and count toward coverage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffBaseline

func DiffBaseline(results []Result, baseline map[string]struct{}) (regressions, stale, orphaned []string)

DiffBaseline compares results against the baseline in three directions.

regressions are live tests that failed but are not in the baseline. stale are live tests that are in the baseline but passed. orphaned are baseline entries that match no live result: the fixture is missing from results (upstream deleted or renamed it), or it is not StateLive (for example a base/env_templates fixture, which Classify marks StateNotApplicable). The regression and stale checks look only at live results, so without the orphan check such an entry would never be flagged.

Checking all three directions keeps the baseline from becoming a permanent ignore-list: an entry for a passing test or for no live test must be removed.

Not-applicable results are neither pass nor fail and are skipped for regressions and stale. All three slices are sorted for stable output.

func ExtensionFor

func ExtensionFor(path string) string

ExtensionFor returns the extension directory a fixture belongs to, given its path relative to the suite root: "base", "EXPR", "TASK_CHUNKING", and so on.

The layout is <extension>/<kind>/<file>.yaml, so the extension is the grandparent directory.

func FormatRollup

func FormatRollup(groups []Group) string

FormatRollup renders groups as an aligned human-readable table.

Not-applicable counts are reported in their own column and never as a pass ratio, so an unimplemented extension or unimplemented document kind (such as env_templates) cannot look like a passing one. Regressions are reported as "REGRESSION" ahead of the baselined count, so they cannot be mistaken for known, accepted failures.

func IsFixtureFile

func IsFixtureFile(name string) bool

IsFixtureFile reports whether a directory entry's base name is a conformance fixture the walker should collect.

A ".yaml" suffix alone is not enough: AppleDouble companions keep the extension (see fsutil.IsAppleDouble), and no fixture in the suite begins with a dot, so leading-dot names are excluded, which also covers ".DS_Store" and other OS metadata.

func KindFor

func KindFor(path string) string

KindFor returns the template kind a fixture belongs to, given its path relative to the suite root: "job_templates" or "env_templates".

The layout is <extension>/<kind>/<file>.yaml, so the kind is the parent directory.

func LoadBaseline

func LoadBaseline(path string) (map[string]struct{}, error)

LoadBaseline reads a baseline file: one known-failing test ID per line. Blank lines are ignored, and everything from a '#' to end of line is a comment. A missing file yields an empty baseline, not an error.

Types

type Group

type Group struct {
	// Name is "<extension>/<kind>", e.g. "base/job_templates".
	Name string
	// Passed counts live tests that passed.
	Passed int
	// Baselined and Regressed split the live failures: a failure listed in the
	// baseline has been adjudicated, while one that is not is a regression.
	// Both count toward the live total.
	Baselined, Regressed int
	// NotApplicable counts tests for extensions sqi has not registered, or for
	// a document kind sqi does not implement (env_templates). These are never
	// counted in Passed; see StateNotApplicable.
	NotApplicable int
}

Group is the per-directory tally reported at the end of a run.

func Rollup

func Rollup(results []Result, baseline map[string]struct{}) []Group

Rollup tallies results per "<extension>/<kind>" directory, sorted by name.

The baseline is needed to tell a baselined failure from a regression. It classifies through DiffBaseline, so these counts always agree with the REGRESSION lines a caller prints from the same diff.

type Result

type Result struct {
	// Case is the fixture that was run.
	Case TestCase
	// State is whether this result counts toward the score.
	State State
	// Accepted reports whether sqi accepted the template (parsed and validated
	// with no errors).
	Accepted bool
	// Passed reports whether the outcome matched the fixture's expectation.
	// Always false when State is StateNotApplicable.
	Passed bool
	// Reason describes the outcome, including the validation error when the
	// template was rejected. Empty when a live fixture passed.
	Reason string
}

Result is the outcome of running one conformance fixture.

func RunCase

func RunCase(tc TestCase, state State, data []byte) Result

RunCase parses and validates one template fixture and scores it against the expectation encoded in its filename.

A fixture whose name lacks ".invalid" must be accepted; one carrying it must be rejected. Malformed YAML counts as a rejection: the suite's contract is accept-versus-reject, and it does not distinguish a parse failure from a validation failure.

Limits are enforced, because the suite tests the limits the specification defines.

When state is StateNotApplicable the fixture is not scored: Passed is false regardless of outcome. See the StateNotApplicable doc comment.

func (Result) ID

func (r Result) ID() string

ID returns the fixture's stable identifier — its path relative to the suite root. This is what the baseline file lists.

type State

type State int

State is whether a fixture's result counts toward the score.

const (
	// StateLive means sqi implements the fixture's extension (or it is a base
	// spec fixture) and the document kind the fixture exercises, so pass/fail
	// is a meaningful signal.
	StateLive State = iota
	// StateNotApplicable means either the fixture's extension is not in sqi's
	// registry, or the fixture is a document kind sqi does not implement
	// (standalone "environment-2023-09" templates, env_templates). Its result
	// is reported separately and never counted as a pass.
	//
	// This prevents two kinds of false pass:
	//
	//  1. sqi rejects templates declaring an unregistered extension, so every
	//     ".invalid" fixture for such an extension is rejected for the wrong
	//     reason and would score as a pass.
	//  2. sqi rejects every env_templates fixture on "/specificationVersion:
	//     unsupported version", regardless of the fixture's own defect, so a
	//     ".invalid" env_templates fixture would score as a pass the same way.
	//     base/env_templates alone has 24 such fixtures.
	StateNotApplicable
)

func Classify

func Classify(extension, kind string) State

Classify reports whether fixtures for the given extension directory and template kind ("job_templates" or "env_templates") should be scored.

kind is checked first: sqi does not implement standalone environment-2023-09 templates, so every env_templates fixture, whatever its extension, is not applicable. Otherwise "base" is always live, and any other extension is live only when it is in internal/openjd's extension registry and marked openjd.StatusSupported. A registered extension that is in progress is not live: validateExtensions rejects every such template on its status, so scoring its fixtures would report a false failure for every valid one and a false pass for every ".invalid" one.

func (State) String

func (s State) String() string

type TestCase

type TestCase struct {
	// Path is the fixture's path relative to the 2023-09 suite root.
	Path string
	// Section is the spec section under test ("1.1", "expr2.2.4"), or "" when
	// the filename carries no section prefix.
	Section string
	// Description is the human-readable remainder of the filename.
	Description string
	// Invalid reports whether the implementation is expected to reject this
	// fixture (filename carries ".invalid").
	Invalid bool
	// IsJobTest reports whether this is a job-execution test (".test"), which
	// requires a live session runtime and is out of scope for template
	// validation.
	IsJobTest bool
}

TestCase is one conformance fixture, described by its filename.

The naming convention is <spec-section>--<description>[.invalid][.test].yaml. The section prefix is optional: some extension fixtures (for example TASK_CHUNKING/jobs/contiguous-even.test.yaml) carry no "--" separator.

func ParseTestCase

func ParseTestCase(path string) TestCase

ParseTestCase derives a TestCase from a fixture path relative to the suite root. It never fails: an unrecognized filename yields a TestCase with an empty Section and the whole stem as Description, which the caller reports like any other test rather than silently dropping.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL