qt3

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package qt3 runs the W3C QT3 (FOTS) test suite against this engine.

The suite is not vendored: it is ~78MB and belongs to the W3C. Point GOXSLT_QT3 at a checkout of https://github.com/w3c/qt3tests and the tests in this package run; without it they skip. That keeps `go test ./...` fast and dependency-free for everyone else while making the conformance run reproducible for anyone who wants it.

Index

Constants

View Source
const CaseTimeout = 10 * time.Second

CaseTimeout bounds a single test case. It is generous: the point is to contain a non-terminating expression, not to measure performance.

Variables

View Source
var SuiteClock = time.Date(2024, 1, 15, 9, 30, 0, 0, time.FixedZone("", -5*3600))

SuiteClock is the fixed value fn:current-dateTime returns during a run. It carries a non-UTC offset because a UTC-only clock would let a timezone bug pass unnoticed.

Functions

func SuiteRoot

func SuiteRoot() string

SuiteRoot returns the checkout directory, or "" when the suite is absent.

Types

type Assertion

type Assertion struct {
	// Kind is the element name: "assert-eq", "all-of", "error", and so on.
	Kind string
	// Value is the character data, which for most kinds is the expected value.
	Value string
	// Code is the @code of an <error>, and @type of an assert-type.
	Code string
	// File is the @file of an assert-xml whose expected value is held in a
	// separate document rather than inline. Without it the comparison ran
	// against an empty string, which reported every such case as a mismatch
	// against "".
	File string
	// Children are the operands of all-of / any-of / not.
	Children []Assertion
}

Assertion is one node of the result tree.

func ParseAssert

func ParseAssert(raw []byte) (Assertion, error)

ParseAssert parses the raw result XML into an assertion tree.

type Catalog

type Catalog struct {
	XMLName      xml.Name      `xml:"catalog"`
	TestSets     []TestSetRef  `xml:"test-set"`
	Environments []Environment `xml:"environment"`
}

Catalog is the top-level catalog.xml.

func LoadCatalog

func LoadCatalog(root string) (*Catalog, error)

LoadCatalog reads catalog.xml from the suite root.

type Collation

type Collation struct {
	URI     string `xml:"uri,attr"`
	Default string `xml:"default,attr"`
}

type Collection

type Collection struct {
	URI     string   `xml:"uri,attr"`
	Sources []Source `xml:"source"`
}

Collection is a named set of documents an environment supplies to fn:collection.

The sources carry the same role/file/uri attributes as a context source, but role is unused: membership in the collection is the point, not the name it is bound to.

type DecimalFormatDecl added in v1.1.0

type DecimalFormatDecl struct {
	// Name is the lexical QName the declaration carries. Its prefix may be
	// declared on the decimal-format element itself, so the namespace it
	// binds to is recovered from Attrs rather than from the environment.
	Name              string     `xml:"name,attr"`
	Attrs             []xml.Attr `xml:",any,attr"`
	DecimalSeparator  string     `xml:"decimal-separator,attr"`
	GroupingSeparator string     `xml:"grouping-separator,attr"`
	Percent           string     `xml:"percent,attr"`
	PerMille          string     `xml:"per-mille,attr"`
	ZeroDigit         string     `xml:"zero-digit,attr"`
	Digit             string     `xml:"digit,attr"`
	PatternSeparator  string     `xml:"pattern-separator,attr"`
	MinusSign         string     `xml:"minus-sign,attr"`
	Infinity          string     `xml:"infinity,attr"`
	NaN               string     `xml:"NaN,attr"`
	ExponentSeparator string     `xml:"exponent-separator,attr"`
}

DecimalFormatDecl is one <decimal-format> declaration. Every attribute is optional and defaults to the standard symbol, so each is a pointer-free string tested for emptiness rather than a value with its own default.

type Dependency

type Dependency struct {
	Type      string `xml:"type,attr"`
	Value     string `xml:"value,attr"`
	Satisfied string `xml:"satisfied,attr"`
}

type Environment

type Environment struct {
	Name       string      `xml:"name,attr"`
	Ref        string      `xml:"ref,attr"`
	Sources    []Source    `xml:"source"`
	Params     []Param     `xml:"param"`
	Namespaces []Namespace `xml:"namespace"`
	Schemas    []Schema    `xml:"schema"`
	// Collations and a declared default collation appear on a few
	// environments; a test needing a non-codepoint one is unsupported here.
	Collations []Collation `xml:"collation"`
	// StaticBaseURI supplies the base URI of the expression itself, which is
	// what fn:static-base-uri returns and what fn:resolve-uri resolves
	// against.
	StaticBaseURI []StaticBaseURI `xml:"static-base-uri"`
	// Collections are the document sets fn:collection returns.
	Collections []Collection `xml:"collection"`
	// Resources are the non-XML files fn:unparsed-text reads, mapping the URI
	// a case names to the file in the checkout that holds it.
	Resources []Resource `xml:"resource"`
	// DecimalFormats are the decimal formats fn:format-number reads. Only the
	// unnamed (default) one is used by these cases.
	DecimalFormats []DecimalFormatDecl `xml:"decimal-format"`
}

