Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhfocus committed Jan 3, 2022
2 parents 3a8f97a + 6875a0e commit 6071840
Show file tree
Hide file tree
Showing 262 changed files with 9,717 additions and 8 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
Notably, each bug is composed of a buggy version, a fixed version, a ***concise patch*** (bug-fixing changes only), and one or more triggering test cases.

# Contents of growingBugs
To date, growingBugs contains
**`1404`** bugs
from open-source Java projects.
To date, growingBugs contains **`1404`** bugs from open-source Java projects.

| | Project ID | Project name | SubProject name |Number of bugs | Bug IDs |
|-----------------|-----------------|----------------------------|--------------------------------|-------------:|-------------------|
Expand Down
Empty file modified framework/bug-mining/bug_mining_projects_info.txt
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions framework/bug-mining/initialize-project-and-collect-issues.pl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ =head1 OPTIONS
. " -n $NAME"
. " -w $WORK_DIR"
. " -r $REPOSITORY_URL",
"Configuring project for Defects4J") or die "Failed to configure project for Defects4J!";
"Configuring project for Defects4J") ;

# Does project exist in the Defects4J database? If yes, copy over the required
# (and existing) files to build the project.
Expand Down Expand Up @@ -183,7 +183,7 @@ =head1 OPTIONS
system("grep -vFf $COMMIT_DB_FILE.orig $COMMIT_DB_FILE > $COMMIT_DB_FILE.filter && mv $COMMIT_DB_FILE.filter $COMMIT_DB_FILE");
# Print header to the active bugs csv
my $active_header = $BUGS_CSV_BUGID.",".$BUGS_CSV_COMMIT_BUGGY.",".$BUGS_CSV_COMMIT_FIXED.",".$BUGS_CSV_ISSUE_ID.",".$BUGS_CSV_ISSUE_URL;
system("echo $active_header > $COMMIT_DB_FILE.new && cat $COMMIT_DB_FILE >> $COMMIT_DB_FILE.new && mv $COMMIT_DB_FILE.new $COMMIT_DB_FILE");
system(" $active_header > $COMMIT_DB_FILE.new && cat $COMMIT_DB_FILE >> $COMMIT_DB_FILE.new && mv $COMMIT_DB_FILE.new $COMMIT_DB_FILE");
}

