Skip to content

Commit 447d509

Browse files
committed
update testscript to drop func() int
1 parent 57a3b42 commit 447d509

File tree

5 files changed

+17
-27
lines changed

5 files changed

+17
-27
lines changed

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module mvdan.cc/unparam
33
go 1.22.0
44

55
require (
6-
github.com/rogpeppe/go-internal v1.12.0
7-
golang.org/x/tools v0.25.0
6+
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a
7+
golang.org/x/tools v0.26.0
88
)
99

1010
require (
1111
golang.org/x/mod v0.21.0 // indirect
1212
golang.org/x/sync v0.8.0 // indirect
13-
golang.org/x/sys v0.25.0 // indirect
13+
golang.org/x/sys v0.26.0 // indirect
1414
)

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
2-
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
1+
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a h1:w3tdWGKbLGBPtR/8/oO74W6hmz0qE5q0z9aqSAewaaM=
2+
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a/go.mod h1:S8kfXMp+yh77OxPD4fdM6YUknrZpQxLhvxzS4gDHENY=
33
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
44
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
55
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
66
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
7-
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
8-
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9-
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE=
10-
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
7+
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
8+
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9+
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
10+
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=

main.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,28 @@ import (
1313
)
1414

1515
var (
16-
flagSet = flag.NewFlagSet("unparam", flag.ContinueOnError)
16+
flagSet = flag.NewFlagSet("unparam", flag.ExitOnError)
1717

1818
tests = flagSet.Bool("tests", false, "load tests too")
1919
exported = flagSet.Bool("exported", false, "inspect exported functions")
2020
debug = flagSet.Bool("debug", false, "debug prints")
2121
)
2222

2323
func main() {
24-
os.Exit(main1())
25-
}
26-
27-
func main1() int {
2824
flagSet.Usage = func() {
2925
fmt.Fprintln(os.Stderr, "usage: unparam [flags] [package ...]")
3026
flagSet.PrintDefaults()
3127
}
32-
if err := flagSet.Parse(os.Args[1:]); err != nil {
33-
if err != flag.ErrHelp {
34-
fmt.Fprintln(os.Stderr, err)
35-
}
36-
return 1
37-
}
28+
flagSet.Parse(os.Args[1:])
3829
warns, err := check.UnusedParams(*tests, *exported, *debug, flagSet.Args()...)
3930
if err != nil {
4031
fmt.Fprintln(os.Stderr, err)
41-
return 1
32+
os.Exit(1)
4233
}
4334
for _, warn := range warns {
4435
fmt.Println(warn)
4536
}
4637
if len(warns) > 0 {
47-
return 1
38+
os.Exit(1)
4839
}
49-
return 0
5040
}

main_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
)
1111

1212
func TestMain(m *testing.M) {
13-
os.Exit(testscript.RunMain(m, map[string]func() int{
14-
"unparam": main1,
15-
}))
13+
testscript.Main(m, map[string]func(){
14+
"unparam": main,
15+
})
1616
}
1717

1818
func TestScript(t *testing.T) {

testdata/script/cmds.txtar

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! exec unparam -h
1+
exec unparam -h
22
stderr '^usage: unparam \[flags'
33
! stderr 'test\.' # don't include flags from testing
44
! stderr 'command not specified'

0 commit comments

Comments
 (0)