diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f9e8fe8e..bef8f17d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -98,6 +98,8 @@ jobs: shell: bash - name: Run tests + env: + MANIM_NOTEBOOK_TEST_CLIPBOARD_TIMEOUT_MS: "3000" run: | if [ "$RUNNER_OS" == "Linux" ]; then # Start an X virtual framebuffer (Xvfb) server, which emulates a diff --git a/tests/preview.test.ts b/tests/preview.test.ts index fef58efd..eda96791 100644 --- a/tests/preview.test.ts +++ b/tests/preview.test.ts @@ -29,7 +29,12 @@ describe("Previewing", function () { }); }); - it("Can preview laggy scene", async () => { + it("Can preview laggy scene", async function () { + if (process.env.CI === "true" && process.platform === "linux") { + // Linux CI runners can be significantly slower for this GPU-heavy scene + this.timeout(120_000); + } + const editor = await window.showTextDocument(uriInWorkspace("laggy.py")); const queue: { line: number; waitForStrings: string[]; resolve: () => void }[] = []; let wantToStopListening = false; @@ -40,7 +45,8 @@ describe("Previewing", function () { return; } if (queue.length === 0) { - throw new Error("Listening to terminal output, but nothing in queue to check against"); + // Ignore unrelated output from concurrent terminal activity + return; } const { waitForStrings } = queue[0]; @@ -56,10 +62,13 @@ describe("Previewing", function () { async function testPreviewAtLine(line: number, waitForStrings: string[]) { goToLine(editor, line); - await commands.executeCommand("manim-notebook.previewManimCell"); - await new Promise((resolve) => { - queue.push({ line, waitForStrings, resolve }); + + const done = new Promise((resolve) => { + queue.push({ line, waitForStrings: [...waitForStrings], resolve }); }); + + await commands.executeCommand("manim-notebook.previewManimCell"); + await done; } await testPreviewAtLine(8, ["ShowCreationVGroup", "In [2]:"]); diff --git a/tests/utils/manimInstaller.ts b/tests/utils/manimInstaller.ts index 7e207ca4..c677d9a8 100644 --- a/tests/utils/manimInstaller.ts +++ b/tests/utils/manimInstaller.ts @@ -138,6 +138,9 @@ export class ManimInstaller { await this.runWithVenvBin("pip install PyOpenGL"); } + // Remove once this is merged: https://github.com/3b1b/manim/pull/2439/ + await this.runWithVenvBin("pip install trimesh pywavefront"); + console.log("🔧 Additional dependencies successfully installed"); } diff --git a/tests/utils/testRunner.ts b/tests/utils/testRunner.ts index 3d159910..b1d32fa2 100644 --- a/tests/utils/testRunner.ts +++ b/tests/utils/testRunner.ts @@ -19,7 +19,7 @@ import * as path from "path"; import "source-map-support/register"; import "./prototype"; -import { Uri, extensions, window, workspace } from "vscode"; +import { ConfigurationTarget, Uri, extensions, window, workspace } from "vscode"; const WORKSPACE_ROOT: string = workspace.workspaceFolders![0].uri.fsPath; @@ -68,6 +68,8 @@ export function run(): Promise { console.log("💠 Tests requested via npm script"); } + await configureClipboardTimeoutForCI(); + // open any python file to trigger extension activation await window.showTextDocument(uriInWorkspace("basic.py")); @@ -95,6 +97,26 @@ export function run(): Promise { }); } +/** + * In CI, test execution can be slower and restoring clipboard contents may + * race with command handling. Increase timeout to reduce flaky tests. + */ +async function configureClipboardTimeoutForCI(): Promise { + if (process.env.CI !== "true") { + return; + } + + const timeoutMs = Number(process.env.MANIM_NOTEBOOK_TEST_CLIPBOARD_TIMEOUT_MS ?? "2000"); + if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) { + throw new Error("MANIM_NOTEBOOK_TEST_CLIPBOARD_TIMEOUT_MS must be a positive number"); + } + + await workspace + .getConfiguration("manim-notebook") + .update("clipboardTimeout", timeoutMs, ConfigurationTarget.Workspace); + console.log(`💠 CI override: manim-notebook.clipboardTimeout=${timeoutMs}ms`); +} + /** * Waits until the Manim Notebook extension is activated. */