fix: result_detail parser
This commit is contained in:
		
							parent
							
								
									5eff9fca75
								
							
						
					
					
						commit
						3f8a6e9066
					
				|  | @ -1,5 +1,5 @@ | ||||||
| from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig | from joj3_config_generator.lib.repo import getHealthcheckConfig, getTeapotConfig | ||||||
| from joj3_config_generator.lib.task import fix_comment, fix_keyword | from joj3_config_generator.lib.task import fix_comment, fix_keyword, fix_result_detail | ||||||
| from joj3_config_generator.models import ( | from joj3_config_generator.models import ( | ||||||
|     Cmd, |     Cmd, | ||||||
|     CmdFile, |     CmdFile, | ||||||
|  | @ -82,16 +82,10 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | ||||||
|                 ParserConfig(name=parser, with_={}) for parser in task_stage.parsers |                 ParserConfig(name=parser, with_={}) for parser in task_stage.parsers | ||||||
|             ], |             ], | ||||||
|         ) |         ) | ||||||
|         # TODO: fix all parser here |         conf_stage = fix_result_detail(task_stage, conf_stage) | ||||||
|         if "result-detail" in task_stage.parsers: |  | ||||||
|             result_detail_parser = next( |  | ||||||
|                 p for p in conf_stage.parsers if p.name == "result-detail" |  | ||||||
|             ) |  | ||||||
|             if task_stage.result_detail is not None: |  | ||||||
|                 result_detail_parser.with_.update(task_stage.result_detail) |  | ||||||
| 
 |  | ||||||
|         conf_stage = fix_comment(task_stage, conf_stage) |         conf_stage = fix_comment(task_stage, conf_stage) | ||||||
|         conf_stage = fix_keyword(task_stage, conf_stage) |         conf_stage = fix_keyword(task_stage, conf_stage) | ||||||
|  |         # TODO: fix diff parser here | ||||||
| 
 | 
 | ||||||
|         result_conf.stage.stages.append(conf_stage) |         result_conf.stage.stages.append(conf_stage) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20,6 +20,37 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: | ||||||
|     return conf_stage |     return conf_stage | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def fix_result_detail(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: | ||||||
|  |     if "result-detail" in task_stage.parsers: | ||||||
|  |         result_detail_parser = next( | ||||||
|  |             p for p in conf_stage.parsers if p.name == "result-detail" | ||||||
|  |         ) | ||||||
|  |         if task_stage.result_detail is not None: | ||||||
|  |             show_files = [] | ||||||
|  |             if ( | ||||||
|  |                 task_stage.result_detail.stdout | ||||||
|  |                 and task_stage.result_detail.stdout is not None | ||||||
|  |             ): | ||||||
|  |                 show_files.append("stdout") | ||||||
|  |             if ( | ||||||
|  |                 task_stage.result_detail.stderr | ||||||
|  |                 and task_stage.result_detail.stderr is not None | ||||||
|  |             ): | ||||||
|  |                 show_files.append("stderr") | ||||||
|  |             result_detail_parser.with_.update( | ||||||
|  |                 { | ||||||
|  |                     "score": 0, | ||||||
|  |                     "comment": "", | ||||||
|  |                     "showFiles": show_files, | ||||||
|  |                     "showExitStatus": task_stage.result_detail.exitstatus, | ||||||
|  |                     "showRuntime": task_stage.result_detail.time, | ||||||
|  |                     "showMemory": task_stage.result_detail.mem, | ||||||
|  |                 } | ||||||
|  |             ) | ||||||
|  | 
 | ||||||
|  |     return conf_stage | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: | def fix_comment(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: | ||||||
|     comment_parser = [ |     comment_parser = [ | ||||||
|         "dummy", |         "dummy", | ||||||
|  |  | ||||||
|  | @ -46,7 +46,9 @@ class Stage(BaseModel): | ||||||
|     keyword: Optional[ParserKeyword] = ParserKeyword() |     keyword: Optional[ParserKeyword] = ParserKeyword() | ||||||
|     clangtidy: Optional[ParserKeyword] = ParserKeyword() |     clangtidy: Optional[ParserKeyword] = ParserKeyword() | ||||||
|     cppcheck: Optional[ParserKeyword] = ParserKeyword() |     cppcheck: Optional[ParserKeyword] = ParserKeyword() | ||||||
|     cpplint: Optional[ParserKeyword] = ParserKeyword() |     # FIXME: determine cpplint type | ||||||
|  |     # cpplint: Optional[ParserKeyword] = ParserKeyword() | ||||||
|  |     cpplint: Optional[ParserDummy] = ParserDummy() | ||||||
|     result_detail: Optional[ParserResultDetail] = Field( |     result_detail: Optional[ParserResultDetail] = Field( | ||||||
|         ParserResultDetail(), alias="result-detail" |         ParserResultDetail(), alias="result-detail" | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user