File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -2241,3 +2241,42 @@ func TestTimestampFlagApply_WithDestination(t *testing.T) {
2241
2241
expect (t , err , nil )
2242
2242
expect (t , * fl .Destination .timestamp , expectedResult )
2243
2243
}
2244
+
2245
+ // Test issue #1254
2246
+ // StringSlice() with UseShortOptionHandling causes duplicated entries, depending on the ordering of the flags
2247
+ func TestSliceShortOptionHandle (t * testing.T ) {
2248
+ wasCalled := false
2249
+ err := (& App {
2250
+ Commands : []* Command {
2251
+ {
2252
+ Name : "foobar" ,
2253
+ UseShortOptionHandling : true ,
2254
+ Action : func (ctx * Context ) error {
2255
+ wasCalled = true
2256
+ if ctx .Bool ("i" ) != true {
2257
+ t .Error ("bool i not set" )
2258
+ }
2259
+ if ctx .Bool ("t" ) != true {
2260
+ t .Error ("bool i not set" )
2261
+ }
2262
+ ss := ctx .StringSlice ("net" )
2263
+ if ! reflect .DeepEqual (ss , []string {"foo" }) {
2264
+ t .Errorf ("Got different slice(%v) than expected" , ss )
2265
+ }
2266
+ return nil
2267
+ },
2268
+ Flags : []Flag {
2269
+ & StringSliceFlag {Name : "net" },
2270
+ & BoolFlag {Name : "i" },
2271
+ & BoolFlag {Name : "t" },
2272
+ },
2273
+ },
2274
+ },
2275
+ }).Run ([]string {"run" , "foobar" , "--net=foo" , "-it" })
2276
+ if err != nil {
2277
+ t .Fatal (err )
2278
+ }
2279
+ if ! wasCalled {
2280
+ t .Fatal ("Action callback was never called" )
2281
+ }
2282
+ }
You can’t perform that action at this time.
0 commit comments