feat: diff parser #33

Merged
张泊明518370910136 merged 10 commits from diff into master 2024-09-11 19:12:13 +08:00
Showing only changes of commit 6fbbe7ece0 - Show all commits

View File

@ -13,7 +13,7 @@ type Conf struct {
Cases []struct { Cases []struct {
Score int Score int
StdoutPath string StdoutPath string
ignoreWhitespace bool IgnoreWhitespace bool
} }
} }
@ -47,7 +47,7 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
) )
// If no difference, assign score // If no difference, assign score
if compareChars(string(stdout), result.Files["stdout"], caseConf.ignoreWhitespace) { if compareChars(string(stdout), result.Files["stdout"], caseConf.IgnoreWhitespace) {
score = caseConf.Score score = caseConf.Score
} else { } else {
// Convert stdout to string and split by lines // Convert stdout to string and split by lines
@ -55,7 +55,7 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
resultLines := strings.Split(result.Files["stdout"], "\n") resultLines := strings.Split(result.Files["stdout"], "\n")
// Find the first difference // Find the first difference
diffIndex := findFirstDifferenceIndex(stdoutLines, resultLines, caseConf.ignoreWhitespace) diffIndex := findFirstDifferenceIndex(stdoutLines, resultLines, caseConf.IgnoreWhitespace)
if diffIndex != -1 { if diffIndex != -1 {
// Generate diff block with surrounding context // Generate diff block with surrounding context
diffOutput := generateDiffWithContext(stdoutLines, resultLines, diffIndex, 10) diffOutput := generateDiffWithContext(stdoutLines, resultLines, diffIndex, 10)