recordTestResults runs all test cases and updates the YAML file with actual results.
(t *testing.T, fullPath string, testCases []SplitTestCase, opts SplitTestOptions)
| 145 | |
| 146 | // recordTestResults runs all test cases and updates the YAML file with actual results. |
| 147 | func recordTestResults(t *testing.T, fullPath string, testCases []SplitTestCase, opts SplitTestOptions) { |
| 148 | t.Helper() |
| 149 | |
| 150 | updated := make([]SplitTestCase, len(testCases)) |
| 151 | for i, tc := range testCases { |
| 152 | updated[i] = SplitTestCase{ |
| 153 | Description: tc.Description, |
| 154 | Input: tc.Input, |
| 155 | } |
| 156 | |
| 157 | result, err := opts.SplitFunc(tc.Input) |
| 158 | if err != nil { |
| 159 | updated[i].Error = err.Error() |
| 160 | continue |
| 161 | } |
| 162 | |
| 163 | updated[i].Result = make([]StatementResult, len(result)) |
| 164 | for j, stmt := range result { |
| 165 | updated[i].Result[j] = StatementResult{ |
| 166 | Text: stmt.Text, |
| 167 | BaseLine: stmt.BaseLine(), |
| 168 | Empty: stmt.Empty, |
| 169 | } |
| 170 | if stmt.Start != nil { |
| 171 | updated[i].Result[j].Start = PositionResult{ |
| 172 | Line: stmt.Start.Line, |
| 173 | Column: stmt.Start.Column, |
| 174 | } |
| 175 | } |
| 176 | if stmt.End != nil { |
| 177 | updated[i].Result[j].End = PositionResult{ |
| 178 | Line: stmt.End.Line, |
| 179 | Column: stmt.End.Column, |
| 180 | } |
| 181 | } |
| 182 | if stmt.Range != nil { |
| 183 | updated[i].Result[j].Range = RangeResult{ |
| 184 | Start: stmt.Range.Start, |
| 185 | End: stmt.Range.End, |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | yamltest.Record(t, fullPath, updated) |
| 192 | |
| 193 | t.Logf("Updated %s with %d test cases", fullPath, len(updated)) |
| 194 | } |
| 195 | |
| 196 | func runSingleTest(t *testing.T, tc SplitTestCase, opts SplitTestOptions) { |
| 197 | t.Helper() |
no test coverage detected