Make tests work on windows
diff --git a/command_test.go b/command_test.go
index b2df7e3..67ced9f 100644
--- a/command_test.go
+++ b/command_test.go
@@ -1,6 +1,7 @@
package flags
import (
+ "fmt"
"testing"
)
@@ -265,7 +266,7 @@
} `command:"cmd"`
}{}
- assertParseFail(t, ErrRequired, "the required flag `-v' was not specified", &opts, "cmd")
+ assertParseFail(t, ErrRequired, fmt.Sprintf("the required flag `%cv' was not specified", defaultShortOptDelimiter), &opts, "cmd")
}
func TestRequiredAllOnCommand(t *testing.T) {
@@ -278,7 +279,7 @@
} `command:"cmd"`
}{}
- assertParseFail(t, ErrRequired, "the required flags `-v' and `--missing' were not specified", &opts, "cmd")
+ assertParseFail(t, ErrRequired, fmt.Sprintf("the required flags `%cv' and `%smissing' were not specified", defaultShortOptDelimiter, defaultLongOptDelimiter), &opts, "cmd")
}
func TestDefaultOnCommand(t *testing.T) {
diff --git a/help_test.go b/help_test.go
index e3e84d8..191c9e3 100644
--- a/help_test.go
+++ b/help_test.go
@@ -7,6 +7,7 @@
"io/ioutil"
"os"
"os/exec"
+ "runtime"
"testing"
"time"
)
@@ -81,7 +82,33 @@
t.Errorf("Expected flags.ErrHelp type, but got %s", e.Type)
}
- expected := `Usage:
+ var expected string
+
+ if runtime.GOOS == "windows" {
+ expected = `Usage:
+ TestHelp [OPTIONS] <command>
+
+Application Options:
+ /v, /verbose Show verbose debug information
+ /c: Call phone number
+ /ptrslice: A slice of pointers to string
+ /empty-description
+ /default: Test default value (Some value)
+ /default-array: Test default array value (Some value, Another value)
+ /default-map: Testdefault map value (some:value, another:value)
+
+Other Options:
+ /s: A slice of strings (some, value)
+ /intmap: A map from string to int (a:1)
+
+Help Options:
+ /h, /help Show this help message
+
+Available commands:
+ command A command (aliases: cm, cmd)
+`
+ } else {
+ expected = `Usage:
TestHelp [OPTIONS] <command>
Application Options:
@@ -103,6 +130,7 @@
Available commands:
command A command (aliases: cm, cmd)
`
+ }
if e.Message != expected {
ret, err := helpDiff(e.Message, expected)
@@ -216,12 +244,23 @@
t.Errorf("Expected flags.ErrHelp type, but got %s", e.Type)
}
- expected := `Usage:
+ var expected string
+
+ if runtime.GOOS == "windows" {
+ expected = `Usage:
+ TestHelpCommand [OPTIONS] command
+
+Help Options:
+ /h, /help Show this help message
+`
+ } else {
+ expected = `Usage:
TestHelpCommand [OPTIONS] command
Help Options:
-h, --help Show this help message
`
+ }
if e.Message != expected {
ret, err := helpDiff(e.Message, expected)
diff --git a/marshal_test.go b/marshal_test.go
index 362d0f2..59c9cce 100644
--- a/marshal_test.go
+++ b/marshal_test.go
@@ -80,7 +80,7 @@
Value marshalled `short:"v"`
}{}
- assertParseFail(t, ErrMarshal, "invalid argument for flag `-v' (expected flags.marshalled): `invalid' is not a valid value, please specify `yes' or `no'", &opts, "-vinvalid")
+ assertParseFail(t, ErrMarshal, fmt.Sprintf("invalid argument for flag `%cv' (expected flags.marshalled): `invalid' is not a valid value, please specify `yes' or `no'", defaultShortOptDelimiter), &opts, "-vinvalid")
}
func TestMarshalError(t *testing.T) {
diff --git a/short_test.go b/short_test.go
index d08702b..95712c1 100644
--- a/short_test.go
+++ b/short_test.go
@@ -1,6 +1,7 @@
package flags
import (
+ "fmt"
"testing"
)
@@ -31,7 +32,7 @@
Value bool `short:"v" required:"true"`
}{}
- assertParseFail(t, ErrRequired, "the required flag `-v' was not specified", &opts)
+ assertParseFail(t, ErrRequired, fmt.Sprintf("the required flag `%cv' was not specified", defaultShortOptDelimiter), &opts)
}
func TestShortMultiConcat(t *testing.T) {
@@ -143,7 +144,7 @@
Value string `short:"v"`
}{}
- assertParseFail(t, ErrExpectedArgument, "expected argument for flag `-v'", &opts, "-ffv=value")
+ assertParseFail(t, ErrExpectedArgument, fmt.Sprintf("expected argument for flag `%cv'", defaultShortOptDelimiter), &opts, "-ffv=value")
}
func TestShortMultiArg(t *testing.T) {
@@ -165,7 +166,7 @@
Value string `short:"v"`
}{}
- assertParseFail(t, ErrExpectedArgument, "expected argument for flag `-v'", &opts, "-ffvvalue")
+ assertParseFail(t, ErrExpectedArgument, fmt.Sprintf("expected argument for flag `%cv'", defaultShortOptDelimiter), &opts, "-ffvvalue")
}
func TestShortMultiArgConcat(t *testing.T) {