コード例 #1
0
def run_for_configuration(configuration, prefix_folder_result, commit):
    folder_result = prefix_folder_result + "/" + configuration + "/"
    if os.path.isdir(folder_result):
        for file in os.listdir(folder_result):
            if os.path.isdir(folder_result + file):
                toolbox.set_output_log_path(
                    toolbox.get_absolute_path(folder_result +
                                              "behavioral_encoding_check.log"))
                path_to_concerned_module = toolbox.get_absolute_path(
                    toolbox.prefix_current_dataset + project + "/" +
                    commit["concernedModule"])
                print path_to_concerned_module
                path_concerned_pom = path_to_concerned_module + "/pom.xml"
                test_suite_switcher.switch(folder_result, path_concerned_pom)
                junit_enforcer.enforce(path_concerned_pom)
                toolbox.print_and_call(
                    [
                        "mvn", "clean", "install", "-DskipTests", "--quiet",
                        "-Dcheckstyle.skip=true", "-Denforcer.skip=true",
                        "-Dxwiki.clirr.skip=true"
                    ],
                    cwd=toolbox.get_absolute_path(
                        toolbox.prefix_current_dataset + project + "/"))
                toolbox.print_and_call(["mvn", "clean", "test"],
                                       cwd=path_to_concerned_module)
                path_to_surefire_report = path_to_concerned_module + suffix_target_surefire_reports
                for report in os.listdir(path_to_surefire_report):
                    if report.startswith("TEST-") and report.endswith(".xml"):
                        return containsFailureOrError(path_to_surefire_report +
                                                      "/" + report)
    return None
コード例 #2
0
ファイル: diff_coverage.py プロジェクト: danglotb/DCI
def compute_diff_coverage_for_given_commit(path_to_concerned_module,
                                           path_to_concerned_module_other,
                                           commit_json, commits, key_commit,
                                           prefix_result):
    output_path = toolbox.get_absolute_path(
        toolbox.prefix_result + project + "/" +
        toolbox.get_output_folder_for_commit(commit_json, commits) + "/" +
        prefix_result + "_" +
        toolbox.name_of_csv_with_list_of_test_that_execute_the_changes +
        ".csv")
    toolbox.set_output_log_path(
        toolbox.get_absolute_path(
            toolbox.prefix_result + project + "/" +
            toolbox.get_output_folder_for_commit(commit_json, commits) + "/" +
            prefix_result + "_" +
            toolbox.name_of_csv_with_list_of_test_that_execute_the_changes +
            ".log"))
    concerned_module = commit_json["concernedModule"]
    cmd = [
        toolbox.maven_home + "mvn", "clean",
        "eu.stamp-project:diff-test-selection:0.5-SNAPSHOT:list",
        "-DpathToDiff=patch.diff",
        "-DpathToOtherVersion=" + path_to_concerned_module_other,
        "-Dmodule=" + concerned_module, "-DoutputPath=" + output_path
    ]
    toolbox.print_and_call_in_a_file(" ".join(cmd),
                                     cwd=path_to_concerned_module)
コード例 #3
0
def install(owner, project):
    toolbox.set_output_log_path(toolbox.prefix_result + project +
                                "_install.log")

    toolbox.print_and_call_in_a_file(" ".join([
        "git", "clone", toolbox.prefix_url_github + owner + "/" + project,
        toolbox.prefix_dataset + project
    ]))

    toolbox.print_and_call_in_a_file(" ".join([
        "git", "clone", toolbox.prefix_url_github + owner + "/" + project,
        toolbox.prefix_dataset + project + toolbox.suffix_parent
    ]))
