|
| 1 | +import json |
1 | 2 | import logging |
2 | 3 | import os |
3 | 4 | import re |
@@ -37,6 +38,10 @@ def _setup_out_dir(self): |
37 | 38 | os.makedirs(xunit_dir) |
38 | 39 | return xunit_dir |
39 | 40 |
|
| 41 | + @property |
| 42 | + def metadata_file_name(self) -> str: |
| 43 | + return f'metadata_{self._tag}.json' |
| 44 | + |
40 | 45 | @cached_property |
41 | 46 | def version(self) -> str: |
42 | 47 | version = self._tag |
@@ -116,6 +121,18 @@ def _apply_patch_files(self) -> bool: |
116 | 121 | if is_dir_empty: |
117 | 122 | logging.warning("The '%s' directory does not contain any files", self.version_folder) |
118 | 123 |
|
| 124 | + def create_metadata_for_failure(self, reason: str) -> None: |
| 125 | + reports_dir = Path(os.path.dirname(__file__)) / "reports" |
| 126 | + if not reports_dir.exists(): |
| 127 | + reports_dir.mkdir(exist_ok=True, parents=True) |
| 128 | + metadata_file = reports_dir / self.metadata_file_name |
| 129 | + metadata = { |
| 130 | + "driver_name": f"TEST-{self._tag}", |
| 131 | + "driver_type": "java", |
| 132 | + "failure_reason": reason, |
| 133 | + } |
| 134 | + metadata_file.write_text(json.dumps(metadata)) |
| 135 | + |
119 | 136 | def run(self) -> ProcessJUnit: |
120 | 137 | self._run_command_in_shell("git checkout .") |
121 | 138 | self._run_command_in_shell(f"git checkout {self._tag}") |
@@ -153,9 +170,15 @@ def run(self) -> ProcessJUnit: |
153 | 170 | except AssertionError: |
154 | 171 | # Some tests are failed |
155 | 172 | pass |
156 | | - |
| 173 | + metadata_file = Path(os.path.dirname(__file__)) / "reports" / self.metadata_file_name |
| 174 | + metadata = { |
| 175 | + "driver_name": f"TEST-{self._tag}", |
| 176 | + "driver_type": "java", |
| 177 | + "junit_result": f"./TEST-{self._tag}.xml", |
| 178 | + } |
157 | 179 | report = ProcessJUnit( |
158 | 180 | new_report_xml_path=Path(os.path.dirname(__file__)) / "reports" / f"TEST-{self._tag}.xml", |
159 | 181 | tests_result_path=self._report_path, |
160 | 182 | tag=self._tag) |
| 183 | + metadata_file.write_text(json.dumps(metadata)) |
161 | 184 | return report |
0 commit comments