Skip to content

Commit

Permalink
update testscript to drop func() int
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan committed Dec 26, 2024
1 parent 7c973a2 commit b857c6c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
15 changes: 6 additions & 9 deletions cmd/xurls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,15 @@ func scanPath(re *regexp.Regexp, path string) error {
return nil
}

func main() { os.Exit(main1()) }

func main1() int {
func main() {
flag.Parse()
if *versionFlag {
fmt.Println(readVersion())
return 0
return
}
if *relaxed && *matching != "" {
fmt.Fprintln(os.Stderr, "-r and -m at the same time don't make much sense")
return 1
os.Exit(1)
}
switch fix {
case "": // disabled by default
Expand All @@ -232,7 +230,7 @@ func main1() int {
fix = "auto"
default:
flag.Usage()
return 1
os.Exit(2)
}
var re *regexp.Regexp
if *relaxed {
Expand All @@ -241,7 +239,7 @@ func main1() int {
var err error
if re, err = xurls.StrictMatchingScheme(*matching); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
os.Exit(2)
}
} else {
re = xurls.Strict()
Expand All @@ -253,10 +251,9 @@ func main1() int {
for _, path := range args {
if err := scanPath(re, path); err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
os.Exit(1)
}
}
return 0
}

// Borrowed from https://github.com/burrowers/garble.
Expand Down
6 changes: 3 additions & 3 deletions cmd/xurls/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
)

func TestMain(m *testing.M) {
os.Exit(testscript.RunMain(m, map[string]func() int{
"xurls": main1,
}))
testscript.Main(m, map[string]func(){
"xurls": main,
})
}

func TestScript(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module mvdan.cc/xurls/v2

go 1.22
go 1.22.0

require (
github.com/rogpeppe/go-internal v1.12.0
golang.org/x/mod v0.16.0
golang.org/x/sync v0.6.0
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a
golang.org/x/mod v0.21.0
golang.org/x/sync v0.8.0
)

require (
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/tools v0.26.0 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a h1:w3tdWGKbLGBPtR/8/oO74W6hmz0qE5q0z9aqSAewaaM=
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a/go.mod h1:S8kfXMp+yh77OxPD4fdM6YUknrZpQxLhvxzS4gDHENY=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=

0 comments on commit b857c6c

Please sign in to comment.