コード例 #4
0
ファイル: run-given-indexes.py プロジェクト: danglotb/DCI
def run(project, indices, amplifiers):
    path_to_project_json = toolbox.prefix_current_dataset + project + ".json"
    project_json = toolbox.get_json_file(path_to_project_json)
    path_to_project_root = toolbox.prefix_dataset + project
    commits = project_json["commits"]

    # for each commits.
    for index in indices:
        commit = commits[index]
        output_path = toolbox.get_absolute_path(
            toolbox.prefix_result + project + "/" +
            toolbox.get_output_folder_for_commit(commit, commits))
        if amplifiers:
            output_path = output_path + "/input_amplification"
        else:
            output_path = output_path + "/assert_amplification"
        toolbox.create(output_path)
        toolbox.set_output_log_path(output_path + "/commit_set.log")
        #  1) set up both version of the program
        commit_setter.set_commit(path_to_project_root, project,
                                 commits.index(commit))
        toolbox.set_output_log_path(output_path + "/amplification.log")
        path_to_concerned_module = toolbox.get_absolute_path(
            toolbox.prefix_dataset + project + "/" + commit["concernedModule"])
        path_to_concerned_module_parent = toolbox.get_absolute_path(
            toolbox.prefix_dataset + project + toolbox.suffix_parent + "/" +
            commit["concernedModule"])
        path_to_test_that_executes_the_changes = toolbox.get_path_to_csv_file(
            project, commit, commits)
        preparation.prepare(project)
        # run now dspot with maven plugin
        cmd = [
            toolbox.maven_home + "mvn",
            "eu.stamp-project:dspot-maven:1.1.1-SNAPSHOT:amplify-unit-tests",
            "-Dpath-to-test-list-csv=" +
            path_to_test_that_executes_the_changes, "-Dverbose=true",
            "-Dtest-criterion=ChangeDetectorSelector",
            "-Doutput-path=" + output_path,
            "-Dpath-to-second-version=" + path_to_concerned_module,
            "-Dgenerate-new-test-class=true", "-Dclean=true", "-X"
        ]
        if amplifiers:
            cmd.append(
                "-Damplifiers=TestDataMutator,MethodAdd,MethodRemove,MethodGeneratorAmplifier,ReturnValueAmplifier,NullifierAmplifier"
            )
            cmd.append("-Diteration=3")
            cmd.append("-Dbudgetizer=SimpleBudgetizer")
        cmd = preparation.add_needed_options(cmd, project)
        toolbox.print_and_call_in_a_file(" ".join(cmd),
                                         cwd=path_to_concerned_module_parent)
コード例 #5
0
ファイル: run.py プロジェクト: danglotb/DCI
def run(project, index_begin, index_end, amplifiers):
    path_to_project_json = toolbox.prefix_current_dataset + project + ".json"
    project_json = toolbox.get_json_file(path_to_project_json)
    path_to_project_root = toolbox.prefix_dataset + project
    commits = project_json["commits"]

    # for each commits.
    for commit in commits[index_begin:index_end]:
        log_path = toolbox.get_absolute_path(toolbox.prefix_result + project + "/commits_" + str(commits.index(commit)))
        if amplifiers:
            log_path = log_path + "_amplifiers"
        log_path = log_path + ".log"

        toolbox.set_output_log_path(log_path)
        #  1) set up both version of the program
        commit_setter.set_commit(path_to_project_root, project, commits.index(commit))

        path_to_concerned_module = toolbox.get_absolute_path(
            toolbox.prefix_dataset + project + "/" + commit["concernedModule"])
        path_to_concerned_module_parent = toolbox.get_absolute_path(
            toolbox.prefix_dataset + project + toolbox.suffix_parent + "/" + commit["concernedModule"])
        create_diff(commit["parent"], path_to_concerned_module)

        path_to_test_that_executes_the_changes = toolbox.get_path_to_csv_file(project, str(commits.index(commit)))
        preparation.prepare(project)

        # if the list does not exists, then compute it
        if not os.path.isfile(path_to_test_that_executes_the_changes):
            # must build all the project, i.e. installing the version
            cmd = [toolbox.maven_home + "mvn", "clean", "install", "-DskipTests"]
            toolbox.print_and_call_in_a_file(" ".join(cmd), cwd=path_to_project_root)

            get_list_of_tests_that_execute_changes(commit["concernedModule"],
                                                   path_to_concerned_module,
                                                   path_to_concerned_module_parent,
                                                   path_to_test_that_executes_the_changes)

        output_path = toolbox.get_absolute_path(toolbox.prefix_result + project + "/commit_" + str(commits.index(commit)))
        if amplifiers:
            output_path = output_path + "_amplifiers"

        # run now dspot with maven plugin
        cmd = [
            toolbox.maven_home + "mvn",
            "eu.stamp-project:dspot-maven:1.1.1-SNAPSHOT:amplify-unit-tests",
            "-Dpath-to-test-list-csv=" + path_to_test_that_executes_the_changes,
            "-Dverbose=True",
            "-Dtest-criterion=ChangeDetectorSelector",
            "-Doutput-path=" + output_path,
            "-Dpath-to-second-version=" + path_to_concerned_module_parent,
            "-Dgenerate-new-test-class=true",
            "-Dclean=true"
        ]

        if amplifiers:
            cmd.append("-Damplifiers=AllLiteralAmplifiers,MethodAdd,MethodRemove,MethodGeneratorAmplifier,ReturnValueAmplifier,NullifierAmplifier")
            cmd.append("-Diteration=3")
            cmd.append("-Dbudgetizer=SimpleBudgetizer")

        cmd = preparation.add_needed_options(cmd, project)
        toolbox.print_and_call_in_a_file(" ".join(cmd), cwd=path_to_concerned_module)
