Documentation
¶
Overview ¶
Package testing provides functions to run gx tests.
Index ¶
- Constants
- func BuildCompileOptions(rtm *api.Runtime, pkg *ir.Package) ([]options.PackageOption, error)
- func CheckSource(errs *fmterr.Errors, node ir.Node)
- func CompareToExpectedErrors(pkg *ir.Package, err error) (bool, error)
- func FetchArray[T dtype.GoDataType](t *testing.T, array types.Array[T]) []T
- func FetchAtom[T dtype.GoDataType](t *testing.T, atom types.Atom[T]) T
- func FindTests(pkg *ir.Package) ([]*ir.FuncDecl, error)
- func NewBuilderStaticSource(stdlibImpl *impl.Stdlib) *builder.Builder
- func NumberLines(s string) string
- func RunAll(t *testing.T, rtm *api.Runtime, pkg *ir.Package, err error) (numTests int)
- func Validate(node ir.Node, visitors ...Visitor) error
- type Runner
- type Session
- type UnitSession
- type Visitor
Constants ¶
const WantPrefix = "Want:"
WantPrefix is the prefix in the comment indicating the result of a test.
Variables ¶
This section is empty.
Functions ¶
func BuildCompileOptions ¶
BuildCompileOptions from the source code of the package.
func CheckSource ¶
CheckSource checks that Source and File return non-nil values.
func CompareToExpectedErrors ¶
CompareToExpectedErrors removes errors declared in the source code using: ERROR <sub string to search in the error message> from a set of errors and returns the remaining errors if any.
First, all expected errors are collected from the comments. Second, these errors are compared to the errors generated by the compiler. If some errors have been generated by the compiler and are not expected, an error is returned. If some errors are expected in the comments and have not been generated by the compiler, an error is returned.
func FetchArray ¶
FetchArray fetches an array from a device.
func NewBuilderStaticSource ¶
NewBuilderStaticSource returns a builder using the embedpkg importer which embeds GX testing source files into their corresponding Go package.
func NumberLines ¶
NumberLines returns a string where lines are prefixed by their number.
Types ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner runs test functions.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a test session to a set of tests given a filesystem, a builder, and a backend.
func NewSession ¶
NewSession returns a new testing session given a runtime.
type UnitSession ¶
type UnitSession struct {
// contains filtered or unexported fields
}
UnitSession is a test session that reads files from a file system and, for each file:
- Create a new builder.
- Read and compile the file as its own package. The package name needs to match the file name.
- Run the tests present in the file.
This is different to a Session where all packages will be built using the same builder.
func NewUnitSession ¶
NewUnitSession returns a new testing session given a runtime.
func (*UnitSession) TestFolder ¶
func (s *UnitSession) TestFolder(t *testing.T, path string)
TestFolder run the tests in a folder.