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)
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)
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")