MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestRunnerOptionsFromFlags

Function TestRunnerOptionsFromFlags

tools/celtest/test_runner.go:184–211  ·  view source on GitHub ↗

TestRunnerOptionsFromFlags returns a TestRunnerOption which configures the following attributes of the test runner using the parsed flags and the optionally provided test runner and test compiler options: - Test compiler - The `file_descriptor_set`, `base_config_path` and `config_path` flags are use

(testResourcesDir string, testRunnerOpts []TestRunnerOption, testCompilerOpts ...any)

Source from the content-addressed store, hash-verified

182// evaluated by the test runner.
183// - Enable coverage - The `enable_coverage` flag is used to enable coverage calculation and reporting.
184func TestRunnerOptionsFromFlags(testResourcesDir string, testRunnerOpts []TestRunnerOption, testCompilerOpts ...any) TestRunnerOption {
185 if !flag.Parsed() {
186 flag.Parse()
187 }
188 if err := updateRunfilesPathForFlags(testResourcesDir); err != nil {
189 return nil
190 }
191 return func(tr *TestRunner) (*TestRunner, error) {
192 opts := []TestRunnerOption{
193 testRunnerCompilerFromFlags(testCompilerOpts...),
194 TestSuite(testSuitePath),
195 FileDescriptorSet(fileDescriptorSetPath),
196 TestExpression(celExpression),
197 }
198 if enableCoverage {
199 opts = append(opts, EnableCoverage())
200 }
201 opts = append(opts, testRunnerOpts...)
202 var err error
203 for _, opt := range opts {
204 tr, err = opt(tr)
205 if err != nil {
206 return nil, err
207 }
208 }
209 return tr, nil
210 }
211}
212
213func testRunnerCompilerFromFlags(testCompilerOpts ...any) TestRunnerOption {
214 var opts []any

Callers 2

TestK8sCELFunction · 0.92
TestCELFunction · 0.92

Calls 7

FileDescriptorSetFunction · 0.85
TestExpressionFunction · 0.85
EnableCoverageFunction · 0.85
TestSuiteFunction · 0.70
ParseMethod · 0.65

Tested by

no test coverage detected