|  |  |  | @ -20,9 +20,12 @@ const ( | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | type Conf struct { | 
		
	
		
			
				|  |  |  |  | 	Cases []struct { | 
		
	
		
			
				|  |  |  |  | 		Score            int | 
		
	
		
			
				|  |  |  |  | 		StdoutPath       string | 
		
	
		
			
				|  |  |  |  | 		IgnoreWhitespace bool | 
		
	
		
			
				|  |  |  |  | 		Outputs []struct { | 
		
	
		
			
				|  |  |  |  | 			Score            int | 
		
	
		
			
				|  |  |  |  | 			FileName         string | 
		
	
		
			
				|  |  |  |  | 			AnswerPath       string | 
		
	
		
			
				|  |  |  |  | 			IgnoreWhitespace bool | 
		
	
		
			
				|  |  |  |  | 		} | 
		
	
		
			
				|  |  |  |  | 	} | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -43,35 +46,31 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) ( | 
		
	
		
			
				|  |  |  |  | 	for i, caseConf := range conf.Cases { | 
		
	
		
			
				|  |  |  |  | 		result := results[i] | 
		
	
		
			
				|  |  |  |  | 		score := 0 | 
		
	
		
			
				|  |  |  |  | 		var comment string | 
		
	
		
			
				|  |  |  |  | 		comment := "" | 
		
	
		
			
				|  |  |  |  | 		for _, output := range caseConf.Outputs { | 
		
	
		
			
				|  |  |  |  | 			answer, err := os.ReadFile(output.AnswerPath) | 
		
	
		
			
				|  |  |  |  | 			if err != nil { | 
		
	
		
			
				|  |  |  |  | 				return nil, true, err | 
		
	
		
			
				|  |  |  |  | 			} | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 		stdout, err := os.ReadFile(caseConf.StdoutPath) | 
		
	
		
			
				|  |  |  |  | 		if err != nil { | 
		
	
		
			
				|  |  |  |  | 			return nil, true, err | 
		
	
		
			
				|  |  |  |  | 		} | 
		
	
		
			
				|  |  |  |  | 			// If no difference, assign score
 | 
		
	
		
			
				|  |  |  |  | 			if compareChars(string(answer), result.Files[output.FileName], output.IgnoreWhitespace) { | 
		
	
		
			
				|  |  |  |  | 				score += output.Score | 
		
	
		
			
				|  |  |  |  | 			} else { | 
		
	
		
			
				|  |  |  |  | 				// Convert answer to string and split by lines
 | 
		
	
		
			
				|  |  |  |  | 				stdoutLines := strings.Split(string(answer), "\n") | 
		
	
		
			
				|  |  |  |  | 				resultLines := strings.Split(result.Files[output.FileName], "\n") | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 		comment = fmt.Sprintf( | 
		
	
		
			
				|  |  |  |  | 			"executor status: run time: %d ns, memory: %d bytes\n", | 
		
	
		
			
				|  |  |  |  | 			result.RunTime, result.Memory, | 
		
	
		
			
				|  |  |  |  | 		) | 
		
	
		
			
				|  |  |  |  | 				// Generate Myers diff
 | 
		
	
		
			
				|  |  |  |  | 				diffOps := myersDiff(stdoutLines, resultLines) | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 		// If no difference, assign score
 | 
		
	
		
			
				|  |  |  |  | 		if compareChars(string(stdout), result.Files["stdout"], caseConf.IgnoreWhitespace) { | 
		
	
		
			
				|  |  |  |  | 			score = caseConf.Score | 
		
	
		
			
				|  |  |  |  | 		} else { | 
		
	
		
			
				|  |  |  |  | 			// Convert stdout to string and split by lines
 | 
		
	
		
			
				|  |  |  |  | 			stdoutLines := strings.Split(string(stdout), "\n") | 
		
	
		
			
				|  |  |  |  | 			resultLines := strings.Split(result.Files["stdout"], "\n") | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 			// Generate Myers diff
 | 
		
	
		
			
				|  |  |  |  | 			diffOps := myersDiff(stdoutLines, resultLines) | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 			// Generate diff block with surrounding context
 | 
		
	
		
			
				|  |  |  |  | 			diffOutput := generateDiffWithContext(stdoutLines, resultLines, diffOps) | 
		
	
		
			
				|  |  |  |  | 			comment += fmt.Sprintf( | 
		
	
		
			
				|  |  |  |  | 				"difference found:\n```diff\n%s```", | 
		
	
		
			
				|  |  |  |  | 				diffOutput, | 
		
	
		
			
				|  |  |  |  | 			) | 
		
	
		
			
				|  |  |  |  | 				// Generate diff block with surrounding context
 | 
		
	
		
			
				|  |  |  |  | 				diffOutput := generateDiffWithContext(stdoutLines, resultLines, diffOps) | 
		
	
		
			
				|  |  |  |  | 				comment += fmt.Sprintf( | 
		
	
		
			
				|  |  |  |  | 					"difference found in %s:\n```diff\n%s```\n", | 
		
	
		
			
				|  |  |  |  | 					output.FileName, diffOutput, | 
		
	
		
			
				|  |  |  |  | 				) | 
		
	
		
			
				|  |  |  |  | 			} | 
		
	
		
			
				|  |  |  |  | 		} | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 		res = append(res, stage.ParserResult{ | 
		
	
	
		
			
				
					|  |  |  | 
 |