コード例 #6
0
ファイル: diff_coverage.py プロジェクト: danglotb/DCI
def diff_coverage(project):
    project_json = toolbox.get_json_file(
        toolbox.get_absolute_path(toolbox.prefix_current_dataset + project))
    commits = project_json["commits"]
    for commit_json in commits:
        concerned_module = commit_json["concernedModule"]
        commit_setter.set_commit(
            toolbox.get_absolute_path(toolbox.prefix_current_dataset +
                                      project), project,
            commits.index(commit_json))
        path_to_concerned_module_parent = toolbox.get_absolute_path(
            toolbox.prefix_current_dataset + project + "_parent/" +
            concerned_module)
        path_to_concerned_module = toolbox.get_absolute_path(
            toolbox.prefix_current_dataset + project + "/" + concerned_module)
        if not concerned_module == "":
            toolbox.set_output_log_path(
                "trash.log")  # we don't care about the log of the installation
            path_to_project_root = toolbox.get_absolute_path(
                toolbox.prefix_current_dataset + project + "/")
            cmd = [
                toolbox.maven_home + "mvn", "clean", "install", "-DskipTests",
                "-Dmaven.compiler.source=1.8", "-Dmaven.compiler.target=1.8",
                "-Dmaven.compile.source=1.8", "-Dmaven.compile.target=1.8",
                "-Dcheckstyle.skip=true", "-Denforcer.skip=true",
                "-Dxwiki.clirr.skip=true"
            ]
            toolbox.print_and_call_in_a_file(" ".join(cmd),
                                             cwd=path_to_project_root)
        run.create_diff(
            commit_json["sha"],
            path_to_concerned_module_parent,
        )
        run.create_diff(
            commit_json["parent"],
            path_to_concerned_module,
        )
        shutil.copy(
            toolbox.get_absolute_path(path_to_concerned_module +
                                      "/patch.diff"),
            toolbox.get_absolute_path(
                toolbox.prefix_result + project + "/" +
                toolbox.get_output_folder_for_commit(commit_json, commits) +
                "/commit_coverage_patch.diff"))
        shutil.copy(
            toolbox.get_absolute_path(path_to_concerned_module_parent +
                                      "/patch.diff"),
            toolbox.get_absolute_path(
                toolbox.prefix_result + project + "/" +
                toolbox.get_output_folder_for_commit(commit_json, commits) +
                "/parent_coverage_patch.diff"))

        preparation.prepare(project)
        '''
        compute_diff_coverage_for_given_commit(path_to_concerned_module_parent,
                                               path_to_concerned_module,
                                               commit_json,
                                               commits,
                                               "sha",
                                               "parent_coverage"
                                               )
        '''
        compute_diff_coverage_for_given_commit(
            path_to_concerned_module, path_to_concerned_module_parent,
            commit_json, commits, "parent", "commit_coverage")