diff options
author | Anthony Fok <foka@debian.org> | 2015-02-17 03:35:23 -0700 |
---|---|---|
committer | Anthony Fok <foka@debian.org> | 2015-02-17 03:35:23 -0700 |
commit | 82a0888995dc9745a9e1c68a4f9d68a7f448c000 (patch) | |
tree | 8c4b3773b9d64c7c920c064fb4818c5ccf7ae270 /utils/utils.go | |
parent | c2e29138728ffbae19b4b0a3e59503c47dd986a5 (diff) |
Revert "Expansion of unit tests for utils/utils.go"
Rationale: Test failing on Windows with errors like this:
utils_test.go:177: Error: Could not remove file "f".
Error: remove C:\Users\appveyor\AppData\Local\Temp\utils_test_747965610:
The process cannot access the file because it is being used by another
process.
This reverts commit 6b28e38cea0dec3e3f045ab8ec833608b91a946f.
Sorry for my premature merge of Pull Request #818.
Diffstat (limited to 'utils/utils.go')
-rw-r--r-- | utils/utils.go | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/utils/utils.go b/utils/utils.go index 381ebc53e..eaa6c09a9 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -22,39 +22,36 @@ func CheckErr(err error, s ...string) { func StopOnErr(err error, s ...string) { if err != nil { - doStopOnErr(err, s...) - os.Exit(-1) - } -} + if len(s) == 0 { + newMessage := cutUsageMessage(err.Error()) -func doStopOnErr(err error, s ...string) { - if len(s) == 0 { - newMessage := cutUsageMessage(err.Error()) - // Printing an empty string results in a error with - // no message, no bueno. - if newMessage != "" { - jww.CRITICAL.Println(newMessage) - } - } else { - for _, message := range s { - message := cutUsageMessage(message) + // Printing an empty string results in a error with + // no message, no bueno. + if newMessage != "" { + jww.CRITICAL.Println(newMessage) + } + } else { + for _, message := range s { + message := cutUsageMessage(message) - if message != "" { - jww.CRITICAL.Println(message) + if message != "" { + jww.CRITICAL.Println(message) + } } } + os.Exit(-1) } } // cutUsageMessage splits the incoming string on the beginning of the usage // message text. Anything in the first element of the returned slice, trimmed -// of its Unicode defined spaces, should be returned. The 2nd element of the +// of its Unicode defined spaces, should be returned. The 2nd element of the // slice will have the usage message that we wish to elide. // // This is done because Cobra already prints Hugo's usage message; not eliding -// would result in the usage output being printed twice, which leads to bug +// would result in the usage output being printed twice, which leads to bug // reports, more specifically: https://github.com/spf13/hugo/issues/374 func cutUsageMessage(s string) string { - pieces := strings.Split(s, "Usage of") + pieces := strings.Split(s, "Usage of") return strings.TrimSpace(pieces[0]) } |