testing: add Testing function

This is new in Go 1.21.
This commit is contained in:
Ayke van Laethem
2023-07-26 13:23:44 +02:00
committed by Ron Evans
parent 215dd3f0be
commit c25dd0a972
4 changed files with 29 additions and 3 deletions
+9
View File
@@ -120,6 +120,15 @@ func Verbose() bool {
return flagVerbose
}
// String constant that is being set when running a test.
var testBinary string
// Testing returns whether the program was compiled as a test, using "tinygo
// test". It returns false when built using "tinygo build", "tinygo flash", etc.
func Testing() bool {
return testBinary == "1"
}
// flushToParent writes c.output to the parent after first writing the header
// with the given format and arguments.
func (c *common) flushToParent(testName, format string, args ...interface{}) {