Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions tests/preview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand All @@ -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<void>((resolve) => {
queue.push({ line, waitForStrings, resolve });

const done = new Promise<void>((resolve) => {
queue.push({ line, waitForStrings: [...waitForStrings], resolve });
});

await commands.executeCommand("manim-notebook.previewManimCell");
await done;
}

await testPreviewAtLine(8, ["ShowCreationVGroup", "In [2]:"]);
Expand Down
3 changes: 3 additions & 0 deletions tests/utils/manimInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
24 changes: 23 additions & 1 deletion tests/utils/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -68,6 +68,8 @@ export function run(): Promise<void> {
console.log("💠 Tests requested via npm script");
}

await configureClipboardTimeoutForCI();

// open any python file to trigger extension activation
await window.showTextDocument(uriInWorkspace("basic.py"));

Expand Down Expand Up @@ -95,6 +97,26 @@ export function run(): Promise<void> {
});
}

/**
* 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<void> {
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.
*/
Expand Down
Loading