From 817f53d27ed43b83e0a75994ec902c2d170973e5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 28 Aug 2026 11:11:27 -0700 Subject: [PATCH] Make tsconfig move lifetime test deterministic --- tsc/internal/project/projectlifetime_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tsc/internal/project/projectlifetime_test.go b/tsc/internal/project/projectlifetime_test.go index 53f271a72f56b..8e9202e4b7518 100644 --- a/tsc/internal/project/projectlifetime_test.go +++ b/tsc/internal/project/projectlifetime_test.go @@ -364,6 +364,7 @@ func TestProjectLifetime(t *testing.T) { "include": ["src"] }`, "/home/projects/TS/p1/src/index.ts": `export const x = 1;`, + "/home/projects/TS/p1/src/other.ts": `export const y = 2;`, } session, utils := projecttestutil.Setup(files) @@ -398,11 +399,20 @@ func TestProjectLifetime(t *testing.T) { Type: lsproto.FileChangeTypeDeleted, }, }) + session.WaitForBackgroundTasks() - // Should now have one configured project only (tsconfig.json now includes src/index.ts) + // The background update should route index.ts to the new configured project, + // but project cleanup is deferred until the next file open. _, err = session.GetLanguageService(context.Background(), indexUri) assert.NilError(t, err) snapshot = session.Snapshot() + assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 2) + assert.Assert(t, snapshot.ProjectCollection.InferredProject() != nil) + assert.Equal(t, snapshot.GetDefaultProject(indexUri).Name(), "/home/projects/TS/p1/tsconfig.json") + + otherUri := lsproto.DocumentUri("file:///home/projects/TS/p1/src/other.ts") + session.DidOpenFile(context.Background(), otherUri, 1, files["/home/projects/TS/p1/src/other.ts"].(string), lsproto.LanguageKindTypeScript) + snapshot = session.Snapshot() assert.Equal(t, len(snapshot.ProjectCollection.Projects()), 1) assert.Assert(t, snapshot.ProjectCollection.InferredProject() == nil) assert.Assert(t, snapshot.ProjectCollection.ConfiguredProject(tspath.Path("/home/projects/ts/p1/tsconfig.json")) != nil)