Skip to content

Commit 9933123

Browse files
committed
Rename error.txt diff to output.txt
1 parent 9c66d9e commit 9933123

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

internal/execute/tsctestrunner_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (test *tscInput) executeCommand(sys *testSys, baselineBuilder *strings.Buil
6363

6464
func (test *tscInput) run(t *testing.T, scenario string) {
6565
t.Helper()
66-
t.Run(test.subScenario+" tsc baseline", func(t *testing.T) {
66+
t.Run(test.subScenario, func(t *testing.T) {
6767
t.Parallel()
6868
// initial test tsc compile
6969
baselineBuilder := &strings.Builder{}
@@ -80,6 +80,7 @@ func (test *tscInput) run(t *testing.T, scenario string) {
8080
result := test.executeCommand(sys, baselineBuilder, test.commandLineArgs)
8181
sys.serializeState(baselineBuilder)
8282
sys.baselineProgram(baselineBuilder, result.IncrementalProgram, result.Watcher)
83+
var unexpectedDiff string
8384

8485
for index, do := range test.edits {
8586
sys.clearOutput()
@@ -118,11 +119,18 @@ func (test *tscInput) run(t *testing.T, scenario string) {
118119
if diff != "" {
119120
baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!", do.expectedDiff)))
120121
baselineBuilder.WriteString(diff)
122+
if do.expectedDiff == "" {
123+
unexpectedDiff += fmt.Sprintf("Edit [%d]:: %s\n!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!\n%s\n", index, do.caption, diff)
124+
}
121125
} else if do.expectedDiff != "" {
122126
baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s !!! Diff not found but explanation present, please review and remove the explanation !!!\n", do.expectedDiff))
127+
unexpectedDiff += fmt.Sprintf("Edit [%d]:: %s\n!!! Diff not found but explanation present, please review and remove the explanation !!!\n", index, do.caption)
123128
}
124129
}
125130
baseline.Run(t, strings.ReplaceAll(test.subScenario, " ", "-")+".js", baselineBuilder.String(), baseline.Options{Subfolder: filepath.Join(test.getBaselineSubFolder(), scenario)})
131+
if unexpectedDiff != "" {
132+
t.Errorf("Test %s has unexpected diff %s with incremental build, please review the baseline file", test.subScenario, unexpectedDiff)
133+
}
126134
})
127135
}
128136

@@ -152,10 +160,10 @@ func getDiffForIncremental(incrementalSys *testSys, nonIncrementalSys *testSys)
152160
}
153161
}
154162

155-
incrementalErrors := strings.Join(incrementalSys.output, "")
156-
nonIncrementalErrors := strings.Join(nonIncrementalSys.output, "")
157-
if incrementalErrors != nonIncrementalErrors {
158-
diffBuilder.WriteString(baseline.DiffText("nonIncremental errors.txt", "incremental errors.txt", nonIncrementalErrors, incrementalErrors))
163+
incrementalOutput := strings.Join(incrementalSys.output, "")
164+
nonIncrementalOutput := strings.Join(nonIncrementalSys.output, "")
165+
if incrementalOutput != nonIncrementalOutput {
166+
diffBuilder.WriteString(baseline.DiffText("nonIncremental.output.txt", "incremental.output.txt", nonIncrementalOutput, incrementalOutput))
159167
}
160168
return diffBuilder.String()
161169
}

testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file-through-indirect-import.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ Diff:: Currently there is issue with d.ts emit for export default = 1 to widen i
299299
@@ -1,1 +1,1 @@
300300
-declare const a = 2;
301301
+declare const a = 1;
302-
--- nonIncremental errors.txt
303-
+++ incremental errors.txt
302+
--- nonIncremental.output.txt
303+
+++ incremental.output.txt
304304
@@ -1,7 +0,0 @@
305305
-class1.ts:1:7 - error TS2322: Type '1' is not assignable to type '2'.
306306
-

testdata/baselines/reference/tsc/incremental/change-to-type-that-gets-used-as-global-through-export-in-another-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ Diff:: Currently there is issue with d.ts emit for export default = 1 to widen i
249249
@@ -1,1 +1,1 @@
250250
-declare const a = 2;
251251
+declare const a = 1;
252-
--- nonIncremental errors.txt
253-
+++ incremental errors.txt
252+
--- nonIncremental.output.txt
253+
+++ incremental.output.txt
254254
@@ -1,7 +0,0 @@
255255
-class1.ts:1:7 - error TS2322: Type '1' is not assignable to type '2'.
256256
-

0 commit comments

Comments
 (0)