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

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:
2025-12-27 17:33:12 +09:00
parent 2f8ca83376
commit 775a9f57c9
3 changed files with 145 additions and 29 deletions

View File

@@ -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...))
}