feat: update diff
This commit is contained in:
		
							parent
							
								
									fc77411879
								
							
						
					
					
						commit
						ac7a2fc912
					
				
							
								
								
									
										56
									
								
								conf.toml
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								conf.toml
									
									
									
									
									
								
							|  | @ -101,50 +101,78 @@ name = "diff" | ||||||
| 
 | 
 | ||||||
| # empty | # empty | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/empty.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/empty.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/one-line.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/one-line.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err1.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err1.out" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # one-line | # one-line | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/empty.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/empty.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/one-line.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/one-line.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err1.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err1.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err2.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err2.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err3.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err3.out" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # multi-line | # multi-line | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/empty.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/empty.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/one-line.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/one-line.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-correct.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-correct.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err1.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err1.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err2.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err2.out" | ||||||
| [[stages.parser.with.cases]] | [[stages.parser.with.cases]] | ||||||
|  | [[stages.parser.with.cases.outputs]] | ||||||
| score = 100 | score = 100 | ||||||
| stdoutPath = "./cases/multi-line-err3.out" | fileName = "stdout" | ||||||
|  | answerPath = "./cases/multi-line-err3.out" | ||||||
|  |  | ||||||
							
								
								
									
										29
									
								
								convert.py
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								convert.py
									
									
									
									
									
								
							|  | @ -1,29 +0,0 @@ | ||||||
| import json |  | ||||||
| import re |  | ||||||
| 
 |  | ||||||
| # 读取 joj3_result.json 文件内容 |  | ||||||
| with open("joj3_result.json", "r", encoding="utf-8") as file: |  | ||||||
|     json_data = file.read() |  | ||||||
| 
 |  | ||||||
| # 解析 JSON 数据 |  | ||||||
| data = json.loads(json_data) |  | ||||||
| 
 |  | ||||||
| # 定义正则表达式以提取 diff 代码块 |  | ||||||
| diff_pattern = re.compile(r"```diff\n(.*?)\n```", re.DOTALL) |  | ||||||
| 
 |  | ||||||
| # 遍历 "run" 的 results |  | ||||||
| for run in data: |  | ||||||
|     if run["name"] == "run": |  | ||||||
|         results = run["results"] |  | ||||||
|         for result_index, result in enumerate(results): |  | ||||||
|             comment = result.get("comment", "") |  | ||||||
|             matches = diff_pattern.findall(comment) |  | ||||||
| 
 |  | ||||||
|             if matches: |  | ||||||
|                 print(f"Result {result_index + 1} diff blocks:") |  | ||||||
|                 for i, diff in enumerate(matches): |  | ||||||
|                     # 将 \n 替换为实际换行符 |  | ||||||
|                     formatted_diff = diff.replace("\\n", "\n") |  | ||||||
|                     print(f"```diff\n{formatted_diff}\n```\n") |  | ||||||
|             else: |  | ||||||
|                 print(f"Result {result_index + 1}: the same\n") |  | ||||||
							
								
								
									
										1
									
								
								expected.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								expected.json
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | [{"name":"compile","results":[{"score":0,"comment":""}],"force_quit":false},{"name":"run","results":[{"score":100,"comment":""},{"score":0,"comment":"difference found in stdout:\n```diff\n- 1024 2048\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n- asdfljsdfklasdfjklasdfjjkl\n- 1024 2048\n- asdfjksdfjkl\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n+ 1024 2048\n  \n```\n"},{"score":100,"comment":""},{"score":0,"comment":"difference found in stdout:\n```diff\n- asdfljsdfklasdfjklasdfjjkl\n  1024 2048\n- asdfjksdfjkl\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n  1024 2048\n- asdfjksdfjkl\n- asdfljsdfklasdfjklasdfjjkl\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n  1024 2048\n- asdfjksdfjkl\n- asdfljsdfklasdfjklasdfjjkl\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n+ 1024 2048\n+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n+ 1024 2048\n+ psdfklj\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n+ 1024 2048\n+ psdfklj\n  \n```\n"},{"score":100,"comment":""},{"score":0,"comment":"difference found in stdout:\n```diff\n- asdfljsdfklasdfjklasdfjjkl\n+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n- asdfjksdfjkl\n+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n+ 1024 2048\n+ psdfklj\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n- asdfjksdfjkl\n- asdfljsdfklasdfjklasdfjjkl\n+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n+ 1024 2048\n+ psdfklj\n  \n```\n"},{"score":0,"comment":"difference found in stdout:\n```diff\n+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n- asdfjksdfjkl\n- asdfljsdfklasdfjklasdfjjkl\n+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n+ 1024 2048\n+ psdfklj\n  \n```\n"}],"force_quit":false}] | ||||||
|  | @ -1,74 +0,0 @@ | ||||||
| [ |  | ||||||
|   { |  | ||||||
|     "name": "compile", |  | ||||||
|     "results": [ |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "" |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     "force_quit": false |  | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     "name": "run", |  | ||||||
|     "results": [ |  | ||||||
|       { |  | ||||||
|         "score": 100, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\n" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\- 1024 2048\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\- asdfljsdfklasdfjklasdfjjkl\n\\- 1024 2048\n\\- asdfjksdfjkl\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\+ 1024 2048\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 100, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\n" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\- asdfljsdfklasdfjklasdfjjkl\n  1024 2048\n\\- asdfjksdfjkl\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n  1024 2048\n\\- asdfjksdfjkl\n\\- asdfljsdfklasdfjklasdfjjkl\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n  1024 2048\n\\- asdfjksdfjkl\n\\- asdfljsdfklasdfjklasdfjjkl\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n\\+ 1024 2048\n\\+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n\\+ 1024 2048\n\\+ psdfklj\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n\\+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n\\+ 1024 2048\n\\+ psdfklj\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 100, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\n" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\- asdfljsdfklasdfjklasdfjjkl\n\\+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n\\- asdfjksdfjkl\n\\+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n\\+ 1024 2048\n\\+ psdfklj\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n\\- asdfjksdfjkl\n\\- asdfljsdfklasdfjklasdfjjkl\n\\+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n\\+ 1024 2048\n\\+ psdfklj\n  \n```" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "score": 0, |  | ||||||
|         "comment": "executor status: run time: \\d+ ns, memory: \\d+ bytes\ndifference found:\n```diff\n\\+ jklasdfklasdfjklf asdfhklasdfjl cvsdlfkdjsfklv \n  1024 2048\n\\- asdfjksdfjkl\n\\- asdfljsdfklasdfjklasdfjjkl\n\\+ asdfjkl asdfkljdaslasdfjkl asdfjkl\n\\+ 1024 2048\n\\+ psdfklj\n  \n```" |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     "force_quit": false |  | ||||||
|   } |  | ||||||
| ] |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user