generated from csivitu/Template
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmaster.ts
More file actions
47 lines (41 loc) · 816 Bytes
/
master.ts
File metadata and controls
47 lines (41 loc) · 816 Bytes
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
43
44
45
46
47
import { CodeExecutor } from '../src';
import logger from '../src/utils/logger';
const codeExecutor = new CodeExecutor('myExecutor', 'redis://127.0.0.1:6379');
const pythonCode = `
import time
time.sleep(1)
print('hello')
`;
const bashCode = `
echo hello
`;
const inputs = [{
language: 'Python',
code: pythonCode,
testCases: [
{
input: '',
output: 'hello\n',
},
],
timeout: 2,
},
{
language: 'Bash',
code: bashCode,
testCases: [
{
input: '',
output: 'hello\n',
},
],
timeout: 2,
}];
async function main() {
const results = await Promise.all(
inputs.map((input) => codeExecutor.runCode(input)),
);
logger.info(JSON.stringify(results));
codeExecutor.stop();
}
main();