feat: option ignoring whitespace

This commit is contained in:
zzjc1234 2024-09-09 13:08:29 +08:00 committed by Boming Zhang
parent 96c71bcd63
commit 6fbbe7ece0
GPG Key ID: D47306D7062CDA9D

View File

@ -13,7 +13,7 @@ type Conf struct {
Cases []struct {
Score int
StdoutPath string
ignoreWhitespace bool
IgnoreWhitespace bool
}
}
@ -47,7 +47,7 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
)
// 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
} else {
// 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")
// Find the first difference
diffIndex := findFirstDifferenceIndex(stdoutLines, resultLines, caseConf.ignoreWhitespace)
diffIndex := findFirstDifferenceIndex(stdoutLines, resultLines, caseConf.IgnoreWhitespace)
if diffIndex != -1 {
// Generate diff block with surrounding context
diffOutput := generateDiffWithContext(stdoutLines, resultLines, diffIndex, 10)