Пример #1
0
def add_new_project(project: ProjectInfo):
    """
    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.
    """

    test_info = SATestBuild.TestInfo(project, is_reference_build=True)
    tester = SATestBuild.ProjectTester(test_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 = ProjectMap(should_exist=False)

    if is_existing_project(project_map, project):
        print(f"Warning: Project with name '{project.name}' already exists.",
              file=sys.stdout)
        print("Reference output has been regenerated.", file=sys.stdout)
    else:
        project_map.projects.append(project)
        project_map.save()
Пример #2
0
def update_reference_results(project: ProjectInfo, git: bool = False):
    test_info = SATestBuild.TestInfo(project)
    tester = SATestBuild.ProjectTester(test_info)
    project_dir = tester.get_project_dir()

    tester.is_reference_build = True
    ref_results_path = tester.get_output_dir()

    tester.is_reference_build = False
    created_results_path = tester.get_output_dir()

    if not os.path.exists(created_results_path):
        print(f"Skipping project '{project.name}', "
              f"it doesn't have newer results.",
              file=sys.stderr)
        return

    build_log_path = SATestBuild.get_build_log_path(ref_results_path)
    build_log_dir = os.path.dirname(os.path.abspath(build_log_path))

    os.makedirs(build_log_dir)

    with open(build_log_path, "w+") as build_log_file:
        def run_cmd(command: str):
            if Verbose:
                print(f"Executing {command}")
            check_call(command, shell=True, stdout=build_log_file)

        # Remove reference results: in git, and then again for a good measure
        # with rm, as git might not remove things fully if there are empty
        # directories involved.
        if git:
            run_cmd(f"git rm -r -q '{ref_results_path}'")
        shutil.rmtree(ref_results_path)

        # Replace reference results with a freshly computed once.
        shutil.copytree(created_results_path, ref_results_path, symlinks=True)

        # Run cleanup script.
        SATestBuild.run_cleanup_script(project_dir, build_log_file)

        SATestBuild.normalize_reference_results(
            project_dir, ref_results_path, project.mode)

        # Clean up the generated difference results.
        SATestBuild.cleanup_reference_results(ref_results_path)

        if git:
            run_cmd(f"git add '{ref_results_path}'")
Пример #3
0
def update_reference_results(project_name: str, build_mode: int):
    project_info = SATestBuild.ProjectInfo(project_name, build_mode)
    tester = SATestBuild.ProjectTester(project_info)
    project_dir = tester.get_project_dir()

    tester.is_reference_build = True
    ref_results_path = os.path.join(project_dir, tester.get_output_dir())

    tester.is_reference_build = False
    created_results_path = os.path.join(project_dir, tester.get_output_dir())

    if not os.path.exists(created_results_path):
        print("New results not found, was SATestBuild.py previously run?",
              file=sys.stderr)
        sys.exit(1)

    build_log_path = SATestBuild.get_build_log_path(ref_results_path)
    build_log_dir = os.path.dirname(os.path.abspath(build_log_path))

    os.makedirs(build_log_dir)

    with open(build_log_path, "w+") as build_log_file:

        def run_cmd(command: str):
            if Verbose:
                print(f"Executing {command}")
            check_call(command, shell=True, stdout=build_log_file)

        # Remove reference results: in git, and then again for a good measure
        # with rm, as git might not remove things fully if there are empty
        # directories involved.
        run_cmd(f"git rm -r -q '{ref_results_path}'")
        shutil.rmtree(ref_results_path)

        # Replace reference results with a freshly computed once.
        shutil.copytree(created_results_path, ref_results_path, symlinks=True)

        # Run cleanup script.
        SATestBuild.run_cleanup_script(project_dir, build_log_file)

        SATestBuild.normalize_reference_results(project_dir, ref_results_path,
                                                build_mode)

        # Clean up the generated difference results.
        SATestBuild.cleanup_reference_results(ref_results_path)

        run_cmd(f"git add '{ref_results_path}'")
Пример #4
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}")