mirror of
https://github.com/QingdaoU/Judger.git
synced 2024-12-29 00:11:41 +00:00
read test config from file
This commit is contained in:
parent
2299a0cd07
commit
baa924ec52
4
judger.c
4
judger.c
@ -46,7 +46,7 @@ static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
if (!next) {
|
||||
break;
|
||||
}
|
||||
if (!PyString_Check(next)) {
|
||||
if (!PyString_Check(next) && !PyUnicode_Check(next)) {
|
||||
PyErr_SetString(PyExc_ValueError, "arg must be string");
|
||||
return NULL;
|
||||
}
|
||||
@ -68,7 +68,7 @@ static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||
if (!next) {
|
||||
break;
|
||||
}
|
||||
if (!PyString_Check(next)) {
|
||||
if (!PyString_Check(next) && !PyUnicode_Check(next)) {
|
||||
PyErr_SetString(PyExc_ValueError, "env must be string");
|
||||
return NULL;
|
||||
}
|
||||
|
1
tests/1/config
Normal file
1
tests/1/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/2/config
Normal file
1
tests/2/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 200000000}
|
1
tests/3/config
Normal file
1
tests/3/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/4/config
Normal file
1
tests/4/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/5/config
Normal file
1
tests/5/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/6/config
Normal file
1
tests/6/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/7/config
Normal file
1
tests/7/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/8/config
Normal file
1
tests/8/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 200000000, "args": ["hello", "123"]}
|
@ -26,11 +26,13 @@ class JudgerTest(TestCase):
|
||||
for i in range(1, 9):
|
||||
test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), str(i))
|
||||
exe_path = os.path.join("/tmp/judger_test", str(i))
|
||||
self.assertEqual(self.compile_src(os.path.join(test_dir, "Main.c"), "c", exe_path), 0)
|
||||
config = json.loads(open(os.path.join(test_dir, "config")).read())
|
||||
self.assertEqual(self.compile_src(os.path.join(test_dir, "Main.c"), config.pop("language"), exe_path), 0)
|
||||
|
||||
run_result = judger.run(path=exe_path,
|
||||
in_file=os.path.join(test_dir, "in"),
|
||||
out_file=os.path.join(self.tmp_path, str(i) + ".out"),
|
||||
max_cpu_time=2000, max_memory=200000000, args=["hello", "123"])
|
||||
**config)
|
||||
result = json.loads(open(os.path.join(test_dir, "result")).read())
|
||||
self.assertEqual(result["flag"], run_result["flag"])
|
||||
self.assertEqual(result["signal"], run_result["signal"])
|
||||
|
Loading…
Reference in New Issue
Block a user