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)
| 182 | // evaluated by the test runner. |
| 183 | // - Enable coverage - The `enable_coverage` flag is used to enable coverage calculation and reporting. |
| 184 | func 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 | |
| 213 | func testRunnerCompilerFromFlags(testCompilerOpts ...any) TestRunnerOption { |
| 214 | var opts []any |
no test coverage detected