Skip to content

Commit 6a18dda

Browse files
committed
Fix deprecation of testscript.RunMain
1 parent f7dac16 commit 6a18dda

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

cmd/step/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package main
22

33
import (
4-
"os"
5-
64
"github.com/smallstep/certificates/ca"
75
"github.com/smallstep/cli-utils/step"
86

@@ -27,5 +25,5 @@ func init() {
2725
}
2826

2927
func main() {
30-
os.Exit(cmd.Run())
28+
cmd.Run()
3129
}

integration/shared_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package integration
22

33
import (
4-
"os"
54
"testing"
65

76
"github.com/rogpeppe/go-internal/testscript"
@@ -10,7 +9,7 @@ import (
109
)
1110

1211
func TestMain(m *testing.M) {
13-
os.Exit(testscript.RunMain(m, map[string]func() int{
12+
testscript.Main(m, map[string]func(){
1413
"step": cmd.Run, // main entrypoint name
15-
}))
14+
})
1615
}

internal/cmd/root.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ import (
4343
_ "github.com/smallstep/cli/command/ssh"
4444
)
4545

46-
func Run() int {
46+
func Run() {
47+
os.Exit(run())
48+
}
49+
50+
func run() int {
51+
defer panicHandler()
52+
4753
// initialize step environment.
4854
if err := step.Init(); err != nil {
4955
fmt.Fprintln(os.Stderr, err.Error())
5056
return 1
5157
}
5258

53-
defer panicHandler()
54-
5559
// create new instance of app
5660
app := newApp(os.Stdout, os.Stderr)
5761

0 commit comments

Comments
 (0)