From b6625664cd129d27edaa2fdcac44de22e77eb48f Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 14 Aug 2009 09:58:18 +0200 Subject: [PATCH] Backward-compatible point files implemented --- t/config | 2 ++ t/moe/testcase.py | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/t/config b/t/config index 8faf95b..2ad11ea 100644 --- a/t/config +++ b/t/config @@ -10,6 +10,8 @@ TESTCASE_IN=${TEST}.in TESTCASE_OUT=${TEST}.out TESTCASE_OK=${TEST}.ok TESTCASE_STATUS=${TEST}.stat +# backward compatibility +TESTCASE_PTS=${TEST}.pts # HOOKS # TESTCASE_HOOKS diff --git a/t/moe/testcase.py b/t/moe/testcase.py index 945f2e4..d1184d3 100644 --- a/t/moe/testcase.py +++ b/t/moe/testcase.py @@ -53,14 +53,18 @@ def collect_status(e): def tmpname(e): return os.path.join(e["TDIR"], e["TEST"] + ".tmp") -def collect_verdict(e, verdict_file): - try: - f = open(verdict_file, "r") +def collect_tmp_line(tmp_file): + if os.path.exists(tmp_file): + f = open(tmp_file, "r") v = f.readline().rstrip("\n") f.close() - except IOError, OSError: + os.unlink(tmp_file) + else: v = "" + return v +def collect_verdict(e, verdict_file): + v = collect_tmp_line(verdict_file) if len(v) >= 4 and v[0].isalnum and v[1].isalnum and v[2] == ":" and v[3] == " ": e.test_stat["status"] = v[0:2] e.log.verbose("Judge's status: %s\n" % v[0:2]) @@ -70,10 +74,11 @@ def collect_verdict(e, verdict_file): e.test_stat["message"] = v e.log.verbose("Judge's verdict: %s\n" % v) - try: - os.unlink(verdict_file) - except IOError, OSError: - pass +def collect_points(e): + p = collect_tmp_line(os.path.join(e["TDIR"], e["TESTCASE_PTS"])) + if p != "": + e.log.verbose("Judge has supplied points: %s\n" % p) + e.test_stat["points"] = p def setup(e): pdir = e["PDIR"] @@ -99,6 +104,7 @@ def judge(e): e.log.flush() rc = os.system(cmd) collect_verdict(e, verdict_file) + collect_points(e) collect_status(e) if os.WIFEXITED(rc): if os.WEXITSTATUS(rc) == 0: @@ -108,7 +114,6 @@ def judge(e): raise moe.MoeError("Judge failure") def points(e): - ## FIXME: check $TEST.pts if e.test_stat["points"] is None: e.test_stat["points"] = e["POINTS_PER_TEST"] -- 2.39.2