type Namespace

type Namespace struct {
	Prefix string `xml:"prefix,attr"`
	URI    string `xml:"uri,attr"`
}

type Outcome

type Outcome int

Outcome is what happened to one test case.

const (
	Pass Outcome = iota
	Fail
	// Skip covers a test this engine is not in scope for — an XQuery-only
	// construct, a 3.0/3.1 feature, or a schema-aware environment. A skip is
	// not a pass and is reported separately, because counting them as passes
	// is how a conformance number becomes meaningless.
	Skip
)

type Param

type Param struct {
	Name   string `xml:"name,attr"`
	Select string `xml:"select,attr"`
	As     string `xml:"as,attr"`
}

type Report

type Report struct {
	Set, Case string
	Outcome   Outcome
	Reason    string
	// Expr is the expression the case evaluated. A failure line naming only
	// the case means opening the catalog to find out what it ran; carrying it
	// here makes the report reproducible by hand.
	Expr string
}

Report is the result of one case.

type Resource added in v1.1.0

type Resource struct {
	File      string `xml:"file,attr"`
	URI       string `xml:"uri,attr"`
	MediaType string `xml:"media-type,attr"`
	Encoding  string `xml:"encoding,attr"`
}

Resource is one <resource> declaration: a file in the checkout published under the URI a test case uses to reach it.

type Result

type Result struct {
	Raw []byte `xml:",innerxml"`
}

Result is the assertion tree, kept as raw XML and parsed by ParseAssert.

The nesting is arbitrary — all-of and any-of contain further assertions to any depth — and struct tags cannot express that, so it is walked with the token stream instead.

type Runner

type Runner struct {
	Root string
	// Target is the language version the run is scoped to. The zero value is
	// XPath20, so an existing caller that does not set it keeps the 2.0 run
	// it had before.
	Target TargetVersion
	// contains filtered or unexported fields
}

Runner executes cases from a suite checkout.

func NewRunner

func NewRunner(root string, cat *Catalog) *Runner

func (*Runner) Run

func (r *Runner) Run(ts *TestSet, tc *TestCase) (rep Report)

Run executes one case.

A panic in the engine is recorded as a failure rather than allowed to abort the run: a crash is the most severe kind of conformance failure, and losing the other 28,000 results to it would hide everything behind the first one.

type Schema

type Schema struct {
	URI  string `xml:"uri,attr"`
	File string `xml:"file,attr"`
}

type Source

type Source struct {
	Role string `xml:"role,attr"`
	File string `xml:"file,attr"`
	URI  string `xml:"uri,attr"`
}

type StaticBaseURI

type StaticBaseURI struct {
	URI string `xml:"uri,attr"`
}

type TargetVersion added in v1.1.0

type TargetVersion int

TargetVersion selects the language version the run is scoped to.

The suite is FOTS 3.1 and every case declares the versions it applies to, so which cases are in scope is a property of the run rather than of the engine. Scoping to 2.0 and to 3.0 are two measurements of the same suite, and both are reported: the 2.0 figure must not move as 3.0 is implemented, which is what makes it a regression check rather than just a headline.

const (
	// XPath20 scopes the run to cases that apply to XPath 2.0.
	XPath20 TargetVersion = iota
	// XPath30 scopes the run to cases that apply to XPath 2.0 or 3.0.
	XPath30
	// XPath31 scopes the run to cases that apply to 2.0, 3.0 or 3.1.
	XPath31
)

func (TargetVersion) String added in v1.1.0

func (v TargetVersion) String() string

type TestCase

type TestCase struct {
	Name         string        `xml:"name,attr"`
	Description  string        `xml:"description"`
	Environments []Environment `xml:"environment"`
	Dependencies []Dependency  `xml:"dependency"`
	Test         string        `xml:"test"`
	Modules      []struct {
		URI  string `xml:"uri,attr"`
		File string `xml:"file,attr"`
	} `xml:"module"`
	Result Result `xml:"result"`
}

type TestSet

type TestSet struct {
	XMLName      xml.Name      `xml:"test-set"`
	Name         string        `xml:"name,attr"`
	Environments []Environment `xml:"environment"`
	Dependencies []Dependency  `xml:"dependency"`
	Cases        []TestCase    `xml:"test-case"`

	// Dir is the test-set file's directory, relative to the suite root.
	//
	// Source paths are relative to the test-set file, not to the root:
	// fn/collection.xml names "../docs/bib.xml". Joining those against the
	// root walks above it and the file is not found, so the directory has to
	// travel with the parsed set.
	Dir string `xml:"-"`
}

TestSet is one test-set file, e.g. fn/abs.xml.

func LoadTestSet

func LoadTestSet(root, file string) (*TestSet, error)

LoadTestSet reads one test-set file named relative to the suite root.

type TestSetRef

type TestSetRef struct {
	Name string `xml:"name,attr"`
	File string `xml:"file,attr"`
}

Jump to

Keyboard shortcuts

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