mirror of
https://github.com/FiloSottile/age.git
synced 2025-12-23 05:25:14 +00:00
committed by
Filippo Valsorda
parent
83bab2ae6a
commit
ed44098807
@@ -99,7 +99,7 @@ func main() {
|
||||
|
||||
if len(os.Args) == 1 {
|
||||
flag.Usage()
|
||||
exit(1)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -16,22 +16,15 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
os.Exit(testscript.RunMain(m, map[string]func() int{
|
||||
"age": func() (exitCode int) {
|
||||
testOnlyPanicInsteadOfExit = true
|
||||
defer func() {
|
||||
if testOnlyDidExit {
|
||||
exitCode = recover().(int)
|
||||
}
|
||||
}()
|
||||
testscript.Main(m, map[string]func(){
|
||||
"age": func() {
|
||||
testOnlyConfigureScryptIdentity = func(r *age.ScryptRecipient) {
|
||||
r.SetWorkFactor(10)
|
||||
}
|
||||
testOnlyFixedRandomWord = "four"
|
||||
main()
|
||||
return 0
|
||||
},
|
||||
"age-plugin-test": func() (exitCode int) {
|
||||
"age-plugin-test": func() {
|
||||
p, _ := plugin.New("test")
|
||||
p.HandleRecipient(func(data []byte) (age.Recipient, error) {
|
||||
return testPlugin{}, nil
|
||||
@@ -39,9 +32,9 @@ func TestMain(m *testing.M) {
|
||||
p.HandleIdentity(func(data []byte) (age.Identity, error) {
|
||||
return testPlugin{}, nil
|
||||
})
|
||||
return p.Main()
|
||||
os.Exit(p.Main())
|
||||
},
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
type testPlugin struct{}
|
||||
|
||||
@@ -37,7 +37,7 @@ func printf(format string, v ...interface{}) {
|
||||
func errorf(format string, v ...interface{}) {
|
||||
l.Printf("age: error: "+format, v...)
|
||||
l.Printf("age: report unexpected or unhelpful errors at https://filippo.io/age/report")
|
||||
exit(1)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func warningf(format string, v ...interface{}) {
|
||||
@@ -50,21 +50,7 @@ func errorWithHint(error string, hints ...string) {
|
||||
l.Printf("age: hint: %s", hint)
|
||||
}
|
||||
l.Printf("age: report unexpected or unhelpful errors at https://filippo.io/age/report")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// If testOnlyPanicInsteadOfExit is true, exit will set testOnlyDidExit and
|
||||
// panic instead of calling os.Exit. This way, the wrapper in TestMain can
|
||||
// recover the panic and return the exit code only if it was originated in exit.
|
||||
var testOnlyPanicInsteadOfExit bool
|
||||
var testOnlyDidExit bool
|
||||
|
||||
func exit(code int) {
|
||||
if testOnlyPanicInsteadOfExit {
|
||||
testOnlyDidExit = true
|
||||
panic(code)
|
||||
}
|
||||
os.Exit(code)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// clearLine clears the current line on the terminal, or opens a new line if
|
||||
|
||||
6
go.mod
6
go.mod
@@ -5,7 +5,7 @@ go 1.24.0
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0
|
||||
filippo.io/hpke v0.4.0
|
||||
filippo.io/nistec v0.0.3
|
||||
filippo.io/nistec v0.0.4
|
||||
golang.org/x/crypto v0.45.0
|
||||
golang.org/x/sys v0.38.0
|
||||
golang.org/x/term v0.37.0
|
||||
@@ -14,6 +14,6 @@ require (
|
||||
// Test dependencies.
|
||||
require (
|
||||
c2sp.org/CCTV/age v0.0.0-20250426113718-46fad5b26cb2
|
||||
github.com/rogpeppe/go-internal v1.12.0
|
||||
golang.org/x/tools v0.22.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1
|
||||
golang.org/x/tools v0.39.0 // indirect
|
||||
)
|
||||
|
||||
12
go.sum
12
go.sum
@@ -4,15 +4,15 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
filippo.io/hpke v0.4.0 h1:p575VVQ6ted4pL+it6M00V/f2qTZITO0zgmdKCkd5+A=
|
||||
filippo.io/hpke v0.4.0/go.mod h1:EmAN849/P3qdeK+PCMkDpDm83vRHM5cDipBJ8xbQLVY=
|
||||
filippo.io/nistec v0.0.3 h1:h336Je2jRDZdBCLy2fLDUd9E2unG32JLwcJi0JQE9Cw=
|
||||
filippo.io/nistec v0.0.3/go.mod h1:84fxC9mi+MhC2AERXI4LSa8cmSVOzrFikg6hZ4IfCyw=
|
||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
filippo.io/nistec v0.0.4 h1:F14ZHT5htWlMnQVPndX9ro9arf56cBhQxq4LnDI491s=
|
||||
filippo.io/nistec v0.0.4/go.mod h1:PK/lw8I1gQT4hUML4QGaqljwdDaFcMyFKSXN7kjrtKI=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
|
||||
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
|
||||
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
|
||||
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
|
||||
|
||||
Reference in New Issue
Block a user