Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

test: skip the deprecated git suites unless ENABLE_GIT_TESTS is set (#1863)

devin-ai-integration[bot]804021ee5dda
diff --git a/packages/js-sdk/tests/sandbox/git/add.test.ts b/packages/js-sdk/tests/sandbox/git/add.test.ts
index 4336c39e8..f554b0c4d 100644
--- a/packages/js-sdk/tests/sandbox/git/add.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/add.test.ts
@@ -1,9 +1,9 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import { cleanupBaseDir, createBaseDir, createRepo } from './helpers.js'
-sandboxTest('git add stages files', async ({ sandbox }) => {
+gitTest('git add stages files', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
diff --git a/packages/js-sdk/tests/sandbox/git/branches.test.ts b/packages/js-sdk/tests/sandbox/git/branches.test.ts
index f3ed3286e..337733185 100644
--- a/packages/js-sdk/tests/sandbox/git/branches.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/branches.test.ts
@@ -1,13 +1,13 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
} from './helpers.js'
-sandboxTest('git branches lists current and feature', async ({ sandbox }) => {
+gitTest('git branches lists current and feature', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -23,7 +23,7 @@ sandboxTest('git branches lists current and feature', async ({ sandbox }) => {
}
})
-sandboxTest('git checkoutBranch switches branch', async ({ sandbox }) => {
+gitTest('git checkoutBranch switches branch', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -43,7 +43,7 @@ sandboxTest('git checkoutBranch switches branch', async ({ sandbox }) => {
}
})
-sandboxTest(
+gitTest(
'git createBranch creates and checks out branch',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
@@ -61,7 +61,7 @@ sandboxTest(
}
)
-sandboxTest('git deleteBranch removes branch', async ({ sandbox }) => {
+gitTest('git deleteBranch removes branch', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
diff --git a/packages/js-sdk/tests/sandbox/git/clone.test.ts b/packages/js-sdk/tests/sandbox/git/clone.test.ts
index d09cac8e4..f9f4a020f 100644
--- a/packages/js-sdk/tests/sandbox/git/clone.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/clone.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
@@ -8,7 +8,7 @@ import {
startGitDaemon,
} from './helpers.js'
-sandboxTest('git clone fetches repo', async ({ sandbox }) => {
+gitTest('git clone fetches repo', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
diff --git a/packages/js-sdk/tests/sandbox/git/commit.test.ts b/packages/js-sdk/tests/sandbox/git/commit.test.ts
index 5e973028a..3e91a8944 100644
--- a/packages/js-sdk/tests/sandbox/git/commit.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/commit.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
@@ -9,7 +9,7 @@ import {
createRepo,
} from './helpers.js'
-sandboxTest('git commit creates commit', async ({ sandbox }) => {
+gitTest('git commit creates commit', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -31,7 +31,7 @@ sandboxTest('git commit creates commit', async ({ sandbox }) => {
}
})
-sandboxTest(
+gitTest(
'git commit uses config for missing author fields',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
diff --git a/packages/js-sdk/tests/sandbox/git/config.test.ts b/packages/js-sdk/tests/sandbox/git/config.test.ts
index 41707150e..b4b08bc23 100644
--- a/packages/js-sdk/tests/sandbox/git/config.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/config.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
@@ -9,7 +9,7 @@ import {
createRepo,
} from './helpers.js'
-sandboxTest('git getConfig reads local config', async ({ sandbox }) => {
+gitTest('git getConfig reads local config', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -34,7 +34,7 @@ sandboxTest('git getConfig reads local config', async ({ sandbox }) => {
}
})
-sandboxTest('git setConfig updates local config', async ({ sandbox }) => {
+gitTest('git setConfig updates local config', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -61,27 +61,24 @@ sandboxTest('git setConfig updates local config', async ({ sandbox }) => {
}
})
-sandboxTest(
- 'git configureUser sets global user config',
- async ({ sandbox }) => {
- await sandbox.git.configureUser(AUTHOR_NAME, AUTHOR_EMAIL)
+gitTest('git configureUser sets global user config', async ({ sandbox }) => {
+ await sandbox.git.configureUser(AUTHOR_NAME, AUTHOR_EMAIL)
- const name = (
- await sandbox.commands.run('git config --global --get user.name')
- ).stdout.trim()
- const email = (
- await sandbox.commands.run('git config --global --get user.email')
- ).stdout.trim()
- const configuredName = await sandbox.git.getConfig('user.name', {
- scope: 'global',
- })
- const configuredEmail = await sandbox.git.getConfig('user.email', {
- scope: 'global',
- })
+ const name = (
+ await sandbox.commands.run('git config --global --get user.name')
+ ).stdout.trim()
+ const email = (
+ await sandbox.commands.run('git config --global --get user.email')
+ ).stdout.trim()
+ const configuredName = await sandbox.git.getConfig('user.name', {
+ scope: 'global',
+ })
+ const configuredEmail = await sandbox.git.getConfig('user.email', {
+ scope: 'global',
+ })
- expect(name).toBe(AUTHOR_NAME)
- expect(email).toBe(AUTHOR_EMAIL)
- expect(configuredName).toBe(AUTHOR_NAME)
- expect(configuredEmail).toBe(AUTHOR_EMAIL)
- }
-)
+ expect(name).toBe(AUTHOR_NAME)
+ expect(email).toBe(AUTHOR_EMAIL)
+ expect(configuredName).toBe(AUTHOR_NAME)
+ expect(configuredEmail).toBe(AUTHOR_EMAIL)
+})
diff --git a/packages/js-sdk/tests/sandbox/git/dangerouslyAuthenticate.test.ts b/packages/js-sdk/tests/sandbox/git/dangerouslyAuthenticate.test.ts
index 1c6c38225..681015bb2 100644
--- a/packages/js-sdk/tests/sandbox/git/dangerouslyAuthenticate.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/dangerouslyAuthenticate.test.ts
@@ -1,9 +1,9 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import { HOST, PASSWORD, PROTOCOL, USERNAME } from './helpers.js'
-sandboxTest('git dangerouslyAuthenticate sets helper', async ({ sandbox }) => {
+gitTest('git dangerouslyAuthenticate sets helper', async ({ sandbox }) => {
await sandbox.git.dangerouslyAuthenticate({
username: USERNAME,
password: PASSWORD,
diff --git a/packages/js-sdk/tests/sandbox/git/helpers.test.ts b/packages/js-sdk/tests/sandbox/git/helpers.test.ts
index d20d0c68c..0f363be2b 100644
--- a/packages/js-sdk/tests/sandbox/git/helpers.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/helpers.test.ts
@@ -1,8 +1,9 @@
import { describe, expect, test, vi } from 'vitest'
+import { isGitTestsEnabled } from '../../setup.js'
import { cleanupBaseDir } from './helpers.js'
-describe('cleanupBaseDir', () => {
+describe.skipIf(!isGitTestsEnabled)('cleanupBaseDir', () => {
test('retries a Cloudflare dropped connection once', async () => {
const run = vi
.fn()
diff --git a/packages/js-sdk/tests/sandbox/git/init.test.ts b/packages/js-sdk/tests/sandbox/git/init.test.ts
index dfc2949da..7d8f7baaf 100644
--- a/packages/js-sdk/tests/sandbox/git/init.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/init.test.ts
@@ -1,9 +1,9 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import { cleanupBaseDir, createBaseDir } from './helpers.js'
-sandboxTest('git init', async ({ sandbox }) => {
+gitTest('git init', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
diff --git a/packages/js-sdk/tests/sandbox/git/remote.test.ts b/packages/js-sdk/tests/sandbox/git/remote.test.ts
index fdf6fc40d..38e10965c 100644
--- a/packages/js-sdk/tests/sandbox/git/remote.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/remote.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
@@ -8,7 +8,7 @@ import {
startGitDaemon,
} from './helpers.js'
-sandboxTest(
+gitTest(
'git remoteGet returns undefined for missing remote',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
@@ -23,7 +23,7 @@ sandboxTest(
}
)
-sandboxTest('git remoteAdd adds remote', async ({ sandbox }) => {
+gitTest('git remoteAdd adds remote', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -42,7 +42,7 @@ sandboxTest('git remoteAdd adds remote', async ({ sandbox }) => {
}
})
-sandboxTest('git remoteAdd overwrites existing remote', async ({ sandbox }) => {
+gitTest('git remoteAdd overwrites existing remote', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
diff --git a/packages/js-sdk/tests/sandbox/git/reset.test.ts b/packages/js-sdk/tests/sandbox/git/reset.test.ts
index a23e1bae0..5fe1d41a9 100644
--- a/packages/js-sdk/tests/sandbox/git/reset.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/reset.test.ts
@@ -1,13 +1,13 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
} from './helpers.js'
-sandboxTest(
+gitTest(
'git reset --hard discards changes',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
diff --git a/packages/js-sdk/tests/sandbox/git/restore.test.ts b/packages/js-sdk/tests/sandbox/git/restore.test.ts
index 2d03484ab..67e60ad1a 100644
--- a/packages/js-sdk/tests/sandbox/git/restore.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/restore.test.ts
@@ -1,13 +1,13 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
} from './helpers.js'
-sandboxTest('git restore --staged unstages changes', async ({ sandbox }) => {
+gitTest('git restore --staged unstages changes', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -32,27 +32,24 @@ sandboxTest('git restore --staged unstages changes', async ({ sandbox }) => {
}
})
-sandboxTest(
- 'git restore discards working tree changes',
- async ({ sandbox }) => {
- const baseDir = await createBaseDir(sandbox)
+gitTest('git restore discards working tree changes', async ({ sandbox }) => {
+ const baseDir = await createBaseDir(sandbox)
- try {
- const repoPath = await createRepoWithCommit(sandbox, baseDir)
- await sandbox.files.write(`${repoPath}/README.md`, 'changed\n')
+ try {
+ const repoPath = await createRepoWithCommit(sandbox, baseDir)
+ await sandbox.files.write(`${repoPath}/README.md`, 'changed\n')
- const status = await sandbox.git.status(repoPath)
- expect(status.isClean).toBe(false)
+ const status = await sandbox.git.status(repoPath)
+ expect(status.isClean).toBe(false)
- await sandbox.git.restore(repoPath, { paths: ['README.md'] })
+ await sandbox.git.restore(repoPath, { paths: ['README.md'] })
- const statusAfter = await sandbox.git.status(repoPath)
- expect(statusAfter.isClean).toBe(true)
+ const statusAfter = await sandbox.git.status(repoPath)
+ expect(statusAfter.isClean).toBe(true)
- const contents = await sandbox.files.read(`${repoPath}/README.md`)
- expect(contents).toBe('hello\n')
- } finally {
- await cleanupBaseDir(sandbox, baseDir)
- }
+ const contents = await sandbox.files.read(`${repoPath}/README.md`)
+ expect(contents).toBe('hello\n')
+ } finally {
+ await cleanupBaseDir(sandbox, baseDir)
}
-)
+})
diff --git a/packages/js-sdk/tests/sandbox/git/status.test.ts b/packages/js-sdk/tests/sandbox/git/status.test.ts
index bbae9495d..009e49ce7 100644
--- a/packages/js-sdk/tests/sandbox/git/status.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/status.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
@@ -9,7 +9,7 @@ import {
createRepo,
} from './helpers.js'
-sandboxTest('git status reports untracked file', async ({ sandbox }) => {
+gitTest('git status reports untracked file', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -36,7 +36,7 @@ sandboxTest('git status reports untracked file', async ({ sandbox }) => {
}
})
-sandboxTest(
+gitTest(
'git status reports added modified deleted renamed',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
diff --git a/packages/js-sdk/tests/sandbox/git/sync.test.ts b/packages/js-sdk/tests/sandbox/git/sync.test.ts
index f51b5efad..9e2fe5259 100644
--- a/packages/js-sdk/tests/sandbox/git/sync.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/sync.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
-import { sandboxTest } from '../../setup.js'
+import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
@@ -10,7 +10,7 @@ import {
startGitDaemon,
} from './helpers.js'
-sandboxTest('git push updates remote', async ({ sandbox }) => {
+gitTest('git push updates remote', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -38,7 +38,7 @@ sandboxTest('git push updates remote', async ({ sandbox }) => {
}
})
-sandboxTest('git push warns when no upstream', async ({ sandbox }) => {
+gitTest('git push warns when no upstream', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -59,7 +59,7 @@ sandboxTest('git push warns when no upstream', async ({ sandbox }) => {
}
})
-sandboxTest('git pull updates clone', async ({ sandbox }) => {
+gitTest('git pull updates clone', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
@@ -94,7 +94,7 @@ sandboxTest('git pull updates clone', async ({ sandbox }) => {
}
})
-sandboxTest('git pull warns when no upstream', async ({ sandbox }) => {
+gitTest('git pull warns when no upstream', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
try {
diff --git a/packages/js-sdk/tests/sandbox/git/validation.test.ts b/packages/js-sdk/tests/sandbox/git/validation.test.ts
index 24bd2a919..3d425b8fc 100644
--- a/packages/js-sdk/tests/sandbox/git/validation.test.ts
+++ b/packages/js-sdk/tests/sandbox/git/validation.test.ts
@@ -1,5 +1,6 @@
-import { test, expect } from 'vitest'
+import { test as base, expect } from 'vitest'
+import { isGitTestsEnabled } from '../../setup.js'
import { Git } from '../../../src/sandbox/git'
import type { Commands } from '../../../src/sandbox/commands'
import { InvalidArgumentError } from '../../../src/errors'
@@ -12,6 +13,8 @@ const failingCommands = {
},
} as unknown as Commands
+const test = base.skipIf(!isGitTestsEnabled)
+
test('git.reset throws InvalidArgumentError on an invalid mode', async () => {
const git = new Git(failingCommands)
await expect(
diff --git a/packages/js-sdk/tests/setup.ts b/packages/js-sdk/tests/setup.ts
index dafe05b29..514f6c093 100644
--- a/packages/js-sdk/tests/setup.ts
+++ b/packages/js-sdk/tests/setup.ts
@@ -145,6 +145,11 @@ export const volumeTest = base.extend<VolumeFixture>({
export const isDebug = process.env.E2B_DEBUG !== undefined
+/** The sandbox `git` API is deprecated; its tests only run when opted in. */
+export const isGitTestsEnabled = process.env.ENABLE_GIT_TESTS !== undefined
+
+export const gitTest = sandboxTest.skipIf(!isGitTestsEnabled)
+
/** Placeholder API key with a valid format for tests that don't hit the API. */
export const TEST_API_KEY = `e2b_${'0'.repeat(40)}`
diff --git a/packages/python-sdk/tests/shared/git/conftest.py b/packages/python-sdk/tests/shared/git/conftest.py
index 7268f3613..c9ef48498 100644
--- a/packages/python-sdk/tests/shared/git/conftest.py
+++ b/packages/python-sdk/tests/shared/git/conftest.py
@@ -1,3 +1,4 @@
+import os
import random
from uuid import uuid4
@@ -6,6 +7,13 @@ import pytest
BASE_DIR = "/tmp/test-git"
[email protected](autouse=True)
+def skip_unless_git_tests_enabled():
+ """The sandbox `git` API is deprecated; its tests only run when opted in."""
+ if os.getenv("ENABLE_GIT_TESTS") is None:
+ pytest.skip("skipped because ENABLE_GIT_TESTS is not set")
+
+
@pytest.fixture
def git_sandbox(sandbox_factory):
# Git suites can cross the old 10-second lifetime while the live backend is