|
6 | 6 | "testing"
|
7 | 7 |
|
8 | 8 | "github.com/microsoft/typescript-go/internal/ast"
|
| 9 | + "github.com/microsoft/typescript-go/internal/collections" |
9 | 10 | "github.com/microsoft/typescript-go/internal/core"
|
10 | 11 | "github.com/microsoft/typescript-go/internal/parser"
|
11 | 12 | "github.com/microsoft/typescript-go/internal/testutil/baseline"
|
@@ -98,44 +99,40 @@ func DoJSEmitBaseline(
|
98 | 99 | ))
|
99 | 100 | }
|
100 | 101 |
|
101 |
| - // !!! Enable the following once noCheck is more comprehensive |
102 |
| - ////if !options.NoCheck.IsTrue() && !options.NoEmit.IsTrue() { |
103 |
| - //// testConfig := make(map[string]string) |
104 |
| - //// testConfig["noCheck"] = "true" |
105 |
| - //// withoutChecking := result.Repeat(testConfig) |
106 |
| - //// compareResultFileSets := func(a collections.OrderedMap[string, *harnessutil.TestFile], b collections.OrderedMap[string, *harnessutil.TestFile]) { |
107 |
| - //// for key, doc := range a.Entries() { |
108 |
| - //// original := b.GetOrZero(key) |
109 |
| - //// if original == nil { |
110 |
| - //// jsCode.WriteString("\r\n\r\n!!!! File ") |
111 |
| - //// jsCode.WriteString(removeTestPathPrefixes(doc.UnitName, false /*retainTrailingDirectorySeparator*/)) |
112 |
| - //// jsCode.WriteString(" missing from original emit, but present in noCheck emit\r\n") |
113 |
| - //// jsCode.WriteString(fileOutput(doc, harnessSettings)) |
114 |
| - //// } else if original.Content != doc.Content { |
115 |
| - //// jsCode.WriteString("\r\n\r\n!!!! File ") |
116 |
| - //// jsCode.WriteString(removeTestPathPrefixes(doc.UnitName, false /*retainTrailingDirectorySeparator*/)) |
117 |
| - //// jsCode.WriteString(" differs from original emit in noCheck emit\r\n") |
118 |
| - //// var fileName string |
119 |
| - //// if harnessSettings.FullEmitPaths { |
120 |
| - //// fileName = removeTestPathPrefixes(doc.UnitName, false /*retainTrailingDirectorySeparator*/) |
121 |
| - //// } else { |
122 |
| - //// fileName = tspath.GetBaseFileName(doc.UnitName) |
123 |
| - //// } |
124 |
| - //// jsCode.WriteString("//// [") |
125 |
| - //// jsCode.WriteString(fileName) |
126 |
| - //// jsCode.WriteString("]\r\n") |
127 |
| - //// expected := original.Content |
128 |
| - //// actual := doc.Content |
129 |
| - //// err := diff.Text("Expected\tThe full check baseline", "Actual\twith noCheck set", expected, actual, &jsCode) |
130 |
| - //// if err != nil { |
131 |
| - //// t.Fatal(err) |
132 |
| - //// } |
133 |
| - //// } |
134 |
| - //// } |
135 |
| - //// } |
136 |
| - //// compareResultFileSets(withoutChecking.DTS, result.DTS) |
137 |
| - //// compareResultFileSets(withoutChecking.JS, result.JS) |
138 |
| - ////} |
| 102 | + if !options.NoCheck.IsTrue() && !options.NoEmit.IsTrue() { |
| 103 | + testConfig := make(map[string]string) |
| 104 | + testConfig["noCheck"] = "true" |
| 105 | + withoutChecking := result.Repeat(testConfig) |
| 106 | + compareResultFileSets := func(a *collections.OrderedMap[string, *harnessutil.TestFile], b *collections.OrderedMap[string, *harnessutil.TestFile]) { |
| 107 | + for key, doc := range a.Entries() { |
| 108 | + original := b.GetOrZero(key) |
| 109 | + if original == nil { |
| 110 | + jsCode.WriteString("\r\n\r\n!!!! File ") |
| 111 | + jsCode.WriteString(removeTestPathPrefixes(doc.UnitName, false /*retainTrailingDirectorySeparator*/)) |
| 112 | + jsCode.WriteString(" missing from original emit, but present in noCheck emit\r\n") |
| 113 | + jsCode.WriteString(fileOutput(doc, harnessSettings)) |
| 114 | + } else if original.Content != doc.Content { |
| 115 | + jsCode.WriteString("\r\n\r\n!!!! File ") |
| 116 | + jsCode.WriteString(removeTestPathPrefixes(doc.UnitName, false /*retainTrailingDirectorySeparator*/)) |
| 117 | + jsCode.WriteString(" differs from original emit in noCheck emit\r\n") |
| 118 | + var fileName string |
| 119 | + if harnessSettings.FullEmitPaths { |
| 120 | + fileName = removeTestPathPrefixes(doc.UnitName, false /*retainTrailingDirectorySeparator*/) |
| 121 | + } else { |
| 122 | + fileName = tspath.GetBaseFileName(doc.UnitName) |
| 123 | + } |
| 124 | + jsCode.WriteString("//// [") |
| 125 | + jsCode.WriteString(fileName) |
| 126 | + jsCode.WriteString("]\r\n") |
| 127 | + expected := original.Content |
| 128 | + actual := doc.Content |
| 129 | + jsCode.WriteString(baseline.DiffText("Expected\tThe full check baseline", "Actual\twith noCheck set", expected, actual)) |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + compareResultFileSets(&withoutChecking.DTS, &result.DTS) |
| 134 | + compareResultFileSets(&withoutChecking.JS, &result.JS) |
| 135 | + } |
139 | 136 |
|
140 | 137 | if tspath.FileExtensionIsOneOf(baselinePath, []string{tspath.ExtensionTs, tspath.ExtensionTsx}) {
|
141 | 138 | baselinePath = tspath.ChangeExtension(baselinePath, tspath.ExtensionJs)
|
|
0 commit comments