Skip to content
This repository was archived by the owner on Nov 8, 2020. It is now read-only.

Commit 70f99cf

Browse files
committed
config
1 parent bf8631c commit 70f99cf

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

judger/case/yaml.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ const readAutoCases = require('./auto');
77

88
const fsp = fs.promises;
99

10-
module.exports = async function readYamlCases(folder, name, { next }) {
11-
const
12-
config = {
13-
checker_type: 'default',
14-
count: 0,
15-
subtasks: [],
16-
judge_extra_files: [],
17-
user_extra_files: [],
18-
};
10+
module.exports = async function readYamlCases(folder, name, args) {
11+
const config = {
12+
checker_type: 'default',
13+
count: 0,
14+
subtasks: [],
15+
judge_extra_files: [],
16+
user_extra_files: [],
17+
};
18+
const next = args.next;
1919
const checkFile = ensureFile(folder);
20-
let configFile = (await fsp.readFile(path.resolve(folder, name))).toString();
20+
let configFile = args.config || (await fsp.readFile(path.resolve(folder, name))).toString();
2121

2222
configFile = yaml.safeLoad(configFile);
2323
config.checker_type = configFile.checker_type || 'default';

judger/cases.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ async function readCases(folder, extra_config = {}, args) {
2525
const s = fs.statSync(path.resolve(folder, d[0]));
2626
if (s.isDirectory()) folder = path.resolve(folder, d[0]);
2727
}
28-
for (const [filename, handler] of map) {
29-
if (fs.existsSync(path.resolve(folder, filename))) {
30-
config = await handler(folder, filename, args); // eslint-disable-line no-await-in-loop
31-
break;
28+
if (args.config) {
29+
config = readYamlCases(folder, null, args);
30+
} else {
31+
for (const [filename, handler] of map) {
32+
if (fs.existsSync(path.resolve(folder, filename))) {
33+
// eslint-disable-next-line no-await-in-loop
34+
config = await handler(folder, filename, args);
35+
break;
36+
}
3237
}
3338
}
3439
if (!config) {
@@ -39,4 +44,5 @@ async function readCases(folder, extra_config = {}, args) {
3944
if (config.type !== 'remotejudge' && !config.count) throw new FormatError('没有找到测试数据');
4045
return config;
4146
}
47+
4248
module.exports = readCases;

judger/hosts/hydro.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class JudgeTask {
3333
this.lang = this.request.lang;
3434
this.code = this.request.code;
3535
this.data = this.request.data;
36-
this.config = this.request.config;
3736
this.next = this.getNext(this);
3837
this.end = this.getEnd(this.session, this.rid);
3938
this.tmpdir = path.resolve(TEMP_DIR, 'tmp', this.host, this.rid);
@@ -73,7 +72,7 @@ class JudgeTask {
7372
this.config = await readCases(
7473
this.folder,
7574
{ detail: this.session.config.detail },
76-
{ next: this.next },
75+
{ next: this.next, config: this.request.config },
7776
);
7877
this.stat.judge = new Date();
7978
await judger[this.config.type || 'default'].judge(this);
@@ -88,40 +87,40 @@ class JudgeTask {
8887
that.nextId = 1;
8988
that.nextWaiting = [];
9089
return (data, id) => {
91-
data.key = 'next';
90+
data.operation = 'next';
9291
data.rid = that.rid;
9392
if (id) {
9493
if (id === that.nextId) {
95-
that.session.axios.post('/judge/next', data);
94+
that.session.axios.post('/judge', data);
9695
that.nextId++;
9796
let t = true;
9897
while (t) {
9998
t = false;
10099
for (const i in that.nextWaiting) {
101100
if (that.nextId === that.nextWaiting[i].id) {
102-
that.session.axios.post('/judge/next', that.nextWaiting[i].data);
101+
that.session.axios.post('/judge', that.nextWaiting[i].data);
103102
that.nextId++;
104103
that.nextWaiting.splice(i, 1);
105104
t = true;
106105
}
107106
}
108107
}
109108
} else that.nextWaiting.push({ data, id });
110-
} else that.session.axios.post('/judge/next', data);
109+
} else that.session.axios.post('/judge', data);
111110
};
112111
}
113112

114113
getEnd(session, rid) { // eslint-disable-line class-methods-use-this
115114
return (data) => {
116-
data.key = 'end';
115+
data.operation = 'end';
117116
data.rid = rid;
118117
log.log({
119118
status: data.status,
120119
score: data.score,
121120
time_ms: data.time_ms,
122121
memory_kb: data.memory_kb,
123122
});
124-
session.axios.post('/judge/end', data);
123+
session.axios.post('/judge', data);
125124
};
126125
}
127126
}

0 commit comments

Comments
 (0)