(t *testing.T)
| 787 | } |
| 788 | |
| 789 | func TestChildFlagShadowsParentPersistentFlag(t *testing.T) { |
| 790 | parent := &Command{Use: "parent", Run: emptyRun} |
| 791 | child := &Command{Use: "child", Run: emptyRun} |
| 792 | |
| 793 | parent.PersistentFlags().Bool("boolf", false, "") |
| 794 | parent.PersistentFlags().Int("intf", -1, "") |
| 795 | child.Flags().String("strf", "", "") |
| 796 | child.Flags().Int("intf", -1, "") |
| 797 | |
| 798 | parent.AddCommand(child) |
| 799 | |
| 800 | childInherited := child.InheritedFlags() |
| 801 | childLocal := child.LocalFlags() |
| 802 | |
| 803 | if childLocal.Lookup("strf") == nil { |
| 804 | t.Error(`LocalFlags expected to contain "strf", got "nil"`) |
| 805 | } |
| 806 | if childInherited.Lookup("boolf") == nil { |
| 807 | t.Error(`InheritedFlags expected to contain "boolf", got "nil"`) |
| 808 | } |
| 809 | |
| 810 | if childInherited.Lookup("intf") != nil { |
| 811 | t.Errorf(`InheritedFlags should not contain shadowed flag "intf"`) |
| 812 | } |
| 813 | if childLocal.Lookup("intf") == nil { |
| 814 | t.Error(`LocalFlags expected to contain "intf", got "nil"`) |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | func TestPersistentFlagsOnChild(t *testing.T) { |
| 819 | var childCmdArgs []string |
nothing calls this directly
no test coverage detected