diff --git a/.vscode/launch.template.json b/.vscode/launch.template.json index 81fe0ec776..769898213b 100644 --- a/.vscode/launch.template.json +++ b/.vscode/launch.template.json @@ -17,6 +17,17 @@ ], "autoAttachChildProcesses": true, "preLaunchTask": "Watch for extension run" + }, + { + "name": "Launch submodule test", + "type": "go", + "request": "launch", + "mode": "test", + "program": "${workspaceFolder}/internal/testrunner", + "args": [ + "-test.run", + "TestSubmodule/${fileBasename}" + ] } ] } diff --git a/internal/testutil/runner/compiler_runner.go b/internal/testrunner/compiler_runner.go similarity index 100% rename from internal/testutil/runner/compiler_runner.go rename to internal/testrunner/compiler_runner.go diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go new file mode 100644 index 0000000000..910e00b942 --- /dev/null +++ b/internal/testrunner/compiler_runner_test.go @@ -0,0 +1,50 @@ +package runner + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/bundled" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/repo" + "github.com/microsoft/typescript-go/internal/tspath" + "gotest.tools/v3/assert" +) + +// Runs the new compiler tests and produces baselines (e.g. `test1.symbols`). +func TestLocal(t *testing.T) { runCompilerTests(t, false) } //nolint:paralleltest + +// Runs the old compiler tests, and produces new baselines (e.g. `test1.symbols`) +// and a diff between the new and old baselines (e.g. `test1.symbols.diff`). +func TestSubmodule(t *testing.T) { runCompilerTests(t, true) } //nolint:paralleltest + +func runCompilerTests(t *testing.T, isSubmodule bool) { + t.Parallel() + + if isSubmodule { + repo.SkipIfNoTypeScriptSubmodule(t) + } + + if !bundled.Embedded { + // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. + // Just skip this for now. + t.Skip("bundled files are not embedded") + } + + runners := []*CompilerBaselineRunner{ + NewCompilerBaselineRunner(TestTypeRegression, isSubmodule), + NewCompilerBaselineRunner(TestTypeConformance, isSubmodule), + } + + var seenTests core.Set[string] + for _, runner := range runners { + for _, test := range runner.EnumerateTestFiles() { + test = tspath.GetBaseFileName(test) + assert.Assert(t, !seenTests.Has(test), "Duplicate test file: %s", test) + seenTests.Add(test) + } + } + + for _, runner := range runners { + runner.RunTests(t) + } +} diff --git a/internal/testutil/runner/runner.go b/internal/testrunner/runner.go similarity index 100% rename from internal/testutil/runner/runner.go rename to internal/testrunner/runner.go diff --git a/internal/testutil/runner/test_case_parser.go b/internal/testrunner/test_case_parser.go similarity index 100% rename from internal/testutil/runner/test_case_parser.go rename to internal/testrunner/test_case_parser.go diff --git a/internal/testutil/runner/test_case_parser_test.go b/internal/testrunner/test_case_parser_test.go similarity index 100% rename from internal/testutil/runner/test_case_parser_test.go rename to internal/testrunner/test_case_parser_test.go diff --git a/internal/testutil/runner/compiler_runner_test.go b/internal/testutil/runner/compiler_runner_test.go deleted file mode 100644 index 6f212417d4..0000000000 --- a/internal/testutil/runner/compiler_runner_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package runner - -import ( - "testing" - - "github.com/microsoft/typescript-go/internal/bundled" - "github.com/microsoft/typescript-go/internal/repo" -) - -// Runs the new compiler tests and produces baselines (e.g. `test1.symbols`). -func TestCompilerBaselinesLocal(t *testing.T) { - t.Parallel() - - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - - testTypes := []CompilerTestType{TestTypeRegression, TestTypeConformance} - for _, testType := range testTypes { - t.Run(testType.String(), func(t *testing.T) { - t.Parallel() - runner := NewCompilerBaselineRunner(testType, false /*isSubmodule*/) - runner.RunTests(t) - }) - } -} - -// Runs the old compiler tests, and produces new baselines (e.g. `test1.symbols`) -// and a diff between the new and old baselines (e.g. `test1.symbols.diff`). -func TestCompilerBaselinesSubmodule(t *testing.T) { - t.Parallel() - repo.SkipIfNoTypeScriptSubmodule(t) - - if !bundled.Embedded { - // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. - // Just skip this for now. - t.Skip("bundled files are not embedded") - } - - testTypes := []CompilerTestType{TestTypeRegression, TestTypeConformance} - for _, testType := range testTypes { - t.Run(testType.String(), func(t *testing.T) { - t.Parallel() - runner := NewCompilerBaselineRunner(testType, true /*isSubmodule*/) - runner.RunTests(t) - }) - } -}