Skip to content

Commit ea6d310

Browse files
committed
incpatch testing w/o changes
1 parent 21bfd76 commit ea6d310

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ var (
3737
flagBranch = flag.Bool("branch", false, "print the current branch name")
3838
)
3939

40+
var exitFn func(int) = os.Exit
41+
var testMode bool
42+
4043
func mainfn() int {
4144
repoDir := os.ExpandEnv(flag.Arg(0))
4245
if repoDir == "" {
@@ -60,6 +63,9 @@ func mainfn() int {
6063
if vi, err = vs.GetVersion(repoDir); err == nil {
6164
if *flagIncPatch {
6265
createTag = vi.IncPatch()
66+
if testMode {
67+
createTag = ""
68+
}
6369
}
6470
content := vi.Version()
6571
if *flagBranch {
@@ -100,8 +106,6 @@ func mainfn() int {
100106
return retv
101107
}
102108

103-
var exitFn func(int) = os.Exit
104-
105109
func main() {
106110
flag.Parse()
107111
exitFn(mainfn())

main_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import (
77
"testing"
88
)
99

10+
func init() {
11+
testMode = true
12+
}
13+
1014
func TestMainFn(t *testing.T) {
1115
flag.Parse()
1216
*flagGoPackage = true
@@ -28,6 +32,7 @@ func TestMainFnBranch(t *testing.T) {
2832
flag.Parse()
2933
*flagBranch = true
3034
*flagOut = "test.out"
35+
*flagIncPatch = true
3136
mainfn()
3237
b, err := os.ReadFile("test.out")
3338
if err == nil {
@@ -53,6 +58,5 @@ func TestMainError(t *testing.T) {
5358
flag.Parse()
5459
*flagOut = "/proc/.nonexistant"
5560
*flagDebug = true
56-
*flagIncPatch = true
5761
main()
5862
}

0 commit comments

Comments
 (0)