-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
spec_test.go
51 lines (42 loc) · 1.05 KB
/
spec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package spec
import (
_ "embed"
"testing"
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace/pkg/sandbox"
"github.com/carapace-sh/carapace/pkg/style"
"github.com/spf13/pflag"
)
//go:embed example/nonposix.yaml
var nonposix string
func skipNonFork(t *testing.T) {
if fs := (flagSet{pflag.NewFlagSet("test", pflag.PanicOnError)}); !fs.IsFork() {
t.Skip("skip nonposix tests with spf13/pflag")
}
}
func TestNonposix(t *testing.T) {
skipNonFork(t)
sandboxSpec(t, nonposix)(func(s *sandbox.Sandbox) {
s.Run("a").
Expect(carapace.ActionValues("a"))
s.Run("-s").
Expect(carapace.ActionValuesDescribed(
"-styled", "nonposix shorthand").
NoSpace('.').
Style(style.Carapace.FlagArg).
Tag("shorthand flags"))
s.Run("--m").
Expect(carapace.ActionValuesDescribed(
"--mixed", "mixed repeatable",
).NoSpace('.').
Style(style.Carapace.FlagNoArg).
Tag("longhand flags"))
s.Run("-opt=").
Expect(carapace.ActionValues(
"1",
"2",
"3",
).Prefix("-opt=").
Usage("both nonposix"))
})
}