MCPcopy Create free account
hub / github.com/cogentcore/core / TestRun

Function TestRun

cli/cli_test.go:117–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115func (cfg *TestConfig) IncludesPtr() *[]string { return &cfg.Includes }
116
117func TestRun(t *testing.T) {
118 cfg := &TestConfig{}
119 os.Args = []string{"myapp", "-gui", "install", "-no-gpu=f", "windows", "-Note", "Hello, World", "-PAT_PARAMS_SPARSENESS=4", "-net-data", "darwin"}
120
121 // we test for correct config in and out of command through closure
122 var (
123 inCmd bool
124 strSlice []string
125 gpu bool
126 sparseness float32
127 )
128 err := Run(DefaultOptions("My App", "My App is an awesome app"), cfg, &Cmd[*TestConfig]{
129 Func: func(tc *TestConfig) error {
130 inCmd = true
131 strSlice = tc.StrSlice
132 gpu = tc.GPU
133 sparseness = tc.PatParams.Sparseness
134 if tc.Note != "Hello, World" {
135 t.Errorf("expeected note to be %q but got %q", "Hello, World", tc.Note)
136 }
137 return nil
138 },
139 Name: "install",
140 Doc: "install installs stuff",
141 })
142 if err != nil {
143 t.Error(err)
144 }
145 if !inCmd {
146 t.Errorf("never got into command")
147 }
148 if !reflect.DeepEqual(strSlice, []string{"windows", "darwin"}) || !gpu || sparseness != 4 {
149 t.Errorf("got bad values for config (config: %#v)", cfg)
150 }
151}
152
153func TestConfigFunc(t *testing.T) {
154 cfg := &TestConfig{}

Callers

nothing calls this directly

Calls 4

DefaultOptionsFunction · 0.85
RunFunction · 0.70
ErrorfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected