Skip to content

Commit 35a5221

Browse files
authored
Accurately recognize fourslash test as submodule (#2068)
1 parent fad2aa0 commit 35a5221

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed

internal/fourslash/baselineutil.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ func getBaselineExtension(command string) string {
5858
}
5959
}
6060

61-
func getBaselineOptions(command string) baseline.Options {
61+
func getBaselineOptions(command string, testPath string) baseline.Options {
6262
subfolder := "fourslash/" + normalizeCommandName(command)
63+
if !isSubmoduleTest(testPath) {
64+
return baseline.Options{
65+
Subfolder: subfolder,
66+
}
67+
}
6368
switch command {
6469
case "Smart Selection":
6570
return baseline.Options{
@@ -229,6 +234,10 @@ func getBaselineOptions(command string) baseline.Options {
229234
}
230235
}
231236

237+
func isSubmoduleTest(testPath string) bool {
238+
return strings.Contains(testPath, "fourslash/tests/gen") || strings.Contains(testPath, "fourslash/tests/manual")
239+
}
240+
232241
func normalizeCommandName(command string) string {
233242
words := strings.Fields(command)
234243
command = strings.Join(words, "")

internal/fourslash/fourslash.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"maps"
8+
"runtime"
89
"slices"
910
"strings"
1011
"testing"
@@ -203,9 +204,10 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten
203204
}
204205
f.activeFilename = f.testData.Files[0].fileName
205206

207+
_, testPath, _, _ := runtime.Caller(1)
206208
t.Cleanup(func() {
207209
inputWriter.Close()
208-
f.verifyBaselines(t)
210+
f.verifyBaselines(t, testPath)
209211
})
210212
return f
211213
}
@@ -2243,9 +2245,9 @@ func (f *FourslashTest) getRangeText(r *RangeMarker) string {
22432245
return script.content[r.Range.Pos():r.Range.End()]
22442246
}
22452247

2246-
func (f *FourslashTest) verifyBaselines(t *testing.T) {
2248+
func (f *FourslashTest) verifyBaselines(t *testing.T, testPath string) {
22472249
for command, content := range f.baselines {
2248-
baseline.Run(t, getBaselineFileName(t, command), content.String(), getBaselineOptions(command))
2250+
baseline.Run(t, getBaselineFileName(t, command), content.String(), getBaselineOptions(command, testPath))
22492251
}
22502252
}
22512253

testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline renamed to testdata/baselines/reference/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline

File renamed without changes.

testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline.diff

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)