feat: diff parser #33
|  | @ -1 +1 @@ | |||
| Subproject commit 2593e79505a93042d308c5fc355dba671dd4fdba | ||||
| Subproject commit 4e5fab93e5a0ce67c8f40fef1e8f4cab7018fc5d | ||||
|  | @ -1 +1 @@ | |||
| Subproject commit 638e9f661092d39daaf6e1ffc8ba5998fc56c96a | ||||
| Subproject commit 1512cb5f20473a598d7504a08dacff3d6406b983 | ||||
|  | @ -1 +1 @@ | |||
| Subproject commit d8d66fb5b47b5e79e08532da31d397a5d461f087 | ||||
| Subproject commit af990327ab095c22a383448ad70d915f8d10490b | ||||
|  | @ -1 +1 @@ | |||
| Subproject commit fc774118794a5c5ec0b88863ba6c8492e5b13f89 | ||||
| Subproject commit ac7a2fc912fb51af156cd4babb7e72148ebe1c14 | ||||
|  | @ -20,10 +20,13 @@ const ( | |||
| 
 | ||||
| type Conf struct { | ||||
| 	Cases []struct { | ||||
| 		Outputs []struct { | ||||
| 			Score            int | ||||
| 		StdoutPath       string | ||||
| 			FileName         string | ||||
| 			AnswerPath       string | ||||
| 			IgnoreWhitespace bool | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| type Diff struct{} | ||||
|  | @ -43,25 +46,20 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( | |||
| 	for i, caseConf := range conf.Cases { | ||||
| 		result := results[i] | ||||
| 		score := 0 | ||||
| 		var comment string | ||||
| 
 | ||||
| 		stdout, err := os.ReadFile(caseConf.StdoutPath) | ||||
| 		comment := "" | ||||
| 		for _, output := range caseConf.Outputs { | ||||
| 			answer, err := os.ReadFile(output.AnswerPath) | ||||
| 			if err != nil { | ||||
| 				return nil, true, err | ||||
| 			} | ||||
| 
 | ||||
| 		comment = fmt.Sprintf( | ||||
| 			"executor status: run time: %d ns, memory: %d bytes\n", | ||||
| 			result.RunTime, result.Memory, | ||||
| 		) | ||||
| 
 | ||||
| 			// If no difference, assign score
 | ||||
| 		if compareChars(string(stdout), result.Files["stdout"], caseConf.IgnoreWhitespace) { | ||||
| 			score = caseConf.Score | ||||
| 			if compareChars(string(answer), result.Files[output.FileName], output.IgnoreWhitespace) { | ||||
| 				score += output.Score | ||||
| 			} else { | ||||
| 			// Convert stdout to string and split by lines
 | ||||
| 			stdoutLines := strings.Split(string(stdout), "\n") | ||||
| 			resultLines := strings.Split(result.Files["stdout"], "\n") | ||||
| 				// Convert answer to string and split by lines
 | ||||
| 				stdoutLines := strings.Split(string(answer), "\n") | ||||
| 				resultLines := strings.Split(result.Files[output.FileName], "\n") | ||||
| 
 | ||||
| 				// Generate Myers diff
 | ||||
| 				diffOps := myersDiff(stdoutLines, resultLines) | ||||
|  | @ -69,10 +67,11 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( | |||
| 				// Generate diff block with surrounding context
 | ||||
| 				diffOutput := generateDiffWithContext(stdoutLines, resultLines, diffOps) | ||||
| 				comment += fmt.Sprintf( | ||||
| 				"difference found:\n```diff\n%s```", | ||||
| 				diffOutput, | ||||
| 					"difference found in %s:\n```diff\n%s```\n", | ||||
| 					output.FileName, diffOutput, | ||||
| 				) | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		res = append(res, stage.ParserResult{ | ||||
| 			Score:   score, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user