|
| 1 | +import { expect } from 'vitest' |
| 2 | + |
| 3 | +import { isDebug, sandboxTest } from './setup' |
| 4 | + |
| 5 | +// Skip these tests in debug mode — the pwd and user in the testing docker container |
| 6 | +// are not the same as in the actual sandbox. |
| 7 | + |
| 8 | +sandboxTest.skipIf(isDebug)('cwd python', async ({ sandbox }) => { |
| 9 | + const result = await sandbox.runCode( |
| 10 | + 'from pathlib import Path; print(Path.cwd())', |
| 11 | + { language: 'python' } |
| 12 | + ) |
| 13 | + expect(result.logs.stdout.join().trim()).toEqual('/home/user') |
| 14 | +}) |
| 15 | + |
| 16 | +sandboxTest.skipIf(isDebug)('cwd javascript', async ({ sandbox }) => { |
| 17 | + const result = await sandbox.runCode('process.cwd()', { |
| 18 | + language: 'js', |
| 19 | + }) |
| 20 | + expect(result.text).toEqual('/home/user') |
| 21 | +}) |
| 22 | + |
| 23 | +sandboxTest.skipIf(isDebug)('cwd typescript', async ({ sandbox }) => { |
| 24 | + const result = await sandbox.runCode('process.cwd()', { |
| 25 | + language: 'ts', |
| 26 | + }) |
| 27 | + expect(result.text).toEqual('/home/user') |
| 28 | +}) |
| 29 | + |
| 30 | +sandboxTest.skipIf(isDebug)('cwd r', async ({ sandbox }) => { |
| 31 | + const result = await sandbox.runCode('getwd()', { |
| 32 | + language: 'r', |
| 33 | + }) |
| 34 | + expect(result.results[0]?.text.trim()).toEqual('[1] "/home/user"') |
| 35 | +}) |
| 36 | + |
| 37 | +sandboxTest.skipIf(isDebug)('cwd java', async ({ sandbox }) => { |
| 38 | + const result = await sandbox.runCode('System.getProperty("user.dir")', { |
| 39 | + language: 'java', |
| 40 | + }) |
| 41 | + expect(result.results[0]?.text.trim()).toEqual('/home/user') |
| 42 | +}) |
0 commit comments