|
| 1 | +package runner |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/microsoft/typescript-go/internal/bundled" |
| 7 | + "github.com/microsoft/typescript-go/internal/core" |
| 8 | + "github.com/microsoft/typescript-go/internal/repo" |
| 9 | + "github.com/microsoft/typescript-go/internal/tspath" |
| 10 | + "gotest.tools/v3/assert" |
| 11 | +) |
| 12 | + |
| 13 | +// Runs the new compiler tests and produces baselines (e.g. `test1.symbols`). |
| 14 | +func TestLocal(t *testing.T) { runCompilerTests(t, false) } //nolint:paralleltest |
| 15 | + |
| 16 | +// Runs the old compiler tests, and produces new baselines (e.g. `test1.symbols`) |
| 17 | +// and a diff between the new and old baselines (e.g. `test1.symbols.diff`). |
| 18 | +func TestSubmodule(t *testing.T) { runCompilerTests(t, true) } //nolint:paralleltest |
| 19 | + |
| 20 | +func runCompilerTests(t *testing.T, isSubmodule bool) { |
| 21 | + t.Parallel() |
| 22 | + |
| 23 | + if isSubmodule { |
| 24 | + repo.SkipIfNoTypeScriptSubmodule(t) |
| 25 | + } |
| 26 | + |
| 27 | + if !bundled.Embedded { |
| 28 | + // Without embedding, we'd need to read all of the lib files out from disk into the MapFS. |
| 29 | + // Just skip this for now. |
| 30 | + t.Skip("bundled files are not embedded") |
| 31 | + } |
| 32 | + |
| 33 | + runners := []*CompilerBaselineRunner{ |
| 34 | + NewCompilerBaselineRunner(TestTypeRegression, isSubmodule), |
| 35 | + NewCompilerBaselineRunner(TestTypeConformance, isSubmodule), |
| 36 | + } |
| 37 | + |
| 38 | + var seenTests core.Set[string] |
| 39 | + for _, runner := range runners { |
| 40 | + for _, test := range runner.EnumerateTestFiles() { |
| 41 | + test = tspath.GetBaseFileName(test) |
| 42 | + assert.Assert(t, !seenTests.Has(test), "Duplicate test file: %s", test) |
| 43 | + seenTests.Add(test) |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + for _, runner := range runners { |
| 48 | + runner.RunTests(t) |
| 49 | + } |
| 50 | +} |
0 commit comments