Example #1
0
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)
Example #2
0
def run(project):
    path_to_root_project = toolbox.get_absolute_path(
        toolbox.prefix_current_dataset + project + "/")
    project_json = toolbox.get_json_file(
        toolbox.get_absolute_path(toolbox.prefix_current_dataset + project))
    commits = project_json['commits']
    for commit in commits:
        commit_setter.set_commit(path_to_root_project, project,
                                 commits.index(commit))
        toolbox.print_and_call_no_redirection(
            [toolbox.maven_home + "mvn", "clean", "test"],
            cwd=path_to_root_project)
        commit['nb_test_per_commit'] = count_tests(path_to_root_project)
    with open(
            toolbox.get_absolute_path(toolbox.prefix_current_dataset + project)
            + '.json', 'w') as outfile:
        json.dump(project_json, outfile)
def run(project, index_commit):
    project_json = toolbox.get_json_file(
        toolbox.get_absolute_path(toolbox.prefix_current_dataset + project))
    beg = 0 if index_commit == -1 else index_commit
    end = index_commit if index_commit == -1 else index_commit + 1
    output_path_to_json = toolbox.get_absolute_path(
        toolbox.prefix_result + project + "/behavioral-encoding-check.json")
    if os.path.isfile(output_path_to_json):
        data = toolbox.get_json_file(
            toolbox.get_absolute_path(output_path_to_json))
    else:
        data = {project: {}}
    data_project = data[project]
    commits = project_json["commits"]
    for commit in commits:
        if not commits.index(commit) in data_project:
            commit_setter.set_commit(
                toolbox.get_absolute_path(toolbox.prefix_current_dataset +
                                          project), project,
                commits.index(commit))
            prefix_folder_result = toolbox.get_absolute_path(
                toolbox.prefix_result + project + "/" +
                toolbox.get_output_folder_for_commit(commit, commits) + "/")
            key_commit = str(commits.index(commit)) + "_" + str(
                commit["sha"][0:7])
            for configuration in [
                    "assert_amplification", "input_amplification"
            ]:
                value = run_for_configuration(configuration,
                                              prefix_folder_result, commit)
                if not value is None:
                    if not key_commit in data_project:
                        data_project[key_commit] = {}
                    data_project[key_commit][configuration] = value
    with open(output_path_to_json, 'w') as outfile:
        json.dump(data, outfile)
Example #4
0
File: run.py Project: 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)
Example #5
0
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")