Skip to content

Commit

Permalink
Merge pull request #11 from vnma0/tcase-parser-fix
Browse files Browse the repository at this point in the history
Fix parser failed to read test log correctly
  • Loading branch information
dungwinux authored Mar 25, 2019
2 parents ed09b52 + c20d249 commit 7cffe0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kon",
"version": "1.0.0",
"version": "1.5.0",
"description": "Themis wrapper for Wafter",
"main": "src/server.js",
"bin": "build/server.js",
Expand Down
8 changes: 5 additions & 3 deletions src/util/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ function parseTestCase(rawTestCase) {
async function parseLog(filePath) {
if (!isFile(filePath)) return null;

const file = await promisify(readFile)(filePath, "utf8");
const file = await promisify(readFile)(filePath, "utf-8");
const { id, problem } = logName2Data(basename(filePath));

const lines = file.split(EOL);

const header = esr(`${id}${problem}`);
const rVerdict = new RegExp(header + ": (.*)", "i");
const rScore = new RegExp(header + "‣Test[0-9]{2}: (.*)", "i");
const rScore = new RegExp(header + "‣.+?: (.*)", "i");

const findVerdict = lines[0].match(rVerdict);
const finalScore = Number(findVerdict[1]);
Expand All @@ -212,11 +212,13 @@ async function parseLog(filePath) {
2
);

const parsedTestSuite = rawTestSuite.map(parseTestCase);

return {
id,
problem,
finalScore,
tests: rawTestSuite.map(parseTestCase)
tests: parsedTestSuite
};
}

Expand Down

0 comments on commit 7cffe0a

Please sign in to comment.