Skip to content

Commit

Permalink
fix successfull message even on failure bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanasati committed Mar 31, 2024
1 parent a7ae5f3 commit 6b9ebf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions internal/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,22 @@ func textify(results []*PrintableResult, filename string) {
// temporarily turn off colors so that [PrintableResult.String] used non-colored summary
origVal := NO_COLOR
NO_COLOR = true
var ferr error
var f *os.File
defer func() {
NO_COLOR = origVal
absPath, err := filepath.Abs(filename)
if err != nil {
Log("red", "unable to get the absolute path for text file: "+err.Error())
return
} else {
Log("green", "Successfully wrote benchmark summary to `"+absPath+"`.")
if ferr == nil {
Log("green", "Successfully wrote benchmark summary to `"+absPath+"`.")
}
}
}()

f, ferr := os.Create(filename)
f, ferr = os.Create(filename)
if ferr != nil {
Log("red", "Failed to create the file.")
}
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
// NAME is the executable name.
NAME = "atomic"
// VERSION is the executable version.
VERSION = "v0.4.0"
VERSION = "v0.4.2"
)

// NoColor is a global variable that is used to determine whether to enable color output.
Expand Down Expand Up @@ -643,7 +643,6 @@ func main() {
}

filename, err := flags["filename"].GetString()
// todo validate the filename
if err != nil {
internal.Log("red", "Application error: cannot parse flag values.")
return
Expand Down

0 comments on commit 6b9ebf9

Please sign in to comment.