cmd/sharefs: check option parsing behaviour
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / ShareFS (push) Successful in 39s
Test / Sandbox (push) Successful in 47s
Test / Sandbox (race detector) (push) Successful in 46s
Test / Hakurei (race detector) (push) Successful in 54s
Test / Hpkg (push) Successful in 50s
Test / Hakurei (push) Successful in 55s
Test / Flake checks (push) Successful in 1m35s
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / ShareFS (push) Successful in 39s
Test / Sandbox (push) Successful in 47s
Test / Sandbox (race detector) (push) Successful in 46s
Test / Hakurei (race detector) (push) Successful in 54s
Test / Hpkg (push) Successful in 50s
Test / Hakurei (push) Successful in 55s
Test / Flake checks (push) Successful in 1m35s
This change makes it possible to check parseOpts behaviour as part of Go tests. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -3,23 +3,14 @@ package main
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
// executableName is the [path.Base] name of the executable that started the current process.
|
||||
var executableName = func() string {
|
||||
if len(os.Args) > 0 {
|
||||
return path.Base(os.Args[0])
|
||||
} else if name, err := os.Executable(); err != nil {
|
||||
return "sharefs"
|
||||
} else {
|
||||
return path.Base(name)
|
||||
}
|
||||
}()
|
||||
// sharefsName is the prefix used by log.std in the sharefs process.
|
||||
const sharefsName = "sharefs"
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
log.SetPrefix(executableName + ": ")
|
||||
log.SetPrefix(sharefsName + ": ")
|
||||
|
||||
os.Exit(_main(len(os.Args), copyStrings(os.Args...)))
|
||||
os.Exit(_main(os.Args...))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user