5454
5555
5656def get_metadata_from_test_path (filepath : Path ) -> MetaData :
57+ """
58+ Will parse out the metadata from the testpath.
59+ If test is local then the metadata will be:
60+
61+ "module_name": "local_module",
62+ "hash": "",
63+ "url": "",
64+
65+ Else it will parse the module_name e.g. `score_docs_as_code`
66+ match this in the known_good_json and grab the accompanying
67+ hash, url as well and return metadata like so for example:
68+
69+ "module_name": "score_docs_as_code",
70+ "hash": "c1207676afe6cafd25c35d420e73279a799515d8",
71+ "url": "https://github.com/eclipse-score/docs-as-code"
72+
73+ """
5774 known_good_json = os .environ .get ("KNOWN_GOOD_JSON" )
5875 module_name = parse_module_name_from_path (filepath )
5976 md : MetaData = {
@@ -193,13 +210,17 @@ def read_test_xml_file(file: Path) -> tuple[list[DataOfTestCase], list[str], lis
193210 return test_case_needs , non_prop_tests , missing_prop_tests
194211
195212
196- # /home/maximilianp/score_personal/reference_integration/bazel-testlogs/external/score_docs_as_code+/src/helper_lib/helper_lib_tests/test.xml
197213def find_xml_files (dir : Path ) -> list [Path ]:
198214 """
199215 Recursively search all test.xml files inside 'bazel-testlogs'
200216
201217 Returns:
202218 - list[Path] => Paths to all found 'test.xml' files.
219+
220+ Example combo TestPath for future reference:
221+
222+ '<local path to folder>/reference_integration/bazel-testlogs
223+ /feature_integration_tests/test_cases/fit/test.xml'
203224 """
204225
205226 test_file_name = "test.xml"
@@ -208,21 +229,19 @@ def find_xml_files(dir: Path) -> list[Path]:
208229 for root , _ , files in os .walk (dir ):
209230 if test_file_name in files :
210231 xml_paths .append (Path (os .path .join (root , test_file_name )))
211- print ("=========================================" )
212- print (xml_paths [0 ])
213- print ("=========================================" )
232+
214233 return xml_paths
215234
216235
217- def find_test_folder (base_path : Path | None = None ) -> tuple [ Path | None , Path | None ] :
236+ def find_test_folder (base_path : Path | None = None ) -> Path | None :
218237 ws_root = base_path if base_path is not None else find_ws_root ()
219238 assert ws_root is not None
220239 if os .path .isdir (ws_root / "tests-report" ):
221- return ws_root , ws_root / "tests-report"
240+ return ws_root / "tests-report"
222241 if os .path .isdir (ws_root / "bazel-testlogs" ):
223- return ws_root , ws_root / "bazel-testlogs"
242+ return ws_root / "bazel-testlogs"
224243 logger .info ("could not find tests-report or bazel-testlogs to parse testcases" )
225- return ws_root , None
244+ return None
226245
227246
228247def run_xml_parser (app : Sphinx , env : BuildEnvironment ):
@@ -231,19 +250,10 @@ def run_xml_parser(app: Sphinx, env: BuildEnvironment):
231250 building testcase needs.
232251 It gets called from the source_code_linker __init__
233252 """
234- root_path , testlogs_dir = find_test_folder ()
235- # early return
253+ testlogs_dir = find_test_folder ()
236254 if testlogs_dir is None :
237255 return
238256 xml_file_paths = find_xml_files (testlogs_dir )
239- # scl_with_metadata = load_source_code_links_with_metadata_json(
240- # app.outdir / "score_source_links_metadata.json"
241- # )[0]
242- # metadata: MetaData = {
243- # "module_name": scl_with_metadata.module_name,
244- # "hash": scl_with_metadata.hash,
245- # "url": scl_with_metadata.url,
246- # }
247257 test_case_needs = build_test_needs_from_files (app , env , xml_file_paths )
248258 # Saving the test case needs for cache
249259 store_data_of_test_case_json (
@@ -301,6 +311,7 @@ def construct_and_add_need(app: Sphinx, tn: DataOfTestCase):
301311 assert tn .module_name is not None
302312 assert tn .hash is not None
303313 assert tn .url is not None
314+ # Have to build metadata here for the gh link func
304315 metadata = ModuleInfo (name = tn .module_name , hash = tn .hash , url = tn .url )
305316 # IDK if this is ideal or not
306317 with contextlib .suppress (BaseException ):
0 commit comments