Skip to content

Commit f4f4592

Browse files
committed
add support for python project workers
1 parent e036bab commit f4f4592

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

config.js

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ exports = module.exports = {
1616
'nodejs': {
1717
CPU_SHARE: '1.2',
1818
MEM_LIMIT: '500m'
19+
},
20+
'python': {
21+
CPU_SHARE: '1.2',
22+
MEM_LIMIT: '500m'
1923
}
2024
},
2125
LANGS: {

src/tasks/scenarios/project.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export default class ProjectScenario extends Scenario {
4545
async result(currentJobDir: string, job: ProjectJob): Promise<ProjectResult> {
4646
const setup_stdout = cat(path.join(currentJobDir, 'setup.stdout')).toString()
4747
const setup_stderr = cat(path.join(currentJobDir, 'setup.stderr')).toString()
48+
const setup_code = cat(path.join(currentJobDir, 'setup.code')).toString()
4849

49-
if (setup_stderr) {
50+
if (setup_code !== '0') {
5051
return {
5152
id: job.id,
5253
scenario: 'project',

test/project/project.nodejs.spec.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ project:
2323
timelimit: 60
2424
}))
2525

26-
console.log(result)
27-
2826
// assertions
29-
expect(1).to.be.equal(1)
30-
// expect(submitResult.testcases[0].result).to.eq('Success')
27+
expect(result.testcases[0].score).to.eq(100)
3128
})
3229
})
3330

test/project/project.python.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { execute } from '../../src/tasks/'
2+
import { expect } from 'chai'
3+
import { ProjectJob } from "../../src/tasks/jobs/project"
4+
5+
describe('project - python', () => {
6+
it('nodejs project submits correctly', async () => {
7+
const result = await execute(new ProjectJob({
8+
id: 5,
9+
lang: 'python',
10+
source: 'https://minio.cb.lk/hackerblocks/python-solution.zip',
11+
problem: 'https://minio.cb.lk/hackerblocks/python-problem.zip',
12+
config: `
13+
project:
14+
allowed-folders:
15+
- main/
16+
before-test:
17+
- pip install -r requirements.txt
18+
testcases:
19+
- python manage.py test tests/*
20+
`,
21+
scenario: 'project',
22+
timelimit: 60
23+
}))
24+
25+
// assertions
26+
expect(result.testcases[0].score).to.eq(100)
27+
})
28+
})
29+

0 commit comments

Comments
 (0)