-
Notifications
You must be signed in to change notification settings - Fork 663
Add symbol baseliner #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add symbol baseliner #191
Changes from all commits
c7ba10e
a31164b
68de1dc
e892a68
619db63
7bd349e
9b18529
4f61e6d
4aaed88
de51332
3d7f5ad
024e9b9
dbc0a63
f73a494
ef7b8e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,11 @@ type Options struct { | |
|
||
const NoContent = "<no content>" | ||
|
||
func Run(t testing.TB, fileName string, actual string, opts Options) { | ||
func Run(t *testing.T, fileName string, actual string, opts Options) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to make this change from |
||
writeComparison(t, actual, fileName, opts) | ||
} | ||
|
||
func writeComparison(t testing.TB, actual string, relativeFileName string, opts Options) { | ||
func writeComparison(t *testing.T, actual string, relativeFileName string, opts Options) { | ||
if actual == "" { | ||
panic("The generated content was \"\". Return 'baseline.NoContent' if no baselining is required.") | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,6 @@ import ( | |
// IO | ||
const harnessNewLine = "\r\n" | ||
|
||
var ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
lineDelimiter = regexp.MustCompile("\r?\n") | ||
nonWhitespace = regexp.MustCompile(`\S`) | ||
tsExtension = regexp.MustCompile(`\.tsx?$`) | ||
) | ||
|
||
var formatOpts = &compiler.DiagnosticsFormattingOptions{ | ||
NewLine: harnessNewLine, | ||
} | ||
|
@@ -40,7 +34,7 @@ var ( | |
diagnosticsLocationPattern = regexp.MustCompile(`(?i)(lib.*\.d\.ts):\d+:\d+`) | ||
) | ||
|
||
func DoErrorBaseline(t testing.TB, baselinePath string, inputFiles []*TestFile, errors []*ast.Diagnostic, pretty bool) { | ||
func DoErrorBaseline(t *testing.T, baselinePath string, inputFiles []*TestFile, errors []*ast.Diagnostic, pretty bool) { | ||
baselinePath = tsExtension.ReplaceAllString(baselinePath, ".errors.txt") | ||
var errorBaseline string | ||
if len(errors) > 0 { | ||
|
@@ -61,7 +55,7 @@ func minimalDiagnosticsToString(diagnostics []*ast.Diagnostic, pretty bool) stri | |
return output.String() | ||
} | ||
|
||
func getErrorBaseline(t testing.TB, inputFiles []*TestFile, diagnostics []*ast.Diagnostic, pretty bool) string { | ||
func getErrorBaseline(t *testing.T, inputFiles []*TestFile, diagnostics []*ast.Diagnostic, pretty bool) string { | ||
t.Helper() | ||
outputLines := iterateErrorBaseline(t, inputFiles, diagnostics, pretty) | ||
|
||
|
@@ -77,7 +71,7 @@ func getErrorBaseline(t testing.TB, inputFiles []*TestFile, diagnostics []*ast.D | |
return strings.Join(outputLines, "") | ||
} | ||
|
||
func iterateErrorBaseline(t testing.TB, inputFiles []*TestFile, inputDiagnostics []*ast.Diagnostic, pretty bool) []string { | ||
func iterateErrorBaseline(t *testing.T, inputFiles []*TestFile, inputDiagnostics []*ast.Diagnostic, pretty bool) []string { | ||
t.Helper() | ||
diagnostics := slices.Clone(inputDiagnostics) | ||
slices.SortFunc(diagnostics, compiler.CompareDiagnostics) | ||
|
@@ -225,7 +219,6 @@ func iterateErrorBaseline(t testing.TB, inputFiles []*TestFile, inputDiagnostics | |
// Verify we didn't miss any errors in this file | ||
assert.Check(t, cmp.Equal(markedErrorCount, len(fileErrors)), "count of errors in "+inputFile.unitName) | ||
_, isDupe := dupeCase[sanitizeTestFilePath(inputFile.unitName)] | ||
checkDuplicatedFileName(inputFile.unitName, dupeCase) | ||
result = append(result, outputLines.String()) | ||
if isDupe { | ||
// Case-duplicated files on a case-insensitive build will have errors reported in both the dupe and the original | ||
|
@@ -253,19 +246,6 @@ func iterateErrorBaseline(t testing.TB, inputFiles []*TestFile, inputDiagnostics | |
return result | ||
} | ||
|
||
func checkDuplicatedFileName(resultName string, dupeCase map[string]int) string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized this was essentially unused in the old test infra. |
||
resultName = sanitizeTestFilePath(resultName) | ||
if _, ok := dupeCase[resultName]; ok { | ||
// A different baseline filename should be manufactured if the names differ only in case, for windows compat | ||
count := 1 + dupeCase[resultName] | ||
dupeCase[resultName] = count | ||
resultName = fmt.Sprintf("%s.dupe%d", resultName, count) | ||
} else { | ||
dupeCase[resultName] = 0 | ||
} | ||
return resultName | ||
} | ||
|
||
func flattenDiagnosticMessage(d *ast.Diagnostic, newLine string) string { | ||
var output strings.Builder | ||
compiler.WriteFlattenedDiagnosticMessage(&output, d, newLine) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug fix.