Documentation ¶
Index ¶
- Constants
- Variables
- func FindNodes[T ast.Node](root ast.Node) []T
- func GetTestC(ts *testscript.TestScript) *qt.C
- func ParseTxtar(s string) *txtar.Archive
- func TestScriptSetupFunc(env *testscript.Env) error
- func UpdateArchiveFile(ts *testscript.TestScript, sourceDir string, filename string, content string)
- func WriteTxtar(c *qt.C, a *txtar.Archive) (dir string)
- type Context
- type PackageList
Constants ¶
const EnvRepoDirOverride = "ENCORE_REPO_DIR"
EnvRepoDirOverride is the name of the environment variable to override the resolution of the path to this repository. It exists because we have some tests that run in a temporary directory (such as when using testscript in process execution mode, like compiler/build/build_test.go), in which case the normal approach of invoking `git rev-parse --show-toplevel` doesn't work.
Variables ¶
var ( EncoreRepoDir = repoDir() RuntimeDir = filepath.Join(EncoreRepoDir, "runtimes") )
var ResourceDeepEquals = qt.CmpEquals( cmp.AllowUnexported(option.Option[*pkginfo.File]{}), )
ResourceDeepEquals is a quicktest comparator for resource.Resource and resource.Bind that forces the comparison to include unexported fields
Functions ¶
func GetTestC ¶
func GetTestC(ts *testscript.TestScript) *qt.C
GetTestC returns the *qt.C for the current testscript test.
This should only be called from within a testscript test which has had TestScriptSetupFunc called during the TestScript.Setup function.
func ParseTxtar ¶
func TestScriptSetupFunc ¶
func TestScriptSetupFunc(env *testscript.Env) error
TestScriptSetupFunc is a testscript setup function which sets up the testscript environment for testing with testutil.
func UpdateArchiveFile ¶
func UpdateArchiveFile(ts *testscript.TestScript, sourceDir string, filename string, content string)
Types ¶
type Context ¶
func NewContext ¶
NewContext constructs a new Context for testing. It defaults the build info to the host system.
func NewContextForTestScript ¶
func NewContextForTestScript(ts *testscript.TestScript, parseTests bool) *Context
NewContextForTestScript constructs a new Context for testing when using testscript
Your testscript test should call this TestScriptSetupFunc in the TestScript.Setup function.
func (*Context) DeferExpectError ¶
DeferExpectError is a defer function that expects errors to be present. Each argument is matched with the corresponding error. If the number of errors differs from the number of matches the test fails.
func (*Context) FailTestOnBailout ¶
func (c *Context) FailTestOnBailout()
FailTestOnBailout is a defer function that fails the test if a bailout was triggered. It must be called as "defer c.FailTestOnBailout()".
func (*Context) FailTestOnErrors ¶
func (c *Context) FailTestOnErrors()
FailTestOnErrors is function that fails the test if an errors are encountered when running fn.
func (*Context) GoModDownload ¶
func (c *Context) GoModDownload()
GoModDownload runs "go mod download all" on the main module.
type PackageList ¶
A PackageList is a list of packages that knows how to collect itself, by passing (*PackageList).Collector() to the scan.ProcessModule function. It's primarily a helper function for testing purposes.
func (*PackageList) Collector ¶
func (l *PackageList) Collector() func(pkg *pkginfo.Package)