diff --git a/packages/pyright-internal/src/common/chokidarFileWatcherProvider.ts b/packages/pyright-internal/src/common/chokidarFileWatcherProvider.ts index 78f7ae647..4bede8c2f 100644 --- a/packages/pyright-internal/src/common/chokidarFileWatcherProvider.ts +++ b/packages/pyright-internal/src/common/chokidarFileWatcherProvider.ts @@ -44,7 +44,7 @@ export class ChokidarFileWatcherProvider implements FileWatcherProvider { watcherOptions.usePolling = false; } - const excludes: string[] = ['**/node_modules', '**/__pycache__', '**/.*']; + const excludes: string[] = ['**/node_modules/**', '**/__pycache__/**', '**/.*']; if (_isMacintosh || _isLinux) { if (paths.some((path) => path === '' || path === '/')) { excludes.push('/dev/**'); diff --git a/packages/pyright-internal/src/tests/languageServer.test.ts b/packages/pyright-internal/src/tests/languageServer.test.ts index 1d99a7096..bdc623954 100644 --- a/packages/pyright-internal/src/tests/languageServer.test.ts +++ b/packages/pyright-internal/src/tests/languageServer.test.ts @@ -182,12 +182,12 @@ describe(`Basic language server tests`, () => { await openFile(info, 'marker'); // Wait for the diagnostics to publish - const diagnostics = await waitForDiagnostics(info); + const diagnostics = await waitForDiagnostics(info, 6); assert.equal(diagnostics[0]!.diagnostics.length, 6); // Make sure the error has a special rule assert.equal(diagnostics[0].diagnostics[1].code, 'pyright[reportUnusedImport]'); assert.equal(diagnostics[0].diagnostics[3].code, 'ruff[F401]'); assert.equal(diagnostics[0].diagnostics[5].code, 'ruff[F401]'); - }); + }, 10000); }); diff --git a/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts b/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts index 94900f7be..695938a09 100644 --- a/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts +++ b/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts @@ -265,16 +265,26 @@ function createServerConnection(testServerData: CustomLSP.TestServerStartOptions return connection; } -export async function waitForDiagnostics(info: PyrightServerInfo, timeout = 10000) { +export async function waitForDiagnostics(info: PyrightServerInfo, expectedCount: number, timeout = 10000) { const deferred = createDeferred(); + // Replit(dstewart): We've got a bit of an issue with the Windows CI job. + // A bit of a Schrodinger's bug situation, since adding console.log seems + // to add just enough latency to cause the tests to pass. I presume that + // what we're seeing is we're getting two responses, first with 3 responses, + // then immediately after one with six responses. + const responseLengths: number[] = []; const disposable = info.diagnosticsEvent((params) => { if (params.diagnostics.length > 0) { + responseLengths.push(params.diagnostics.length); + } + if (params.diagnostics.length === expectedCount) { deferred.resolve(); } }); const timer = setTimeout(() => deferred.reject('Timed out waiting for diagnostics'), timeout); try { await deferred.promise; + assert.equal(responseLengths.length, 1, 'We had more than one result! ' + JSON.stringify(responseLengths)); } finally { clearTimeout(timer); disposable.dispose();