ExecuteTest executes the test case against the provided list of programs and returns an error if the test fails. During the test execution, the intermediate values encountered during the evaluation of each program are collected and stored in the CoverageStats map of the TestRunner.
(t *testing.T, programs []Program, test *Test)
| 1019 | // During the test execution, the intermediate values encountered during the evaluation of each |
| 1020 | // program are collected and stored in the CoverageStats map of the TestRunner. |
| 1021 | func (tr *TestRunner) ExecuteTest(t *testing.T, programs []Program, test *Test) error { |
| 1022 | t.Helper() |
| 1023 | if tr.Compiler == nil { |
| 1024 | return fmt.Errorf("compiler is not set") |
| 1025 | } |
| 1026 | for i, pr := range programs { |
| 1027 | if pr.Program == nil { |
| 1028 | return fmt.Errorf("CEL program not set") |
| 1029 | } |
| 1030 | out, details, err := pr.Eval(test.input) |
| 1031 | if enableDebug { |
| 1032 | t.Logf("Eval result: %v (err: %v)", out, err) |
| 1033 | } |
| 1034 | if testResult := test.resultMatcher(out, err); !testResult.Success { |
| 1035 | return fmt.Errorf("test: %s \n wanted: %v \n failed: %v", test.name, testResult.Wanted, testResult.Error) |
| 1036 | } |
| 1037 | if tr.EnableCoverage { |
| 1038 | collectCoverageStats(details, &pr) |
| 1039 | programs[i] = pr |
| 1040 | } |
| 1041 | } |
| 1042 | return nil |
| 1043 | } |
| 1044 | |
| 1045 | // collectCoverageStats collects the coverage stats from the EvalDetails and stores them in the |
| 1046 | // CoverageStats map of the Program. |