From ae4b44f62691c91b38685485aaa8dff598778661 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:21:29 -0700 Subject: [PATCH 1/8] Move internal/testutil/runner to internal/testrunner --- internal/{testutil/runner => testrunner}/compiler_runner.go | 0 internal/{testutil/runner => testrunner}/compiler_runner_test.go | 0 internal/{testutil/runner => testrunner}/runner.go | 0 internal/{testutil/runner => testrunner}/test_case_parser.go | 0 internal/{testutil/runner => testrunner}/test_case_parser_test.go | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename internal/{testutil/runner => testrunner}/compiler_runner.go (100%) rename internal/{testutil/runner => testrunner}/compiler_runner_test.go (100%) rename internal/{testutil/runner => testrunner}/runner.go (100%) rename internal/{testutil/runner => testrunner}/test_case_parser.go (100%) rename internal/{testutil/runner => testrunner}/test_case_parser_test.go (100%) 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/testutil/runner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go similarity index 100% rename from internal/testutil/runner/compiler_runner_test.go rename to internal/testrunner/compiler_runner_test.go 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 From 7f3ebab9b6397d5847845e44653de474e61efff1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:22:55 -0700 Subject: [PATCH 2/8] Rename top level tests to be shorter --- internal/testrunner/compiler_runner_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go index 6f212417d4..16f764dbf5 100644 --- a/internal/testrunner/compiler_runner_test.go +++ b/internal/testrunner/compiler_runner_test.go @@ -8,7 +8,7 @@ import ( ) // Runs the new compiler tests and produces baselines (e.g. `test1.symbols`). -func TestCompilerBaselinesLocal(t *testing.T) { +func TestLocal(t *testing.T) { t.Parallel() if !bundled.Embedded { @@ -29,7 +29,7 @@ func TestCompilerBaselinesLocal(t *testing.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) { +func TestSubmodule(t *testing.T) { t.Parallel() repo.SkipIfNoTypeScriptSubmodule(t) From ccacd7bbbe4279545568b39828de65266b707348 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:23:06 -0700 Subject: [PATCH 3/8] Unnest different test types --- internal/testrunner/compiler_runner_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go index 16f764dbf5..041fae6dff 100644 --- a/internal/testrunner/compiler_runner_test.go +++ b/internal/testrunner/compiler_runner_test.go @@ -19,11 +19,8 @@ func TestLocal(t *testing.T) { 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) - }) + runner := NewCompilerBaselineRunner(testType, false /*isSubmodule*/) + runner.RunTests(t) } } @@ -41,10 +38,7 @@ func TestSubmodule(t *testing.T) { 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) - }) + runner := NewCompilerBaselineRunner(testType, true /*isSubmodule*/) + runner.RunTests(t) } } From 7a6410541abe8ce82d52dab2b53100145ff00866 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:55:37 -0700 Subject: [PATCH 4/8] Duplicate test checking, small refactor --- internal/testrunner/compiler_runner.go | 2 -- internal/testrunner/compiler_runner_test.go | 39 ++++++++++----------- internal/testrunner/runner.go | 14 -------- 3 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 internal/testrunner/runner.go diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index a1811bfeb5..52abec369e 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -56,8 +56,6 @@ type CompilerBaselineRunner struct { testSuitName string } -var _ Runner = (*CompilerBaselineRunner)(nil) - func NewCompilerBaselineRunner(testType CompilerTestType, isSubmodule bool) *CompilerBaselineRunner { testSuitName := testType.String() var basePath string diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go index 041fae6dff..de7fc0144b 100644 --- a/internal/testrunner/compiler_runner_test.go +++ b/internal/testrunner/compiler_runner_test.go @@ -4,11 +4,18 @@ import ( "testing" "github.com/microsoft/typescript-go/internal/bundled" - "github.com/microsoft/typescript-go/internal/repo" + "github.com/microsoft/typescript-go/internal/core" + "gotest.tools/v3/assert" ) // Runs the new compiler tests and produces baselines (e.g. `test1.symbols`). -func TestLocal(t *testing.T) { +func TestLocal(t *testing.T) { runTests(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) { runTests(t, true) } //nolint:paralleltest + +func runTests(t *testing.T, isSubmodule bool) { t.Parallel() if !bundled.Embedded { @@ -17,28 +24,20 @@ func TestLocal(t *testing.T) { t.Skip("bundled files are not embedded") } - testTypes := []CompilerTestType{TestTypeRegression, TestTypeConformance} - for _, testType := range testTypes { - runner := NewCompilerBaselineRunner(testType, false /*isSubmodule*/) - runner.RunTests(t) + runners := []*CompilerBaselineRunner{ + NewCompilerBaselineRunner(TestTypeRegression, isSubmodule), + NewCompilerBaselineRunner(TestTypeConformance, isSubmodule), } -} - -// 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) { - 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") + var seenTests core.Set[string] + for _, runner := range runners { + for _, test := range runner.EnumerateTestFiles() { + assert.Assert(t, !seenTests.Has(test), "Duplicate test file: %s", test) + seenTests.Add(test) + } } - testTypes := []CompilerTestType{TestTypeRegression, TestTypeConformance} - for _, testType := range testTypes { - runner := NewCompilerBaselineRunner(testType, true /*isSubmodule*/) + for _, runner := range runners { runner.RunTests(t) } } diff --git a/internal/testrunner/runner.go b/internal/testrunner/runner.go deleted file mode 100644 index f50d4f98c2..0000000000 --- a/internal/testrunner/runner.go +++ /dev/null @@ -1,14 +0,0 @@ -package runner - -import "testing" - -type Runner interface { - EnumerateTestFiles() []string - RunTests(t *testing.T) -} - -func runTests(t *testing.T, runners []Runner) { - for _, runner := range runners { - runner.RunTests(t) - } -} From 155ec0b34c1ec2f442a69f0976e82e6d810c5d81 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 13 Mar 2025 19:59:46 -0700 Subject: [PATCH 5/8] Restore missing submodule check --- internal/testrunner/compiler_runner_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go index de7fc0144b..5ffc888416 100644 --- a/internal/testrunner/compiler_runner_test.go +++ b/internal/testrunner/compiler_runner_test.go @@ -5,6 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/bundled" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/repo" "gotest.tools/v3/assert" ) @@ -18,6 +19,10 @@ func TestSubmodule(t *testing.T) { runTests(t, true) } //nolint:paralleltest func runTests(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. From 27089bea1996424bd0e1c223e6ff5687839ae621 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:41:07 -0700 Subject: [PATCH 6/8] Restore code --- internal/testrunner/compiler_runner.go | 2 ++ internal/testrunner/compiler_runner_test.go | 6 +++--- internal/testrunner/runner.go | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 internal/testrunner/runner.go diff --git a/internal/testrunner/compiler_runner.go b/internal/testrunner/compiler_runner.go index 52abec369e..a1811bfeb5 100644 --- a/internal/testrunner/compiler_runner.go +++ b/internal/testrunner/compiler_runner.go @@ -56,6 +56,8 @@ type CompilerBaselineRunner struct { testSuitName string } +var _ Runner = (*CompilerBaselineRunner)(nil) + func NewCompilerBaselineRunner(testType CompilerTestType, isSubmodule bool) *CompilerBaselineRunner { testSuitName := testType.String() var basePath string diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go index 5ffc888416..7142a69de5 100644 --- a/internal/testrunner/compiler_runner_test.go +++ b/internal/testrunner/compiler_runner_test.go @@ -10,13 +10,13 @@ import ( ) // Runs the new compiler tests and produces baselines (e.g. `test1.symbols`). -func TestLocal(t *testing.T) { runTests(t, false) } //nolint:paralleltest +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) { runTests(t, true) } //nolint:paralleltest +func TestSubmodule(t *testing.T) { runCompilerTests(t, true) } //nolint:paralleltest -func runTests(t *testing.T, isSubmodule bool) { +func runCompilerTests(t *testing.T, isSubmodule bool) { t.Parallel() if isSubmodule { diff --git a/internal/testrunner/runner.go b/internal/testrunner/runner.go new file mode 100644 index 0000000000..f50d4f98c2 --- /dev/null +++ b/internal/testrunner/runner.go @@ -0,0 +1,14 @@ +package runner + +import "testing" + +type Runner interface { + EnumerateTestFiles() []string + RunTests(t *testing.T) +} + +func runTests(t *testing.T, runners []Runner) { + for _, runner := range runners { + runner.RunTests(t) + } +} From 7068eae46c26225ccd9cf89c62b5537c1897da1b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 14 Mar 2025 10:47:54 -0700 Subject: [PATCH 7/8] oops, base file name --- internal/testrunner/compiler_runner_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/testrunner/compiler_runner_test.go b/internal/testrunner/compiler_runner_test.go index 7142a69de5..910e00b942 100644 --- a/internal/testrunner/compiler_runner_test.go +++ b/internal/testrunner/compiler_runner_test.go @@ -6,6 +6,7 @@ import ( "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" ) @@ -37,6 +38,7 @@ func runCompilerTests(t *testing.T, isSubmodule bool) { 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) } From f1891c0afba42dd39ffa6c2c27267594a0ab3ea3 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 14 Mar 2025 11:02:28 -0700 Subject: [PATCH 8/8] Add launch task --- .vscode/launch.template.json | 11 +++++++++++ 1 file changed, 11 insertions(+) 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}" + ] } ] }