devtesting

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 6 Imported by: 1 module, 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 devtesting is the fake test controller of the debug builds (SPEC §15.2, step 26.2): "dev.testing.fake" reads a script of tests and results from the folder and plays it as a test run, so that the Test Explorer can be shown, in a proof or by hand, without a language's test tool. A release build never has it (cmd/emetos adds it only where dev commands are enabled).

Index

Constants

View Source
const (
	// ID is the id of the extension and ControllerID that of the controller it makes.
	ID           = "dev.testing"
	ControllerID = "dev.testing.fake"
	// ScriptFile is the file of the folder the controller reads, by its path relative to the folder.
	ScriptFile = "fake-tests.json"
)

The names of the extension.

Variables

This section is empty.

Functions

func New

func New() extension.Extension

New makes the extension. It is a factory of extension.Factory.

Types

type Branch

type Branch struct {
	Hits   int    `json:"hits"`
	Label  string `json:"label,omitempty"`
	Line   int    `json:"line,omitempty"`
	Col    int    `json:"col,omitempty"`
	EndCol int    `json:"endCol,omitempty"`
}

Branch is a branch of a statement and how many times it ran; Line and its columns, when given, are where it is (otherwise it has no place of its own, which the editor shows at the end of its statement).

type Declaration

type Declaration struct {
	Name    string `json:"name"`
	Line    int    `json:"line"`
	EndLine int    `json:"endLine,omitempty"`
	Hits    int    `json:"hits"`
}

Declaration is a function of a file: its name, the lines it covers (counted from 1) and how many times it ran.

type FileCoverage

type FileCoverage struct {
	File         string        `json:"file"`
	Statements   []Statement   `json:"statements,omitempty"`
	Declarations []Declaration `json:"declarations,omitempty"`
}

FileCoverage is the coverage a run with coverage reports for a file of the folder (by its path relative to the folder). The counts of the file are worked out from the details.

type Frame

type Frame struct {
	Label string `json:"label"`
	File  string `json:"file,omitempty"`
	Line  int    `json:"line,omitempty"`
}

Frame is a line of the stack trace of a failure: a function, and the file (by its path relative to the folder) and line (counted from 1) it was at.

type Script

type Script struct {
	// Label is the name of the controller; "Fake Tests (dev)" when empty.
	Label string `json:"label"`
	// DelayMs is how long a test runs before it reports, 150 when 0.
	DelayMs int `json:"delayMs"`
	// Tests are the top items.
	Tests []Test `json:"tests"`
	// Coverage is what a run with coverage reports: the files with their statements, branches and declarations (step 26.4).
	Coverage []FileCoverage `json:"coverage,omitempty"`
}

Script is the file ScriptFile: the tests, and what a run of each does.

type Statement

type Statement struct {
	Line     int      `json:"line"`
	EndLine  int      `json:"endLine,omitempty"`
	Col      int      `json:"col,omitempty"`
	EndCol   int      `json:"endCol,omitempty"`
	Hits     int      `json:"hits"`
	Branches []Branch `json:"branches,omitempty"`
}

Statement is a statement of a file: the lines it covers (counted from 1; EndLine 0 is Line) and how many times it ran. Col and EndCol are the columns (counted from 1) it starts and ends at; both 0 give the whole line.

type Test

type Test struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	// Result and Ms are the result and the duration a run reports; Message is the message of a failure.
	Result  string  `json:"result,omitempty"`
	Ms      float64 `json:"ms,omitempty"`
	Message string  `json:"message,omitempty"`
	// Expected and Actual are shown as a diff with a failure.
	Expected string `json:"expected,omitempty"`
	Actual   string `json:"actual,omitempty"`
	// FailLine is the line (counted from 1) of the file of the test that the message of a failure is at; 0 gives the message no place of its
	// own. Stack are the frames of the failure and Output is the text the test prints, with ANSI sequences.
	FailLine int     `json:"failLine,omitempty"`
	Stack    []Frame `json:"stack,omitempty"`
	Output   string  `json:"output,omitempty"`
	// File is the file of the test, by its path relative to the folder; Line and EndLine are the lines it covers (counted from 1) when it has a
	// file. A test with no file has no place in an editor.
	File     string `json:"file,omitempty"`
	Line     int    `json:"line,omitempty"`
	EndLine  int    `json:"endLine,omitempty"`
	Children []Test `json:"children,omitempty"`
}

Test is an item and the result a run gives it: Result is "passed", "failed", "errored" or "skipped" (a test with children has none).

Jump to

Keyboard shortcuts

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