diff options
author | Ayke van Laethem <[email protected]> | 2021-05-06 18:54:59 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-05-06 20:04:16 +0200 |
commit | 78acbdf0d99f40dd7abe20f822739ca6aadf7304 (patch) | |
tree | 99b8ee93833dfd1bfa7d95a33a30e393d307db97 /loader | |
parent | 617e2791efa4ad5231b24a257bc1e822732a15c6 (diff) | |
download | tinygo-78acbdf0d99f40dd7abe20f822739ca6aadf7304.tar.gz tinygo-78acbdf0d99f40dd7abe20f822739ca6aadf7304.zip |
main: match `go test` output
This commit makes the output of `tinygo test` similar to that of `go
test`. It changes the following things in the process:
* Running multiple tests in a single command is now possible. They
aren't paralellized yet.
* Packages with no test files won't crash TinyGo, instead it logs it
in the same way the Go toolchain does.
Diffstat (limited to 'loader')
-rw-r--r-- | loader/errors.go | 10 | ||||
-rw-r--r-- | loader/loader.go | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/loader/errors.go b/loader/errors.go index 5c1a2b9d7..5aaf6cba6 100644 --- a/loader/errors.go +++ b/loader/errors.go @@ -23,3 +23,13 @@ type Error struct { func (e Error) Error() string { return e.Err.Error() } + +// Error returned when loading a *Program for a test binary but no test files +// are present. +type NoTestFilesError struct { + ImportPath string +} + +func (e NoTestFilesError) Error() string { + return "no test files" +} diff --git a/loader/loader.go b/loader/loader.go index 4672f4067..27d5ea76e 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -210,6 +210,12 @@ func Load(config *compileopts.Config, inputPkgs []string, clangHeaders string, t p.Packages[pkg.ImportPath] = pkg } + if config.TestConfig.CompileTestBinary && !strings.HasSuffix(p.sorted[len(p.sorted)-1].ImportPath, ".test") { + // Trying to compile a test binary but there are no test files in this + // package. + return p, NoTestFilesError{p.sorted[len(p.sorted)-1].ImportPath} + } + return p, nil } |