Skip to content

Commit ef52e51

Browse files
committed
update tes
1 parent 9ea1981 commit ef52e51

13 files changed

+79
-31
lines changed

src/tasks/submission.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@ import { cat, exec, mkdir, rm } from 'shelljs'
33
import { SubmissionJob, SubmissionResult } from '../types/job'
44
import * as path from 'path'
55
import * as fs from 'fs'
6-
import http = require('http')
6+
import http from 'http'
77
import { Scenario } from 'types/scenario.js'
88

9-
rm('-rf', config.RUNBOX.DIR)
10-
mkdir('-p', config.RUNBOX.DIR)
9+
export const download = (url: string, dest: string): Promise<http.ClientRequest> => {
10+
const file = fs.createWriteStream(dest);
11+
return new Promise((resolve, reject) =>
12+
http.get(url, function(response) {
13+
response.pipe(file);
14+
file.on('finish', function() {
15+
resolve()
16+
});
17+
}).on('error', err => {
18+
reject(err)
19+
})
20+
)
21+
}
1122

1223
class SubmissionScenario implements Scenario {
1324
setup(currentJobDir: string, job: SubmissionJob) {

src/types/job.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ export interface SubmissionJob extends Job {
3939

4040
export interface SubmissionResult extends Result {
4141
testcases: Array<TestcaseResult>
42-
}
42+
}

test/run.c.spec.ts renamed to test/run/run.c.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - c', () => {
66
it('.c file runs correctly', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 19,
99
lang: 'c',
1010
source: (new Buffer(`
@@ -21,4 +21,4 @@ int main () {
2121
})
2222
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World')
2323
})
24-
})
24+
})

test/run.cpp.spec.ts renamed to test/run/run.cpp.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - cpp', () => {
66
it('.cpp file runs correctly', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 20,
99
lang: 'cpp',
1010
source: (new Buffer(`
@@ -21,4 +21,4 @@ int main () {
2121
})
2222
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World')
2323
})
24-
})
24+
})

test/run.csharp.spec.ts renamed to test/run/run.csharp.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - csharp', () => {
66
it('.cs file runs correctly', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 21,
99
lang: 'csharp',
1010
source: (new Buffer(`
@@ -20,4 +20,4 @@ public class HelloWorld {
2020
})
2121
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World\n')
2222
})
23-
})
23+
})

test/run.java8.spec.ts renamed to test/run/run.java8.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - java8', () => {
66
it('.java file runs correctly (Java8)', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 22,
99
lang: 'java8',
1010
source: (new Buffer(`
@@ -22,4 +22,4 @@ public class Main {
2222
})
2323
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World\n')
2424
})
25-
})
25+
})

test/run.nodejs10.spec.ts renamed to test/run/run.nodejs10.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - nodejs10', () => {
66
it('.js file runs correctly (NodeJS 6)', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 24,
99
lang: 'nodejs10',
1010
source: (new Buffer(`
@@ -24,4 +24,4 @@ rl.on('line', function (line) {
2424
})
2525
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World\n')
2626
})
27-
})
27+
})

test/run.nodejs8.spec.ts renamed to test/run/run.nodejs8.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - nodejs8', () => {
66
it('.js file runs correctly (NodeJS 8)', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 25,
99
lang: 'nodejs8',
1010
source: (new Buffer(`
@@ -24,4 +24,4 @@ rl.on('line', function (line) {
2424
})
2525
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World\n')
2626
})
27-
})
27+
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - py2', () => {
66
it('.py file runs correctly (Python 2.7)', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 23,
99
lang: 'py2',
1010
source: (new Buffer(`
@@ -15,4 +15,4 @@ print("Hello " + inp)
1515
})
1616
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World\n')
1717
})
18-
})
18+
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {execRun} from '../src/tasks/run'
1+
import {executor} from '../../src/tasks/'
22
import {expect} from 'chai'
33

44

55
describe('run - py3', () => {
66
it('.py file runs correctly (Python 3.0)', async () => {
7-
const runResult = await execRun({
7+
const runResult = await executor({
88
id: 26,
99
lang: 'py3',
1010
source: (new Buffer(`
@@ -15,4 +15,4 @@ print("Hello " + inp)
1515
})
1616
expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World\n')
1717
})
18-
})
18+
})

0 commit comments

Comments
 (0)