lang

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package lang runs the native tests of the implementations (spec 09.9).

Each language has a recipe. A recipe copies the files of one implementation to a new temporary directory, writes the build files that the language needs, and runs the test command there. The recipe does not change the content tree.

The tests run code from the content repository. Run them only in a sandbox, such as a CI runner or a container. The CLI asks for -unsafe-local outside CI.

Index

Constants

View Source
const JUnitVersion = "1.13.4"

JUnitVersion is the version of the JUnit console launcher for Java and Kotlin.

Variables

View Source
var (
	// HelloTimeout is the longest time that an adapter can take to start. The JVM and .NET start slowly.
	HelloTimeout = 60 * time.Second
	// CaseTimeout is the longest time of one shared case.
	CaseTimeout = 10 * time.Second
)
View Source
var Recipes = map[string]Recipe{
	"python":     {ID: "python", Tools: []string{"python3"}, Version: []string{"python3", "--version"}, Run: python},
	"go":         {ID: "go", Tools: []string{"go"}, Version: []string{"go", "version"}, Run: golang},
	"rust":       {ID: "rust", Tools: []string{"cargo"}, Version: []string{"rustc", "--version"}, Run: rust},
	"c":          {ID: "c", Tools: []string{"cc"}, Version: []string{"cc", "--version"}, Run: clang},
	"cpp":        {ID: "cpp", Tools: []string{"c++"}, Version: []string{"c++", "--version"}, Run: cpp},
	"javascript": {ID: "javascript", Tools: []string{"node"}, Version: []string{"node", "--version"}, Run: javascript},
	"typescript": {ID: "typescript", Tools: []string{"node"}, Version: []string{"node", "--version"}, Run: typescript},
	"java":       {ID: "java", Tools: []string{"javac", "java"}, Version: []string{"javac", "-version"}, Run: java},
	"kotlin":     {ID: "kotlin", Tools: []string{"kotlinc", "java"}, Version: []string{"kotlinc", "-version"}, Run: kotlin},
	"csharp":     {ID: "csharp", Tools: []string{"dotnet"}, Version: []string{"dotnet", "--version"}, Run: csharp},
}

Recipes are the tier 1 languages (spec 08.2).

View Source
var Timeout = 3 * time.Minute

Timeout is the longest time that the tests of one implementation can take.

Functions

This section is empty.

Types

type Recipe

type Recipe struct {
	ID string
	// Tools are the commands that the recipe needs. If one is missing, the language is skipped.
	Tools []string
	// Version prints the version of the toolchain.
	Version []string
	// Run prepares dir, which holds a copy of the files, and returns the commands to run in it.
	Run func(r *Runner, dir string, n *node.Node, im node.Impl) ([][]string, error)
}

Recipe runs the tests of one language.

func (Recipe) Available

func (rc Recipe) Available() error

Available tells if the tools of a recipe are installed.

func (Recipe) ToolVersion

func (rc Recipe) ToolVersion() string

ToolVersion returns the first line of the version output of the toolchain.

type Runner

type Runner struct {
	// Cache holds the downloaded jars. The default is the user cache directory.
	Cache string
	// Log gets one line for each implementation.
	Log func(format string, args ...any)
	// Keep keeps the temporary directories, for debugging.
	Keep bool
}

Runner runs tests and keeps the results.

func (*Runner) Shared added in v0.1.2

func (r *Runner) Shared(n *node.Node, im node.Impl, k *contract.Contract, cases []contract.Case) status.Shared

Shared runs the shared cases of the contract k on one implementation (spec 09.2). It builds the adapter in a new temporary directory, starts it once and sends the cases in order. A crash fails the case, and the next case gets a new adapter.

func (*Runner) Test

func (r *Runner) Test(n *node.Node, im node.Impl) status.Test

Test runs the native tests of one implementation.

type Skip

type Skip struct{ Lang, Tool string }

Skip is the error of a language whose tools are missing.

func (Skip) Error

func (s Skip) Error() string

Jump to

Keyboard shortcuts

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