示例#1
0
def main(argv):
    if len(argv) == 2 and argv[1] in ("-h", "--help"):
        print(
            "Update static analyzer reference results based "
            "\non the previous run of SATestBuild.py.\n"
            "\nN.B.: Assumes that SATestBuild.py was just run",
            file=sys.stderr)
        sys.exit(1)

    with open(SATestBuild.get_project_map_path(), "r") as f:
        for project_name, build_mode in SATestBuild.get_projects(f):
            update_reference_results(project_name, int(build_mode))
示例#2
0
def add_new_project(name: str, build_mode: int):
    """
    Add a new project for testing: build it and add to the Project Map file.
    :param name: is a short string used to identify a project.
    """

    project_info = SATestBuild.ProjectInfo(name,
                                           build_mode,
                                           is_reference_build=True)
    tester = SATestBuild.ProjectTester(project_info)

    project_dir = tester.get_project_dir()
    if not os.path.exists(project_dir):
        print(f"Error: Project directory is missing: {project_dir}")
        sys.exit(-1)

    # Build the project.
    tester.test()

    # Add the project name to the project map.
    project_map_path = SATestBuild.get_project_map_path(should_exist=False)

    if os.path.exists(project_map_path):
        file_mode = "r+"
    else:
        print("Warning: Creating the project map file!")
        file_mode = "w+"

    with open(project_map_path, file_mode) as map_file:
        if is_existing_project(map_file, name):
            print(f"Warning: Project with name '{name}' already exists.",
                  file=sys.stdout)
            print("Reference output has been regenerated.", file=sys.stdout)
        else:
            map_writer = csv.writer(map_file)
            map_writer.writerow((name, build_mode))
            print(f"The project map is updated: {project_map_path}")