diff --git a/doc/generateDocumentationData.py b/doc/generateDocumentationData.py index fc46923f018ec64822e1d3421378970b22dbb08b..9b314e266479e633b5fcfd86799defa99ccea787 100644 --- a/doc/generateDocumentationData.py +++ b/doc/generateDocumentationData.py @@ -5,7 +5,7 @@ from os.path import dirname, exists from os import makedirs, walk -def create_json_of_robotfile(robot_file_to_be_processed: str): +def create_json_of_robotfile(robot_file_to_be_processed: str, computestatistics: bool=False): folder_test_suites = dirname(dirname(__file__)) folder_result_path = f'{folder_test_suites}/doc/results' @@ -17,14 +17,24 @@ def create_json_of_robotfile(robot_file_to_be_processed: str): if not exists(folder_result_path): makedirs(folder_result_path) - #try: - data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) - data.parse_robot() - info = data.get_info() - #except Exception as e: - # print("WHILE GENERATING ROBOT DATA:", e) - # info = dict() - # info["error_while_parsing"] = True + if computestatistics: + try: + data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) + data.parse_robot() + info = data.get_info() + except Exception as e: + print("WHILE GENERATING ROBOT DATA:", e) + info = dict() + info["error_while_parsing"] = True + info["robotfile"] = robot_file_to_be_processed + if(robot_path_to_be_processed.startswith("/")): + robot_path_to_be_processed = robot_path_to_be_processed[1:] + info["robotpath"] = robot_path_to_be_processed + else: + data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) + data.parse_robot() + info = data.get_info() + with open(result_file, 'w') as fp: dump(obj=info, indent=2, fp=fp) diff --git a/doc/statisticsDocumentationData.py b/doc/statisticsDocumentationData.py new file mode 100644 index 0000000000000000000000000000000000000000..e3fb0c3d50cb71128225858b52b580f06a0582aa --- /dev/null +++ b/doc/statisticsDocumentationData.py @@ -0,0 +1,44 @@ +from generateDocumentationData import create_json_of_robotfile +from os.path import dirname +from os import walk +from json import dump + +if __name__ == "__main__": + basedir = dirname(dirname(__file__)) + statistics = dict() + testcases = [] + number_of_failures = 0 + number_of_all_testcases = 0 + number_of_successes = 0 + ROBOT_FILE_EXTENSION = ".robot" + + fullpath = basedir+"/TP/NGSI-LD" + for root, dirs, files in walk(fullpath): + for filename in files: + if filename.endswith(ROBOT_FILE_EXTENSION): + number_of_all_testcases += 1 + name_of_test_case = filename[:-len(ROBOT_FILE_EXTENSION)] + json_of_test_case = create_json_of_robotfile(name_of_test_case, True) + statistics[name_of_test_case] = dict() + strippedpath = root[len(fullpath)+1:] + statistics[name_of_test_case]["path"] = strippedpath + if "error_while_parsing" in json_of_test_case and json_of_test_case["error_while_parsing"] == True: + statistics[name_of_test_case]["failed"] = True + number_of_failures += 1 + else: + statistics[name_of_test_case]["failed"] = False + number_of_successes += 1 + testcases.append(json_of_test_case) + + print() + print() + print() + print("THE FOLLOWING TESTCASES FAILED PARSING:") + for testcasename, testcaseresult in statistics.items(): + if testcaseresult["failed"] == True: + print(testcasename+" "+testcaseresult["path"]) + + print("Out of "+str(number_of_all_testcases)+" testcases, "+str(number_of_failures)+" of them failed to be correctly parsed") + + with open("testcases.json", 'w') as fp: + dump(obj=testcases, indent=2, fp=fp) \ No newline at end of file