Closed MohamedIrfanAM closed 8 months ago
The issue with using trimmed lines is that it also removes spaces at the end or begining, so if someone added some spaces accidentally it will no longer be detected by cpbooster, however, from the code change looks like the issue is just the line ending so probably we could just normalize the line endings depending on the OS without removing the spaces
In windows compiled output has '\r\n' instead of '\n' at end of each line. This creates two problems
Veredict.AC_WHEN_TRIMMED
is found instead of Veredict.AC
because output
and ans
will never be same https://github.com/searleser97/cpbooster/blob/cdfbd6fe91dcde76c101922718542002f934689c/app/src/Test/TesterFactory/Tester.ts#L204C3-L204C3.split("\n")
is called the outputLines
is left with "\r"
at end of each line and this creates weird outputBoth problems can be fixed if we replace all'\r\n'
sequence in the output file with '\n'
Something like
const isWindows = os.type() === "Windows_NT" || os.release().includes("Microsoft");
let output = execution.stdout?.toString() ?? "";
const ans = fs.readFileSync(answerFilePath).toString();
if(isWindows){
output = output.replace(/\r\n/g, "\n");
}
May I proceed?
In windows compiled output has '\r\n' instead of '\n' at end of each line. This creates two problems
Veredict.AC_WHEN_TRIMMED
is found instead ofVeredict.AC
becauseoutput
andans
will never be same https://github.com/searleser97/cpbooster/blob/cdfbd6fe91dcde76c101922718542002f934689c/app/src/Test/TesterFactory/Tester.ts#L204C3-L204C3when this
.split("\n")
is called theoutputLines
is left with"\r"
at end of each line and this creates weird outputBoth problems can be fixed if we replace all
'\r\n'
sequence in the output file with'\n'
Something likeconst isWindows = os.type() === "Windows_NT" || os.release().includes("Microsoft"); let output = execution.stdout?.toString() ?? ""; const ans = fs.readFileSync(answerFilePath).toString(); if(isWindows){ output = output.replace(/\r\n/g, "\n"); }
May I proceed?
I agree, let's do that
I moved isWindows to Util, is that okay? https://github.com/searleser97/cpbooster/pull/98/commits/fe0b510ee72385d22218e3234a903330cd4bd9a6
Resolves #51 #9