-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathcwd.test.ts
More file actions
42 lines (35 loc) · 1.29 KB
/
cwd.test.ts
File metadata and controls
42 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { expect } from 'vitest'
import { isDebug, sandboxTest } from './setup'
// Skip these tests in debug mode — the pwd and user in the testing docker container
// are not the same as in the actual sandbox.
sandboxTest.skipIf(isDebug)('cwd python', async ({ sandbox }) => {
const result = await sandbox.runCode(
'from pathlib import Path; print(Path.cwd())',
{ language: 'python' }
)
expect(result.logs.stdout.join().trim()).toEqual('/home/user')
})
sandboxTest.skipIf(isDebug)('cwd javascript', async ({ sandbox }) => {
const result = await sandbox.runCode('process.cwd()', {
language: 'js',
})
expect(result.text).toEqual('/home/user')
})
sandboxTest.skipIf(isDebug)('cwd typescript', async ({ sandbox }) => {
const result = await sandbox.runCode('process.cwd()', {
language: 'ts',
})
expect(result.text).toEqual('/home/user')
})
sandboxTest.skipIf(isDebug)('cwd r', async ({ sandbox }) => {
const result = await sandbox.runCode('getwd()', {
language: 'r',
})
expect(result.results[0]?.text.trim()).toEqual('[1] "/home/user"')
})
sandboxTest.skipIf(isDebug)('cwd java', async ({ sandbox }) => {
const result = await sandbox.runCode('System.getProperty("user.dir")', {
language: 'java',
})
expect(result.results[0]?.text.trim()).toEqual('/home/user')
})