print("Project $PID has been successfully initialized!\n");
4 changes: 2 additions & 2 deletions framework/bug-mining/initialize-revisions.pl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ sub _init_version {
system("mkdir -p $ANALYZER_OUTPUT/$bid");
if (-e "$work_dir/pom.xml") {
#here are two patterns : one is just deleting -SNAPSHOT , the other is changing the version and deleting -SNAPSHOT
#system("sed -i \"s/<xmlsec\.version>2\.2\.0-SNAPSHOT<\/xmlsec\.version>/<xmlsec\.version>2\.2\.3-SNAPSHOT<\/xmlsec\.version>/g\" `grep SNAPSHOT -rl $temp_work_dir`");
#system("sed -i \"s/<xmlsec\.version>2\.2\.0-SNAPSHOT<\/xmlsec\.version>/<xmlsec\.version>2\.2\.3-SNAPSHOT<\/xmlsec\.version>/g\" `grep SNAPSHOT -rl $temp_work_dir`");
#sed -i \"s/-SNAPSHOT//g\" `grep SNAPSHOT -rl $temp_work_dir`"
#system("sed -i \"s/\<bundle\.version\>2\.0-SNAPSHOT\<\\/bundle\.version\>/\<bundle\.version\>2\.0\<\\/bundle\.version\>/g\" `grep SNAPSHOT -rl $temp_work_dir`");

Expand All @@ -154,7 +154,7 @@ sub _init_version {

# Run maven-ant plugin and overwrite the original build.xml whenever a maven build file exists
my $cmd = " cd $work_dir" .
" && mvn ant:ant -Doverwrite=true 2>&1 -Dhttps.protocols=TLSv1.2" .
" && mvn ant:ant -Doverwrite=true 2>&1 -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 " .
" && patch build.xml $PROJECT_DIR/build.xml.patch 2>&1" .
" && rm -rf $GEN_BUILDFILE_DIR/$rev_id && mkdir -p $GEN_BUILDFILE_DIR/$rev_id 2>&1" .
" && cp maven-build.* $GEN_BUILDFILE_DIR/$rev_id 2>&1" .
Expand Down
243 changes: 243 additions & 0 deletions framework/core/Project/Sdk_core.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2014-2019 René Just, Darioush Jalali, and Defects4J contributors.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-------------------------------------------------------------------------------

=pod
=head1 NAME
Project::Sdk_core.pm -- L<Project> submodule for sdk-core.
=head1 DESCRIPTION
This module provides all project-specific configurations and subroutines for the
sdk-core project.
=cut
package Project::Sdk_core;

use strict;
use warnings;

use Constants;
use Vcs::Git;

our @ISA = qw(Project);
my $PID = "Sdk_core";

sub new {
@_ == 1 or die $ARG_ERROR;
my ($class) = @_;

my $name = "sdk-core";
my $vcs = Vcs::Git->new($PID,
"$REPO_DIR/$name.git",
"$PROJECTS_DIR/$PID/$BUGS_CSV_ACTIVE",
\&_post_checkout);

return $class->SUPER::new($PID, $name, $vcs);
}

##
## Determines the directory layout for sources and tests
##
#sub determine_layout {
# @_ == 2 or die $ARG_ERROR;
# my ($self, $rev_id) = @_;
# my $dir = $self->{prog_root};

# # Add additional layouts if necessary
# my $result = _ant_layout($dir) // _maven_layout($dir);
# die "Unknown layout for revision: ${rev_id}" unless defined $result;
# return $result;
#}

#
# Post-checkout tasks include, for instance, providing cached build files,
# fixing compilation errors, etc.
#
sub _post_checkout {
my ($self, $rev_id, $work_dir,$SUBPROJ) = @_;
#print("$SUBPROJ !\n");
my $project_dir = "$PROJECTS_DIR/$self->{pid}";
$work_dir.="/$SUBPROJ";
# Check whether ant build file exists
my $build_files_dir = "$PROJECTS_DIR/$PID/build_files/$rev_id";
if (-d "$build_files_dir") {
Utils::exec_cmd("cp -r $build_files_dir/* $work_dir", "Copy generated Ant build file") or die;
}

if (-e "$work_dir/build.xml"){
rename("$work_dir/build.xml", "$work_dir/build.xml".'.bak');
open(IN, '<'."$work_dir/build.xml".'.bak') or die $!;
open(OUT, '>'."$work_dir/build.xml") or die $!;
while(<IN>) {

$_ =~ s/compile-tests/compile\.tests/g;
#$_ =~ s/=src\//=$SUBPROJ\/src\//g;
#$_ =~ s/classesdir/classes\.dir/g;
#$_ =~ s/testclasses\.dir/test\.classes\.dir/g;

#support java8
$_ =~ s/fork="false"/fork="true"/g;
print OUT $_;
}
close(IN);
close(OUT);
}

if (-e "$work_dir/maven-build.xml"){
rename("$work_dir/maven-build.xml", "$work_dir/maven-build.xml".'.bak');
open(IN, '<'."$work_dir/maven-build.xml".'.bak') or die $!;
open(OUT, '>'."$work_dir/maven-build.xml") or die $!;
while(<IN>) {
$_ =~ s/compile-tests/compile\.tests/g;
#$_ =~ s/classesdir/classes\.dir/g;
#$_ =~ s/testclasses\.dir/test\.classes\.dir/g;
#$_ =~ s/src\//$SUBPROJ\/src\//g;
#support java8
$_ =~ s/fork="false"/fork="true"/g;
print OUT $_;
}
close(IN);
close(OUT);
}
if (-e "$work_dir/maven-build.properties"){
rename("$work_dir/maven-build.properties", "$work_dir/maven-build.properties".'.bak');
open(IN, '<'."$work_dir/maven-build.properties".'.bak') or die $!;
open(OUT, '>'."$work_dir/maven-build.properties") or die $!;
while(<IN>) {
$_ =~ s/compile-tests/compile\.tests/g;
#$_ =~ s/=src\//=$SUBPROJ\/src\//g;
#$_ =~ s/classesdir/classes\.dir/g;
#$_ =~ s/testclasses\.dir/test\.classes\.dir/g;

#support java8
$_ =~ s/fork="false"/fork="true"/g;
print OUT $_;
}
close(IN);
close(OUT);
}

#exclude the test you don't need
my $exclude_test1="$work_dir/src/tests/junit/org/apache/tools/ant/taskdefs/xxx.java";
if (-e $exclude_test1){
rename($exclude_test1,$exclude_test1.".bak");
#open(OUT, '>'.$exclude_test1) or die $!;
#my $converted_file = `iconv -f iso-8859-1 -t utf-8 "$exclude_test1.bak"`;
#print OUT $converted_file;
#close(OUT);
}

}


#
# This subroutine is called by the bug-mining framework for each revision during
# the initialization of the project. Example uses are: converting and caching
# build files or other time-consuming tasks, whose results should be cached.
#
sub initialize_revision {
my ($self, $rev_id, $vid,$sub_project) = @_;
$self->SUPER::initialize_revision($rev_id);

my $work_dir = $self->{prog_root};
my $result = _ant_layout($work_dir) // _maven_layout($work_dir);

if (-e "$work_dir/src/main/java" and -e "$work_dir/src/test/java"){
$result = {src=>"src/main/java", test=>"src/test/java"} unless defined $result;
}
elsif (-e "$work_dir/src/main/java" and -e "$work_dir/src/tests/java"){
$result = {src=>"src/main/java", test=>"src/tests/java"} unless defined $result;
}
elsif (-e "$work_dir/src/main" and -e "$work_dir/src/testcases"){
$result = {src=>"src/main", test=>"src/testcases"} unless defined $result;
}
elsif (-e "$work_dir/src/main" and -e "$work_dir/src/tests/junit"){
$result = {src=>"src/main", test=>"src/tests/junit"} unless defined $result;
}
elsif (-e "$work_dir/src/main" and -e "$work_dir/src/tests"){
$result = {src=>"src/main", test=>"src/tests"} unless defined $result;
}
elsif (-e "$work_dir/src/java" and -e "$work_dir/src/test"){
$result = {src=>"src/java", test=>"src/test"} unless defined $result;
}
elsif (-e "$work_dir/src/java" and -e "$work_dir/src/tests"){
$result = {src=>"src/java", test=>"src/tests"} unless defined $result;
}
else {
if (-e "$work_dir"){
system("tree -d $work_dir");
die "Unknown directory layout" unless defined $result;
}
else {
$result = {src=>"$sub_project", test=>"$sub_project"} unless defined $result;
}
}

$self->_add_to_layout_map($rev_id, $result->{src}, $result->{test});
$self->_cache_layout_map(); # Force cache rebuild
}

#
# Distinguish between project layouts and determine src and test directories.
# Each _layout subroutine returns undef if it doesn't match the layout of the
# checked-out version. Otherwise, it returns a hash that provides the src and
# test directory, relative to the working directory.
#

#
# Existing Ant build.xml and default.properties
#
sub _ant_layout {
@_ == 1 or die $ARG_ERROR;
my ($dir) = @_;
my $src = `grep "source.home" $dir/default.properties 2>/dev/null`;
my $test = `grep "test.home" $dir/default.properties 2>/dev/null`;

# Check whether this layout applies to the checked-out version
return undef if ($src eq "" || $test eq "");

$src =~ s/\s*source.home\s*=\s*(\S+)\s*/$1/;
$test=~ s/\s*test.home\s*=\s*(\S+)\s*/$1/;

return {src=>$src, test=>$test};
}

#
# Generated build.xml (from mvn ant:ant) with maven-build.properties
#
sub _maven_layout {
@_ == 1 or die $ARG_ERROR;
my ($dir) = @_;
my $src = `grep "maven.build.srcDir.0" $dir/maven-build.properties 2>/dev/null`;
my $test = `grep "maven.build.testDir.0" $dir/maven-build.properties 2>/dev/null`;

return undef if ($src eq "" || $test eq "");

$src =~ s/\s*maven\.build\.srcDir\.0\s*=\s*(\S+)\s*/$1/;
$test=~ s/\s*maven\.build\.testDir\.0\s*=\s*(\S+)\s*/$1/;

return {src=>$src, test=>$test};
}

1;
2 changes: 1 addition & 1 deletion framework/core/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ sub get_failing_tests {
if ($lines[$i] =~ /junit\./) {
# Skip junit entries in the stack trace
++$i;
} elsif ($lines[$i] =~ /$classname\.java:(\d+)/) {
} elsif ($lines[$i] =~ /'\Q$classname\E'\.java:(\d+)/ ) {
# We found the right entry in the stack trace
my $line = $1;
$list->{asserts}->{"${class}::$method"} = $line;
Expand Down
Empty file modified framework/lib/Bug_Builder.jar
100644 → 100755
Empty file.
Loading

0 comments on commit 6071840

Please sign in to comment.