Updates for coverage

This commit is contained in:
Arthur Barr
2017-12-18 15:38:05 +00:00
parent b6b72952e4
commit b938a5eb95
4 changed files with 56 additions and 20 deletions

View File

@@ -25,6 +25,8 @@ import (
var test *bool
const filename = "/var/coverage/exitCode"
func init() {
test = flag.Bool("test", false, "Set to true when running tests for coverage")
}
@@ -38,8 +40,11 @@ func TestSystem(t *testing.T) {
}()
osExit = func(rc int) {
// Write the exit code to a file instead
log.Printf("Writing exit code %v to file", strconv.Itoa(rc))
ioutil.WriteFile("/var/coverage/exitCode", []byte(strconv.Itoa(rc)), 0644)
log.Printf("Writing exit code %v to file %v", strconv.Itoa(rc), filename)
err := ioutil.WriteFile(filename, []byte(strconv.Itoa(rc)), 0644)
if err != nil {
log.Print(err)
}
}
main()
}