Skip to content

Commit

Permalink
Merge ../defects4j-branch-master into version-3
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed May 30, 2024
2 parents 272940d + 90d4ecd commit 22870d3
Show file tree
Hide file tree
Showing 49 changed files with 464 additions and 169 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ jobs:
JDK_ARCH: x64
JDK_VERSION: 8u192
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1
show-progress: false
- name: Cache JDK
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-jdk
with:
path: ~/.java
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ RUN \
apt-get install -y openjdk-8-jdk \
git \
build-essential \
subversion \
perl \
curl \
unzip \
cpanminus \
make \
subversion \
perl \
curl \
unzip \
cpanminus \
make \
&& \
rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Steps to set up Defects4J

3. Add Defects4J's executables to your PATH:
- `export PATH=$PATH:"path2defects4j"/framework/bin`
("path2defects4j" points to the directory to which you cloned Defects4J; it
looks like "/user/yourComputerUserName/desktop/defects4j".)

4. Check installation:
- `defects4j info -p Lang`
Expand Down
2 changes: 1 addition & 1 deletion framework/bug-mining/Patch-Minimization-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Code refactoring may consist of one or more of the following:

### 2. Compiler directives and annotations

1. __Changes made to import statements that are not relevant to the bug fix should be removed__
1. __Changes made to import statements that are not relevant to the bug fix should be removed__
Although removing changes involving import statements might create new warnings of `unused import statements`, import statements would not communicate anything about the bug or the bug fix since they would only be necessary to support functions. It is also worth noting that these import statements could be completely removed by using the fully qualified function names.

2. __Changes made to @override statements can be removed under some circumstances__
Expand Down
3 changes: 0 additions & 3 deletions framework/bug-mining/initialize-project-and-collect-issues.pl
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ =head1 OPTIONS
system("tail -n +2 $PROJECTS_DIR/$PID/$BUGS_CSV_ACTIVE | cut -f 2- -d',' > $COMMIT_DB_FILE.orig");
# Find all versions that have not been mined
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");
}

print("Project $PID has been successfully initialized!\n");
15 changes: 15 additions & 0 deletions framework/core/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ The directory name of the local gradle repository (I<.gradle_local_home>).

our $GRADLE_LOCAL_HOME_DIR = ($ENV{'GRADLE_LOCAL_HOME_DIR'} // ".gradle_local_home");

#
# Check if we have the correct version of Java
#
# Run the 'java -version' command and capture its output
my $java_version_output = `java -version 2>&1`;

# Extract the imajor version number using regular expressions
if ($java_version_output =~ 'version "?(?:1\.)?(\K\d+)') {
if ($1 != 8) {
die ("Java 8 is required!\n\n");
}
} else {
die ("Failed to parse Java version! Is Java installed/on the execution path?\n\n");
}

#
# Check whether Defects4J has been properly initialized:
# - Project repos available?
Expand Down
33 changes: 32 additions & 1 deletion framework/core/Project.pm
Original file line number Diff line number Diff line change
Expand Up @@ -740,17 +740,48 @@ sub monitor_test {
my @log = `cat $log_file`;
foreach (@log) {
chomp;
s/\[Loaded ([^\$]*)(\$\S*)? from.*/$1/;
# Try to find the correspondent .java file of a given loaded class X.
#
# X could be
# - A system class, e.g., java.io.ObjectInput, which is ignored by the following
# procedure as it does not belong to the project under test.
# - A "normal" class for which there is indeed a correspondent X.java file.
# - A "normal" class named with one or more $ symbols, e.g., com.google.gson.internal.$Gson$Types
# from Gson-{14,16,18}.
#
s/\[Loaded (.*) from.*/$1/;
my $found = 0;
if (defined $src->{$_}) {
$found = 1;
push(@{$classes->{src}}, $_);
# Delete already loaded classes to avoid duplicates in the result
delete($src->{$_});
}
if (defined $test->{$_}) {
$found = 1;
push(@{$classes->{test}}, $_);
# Delete already loaded classes to avoid duplicates in the result
delete($test->{$_});
}
if ($found == 0) {
# The correspondent .java file of a given loaded class X has not been found.
#
# It might be that X is, for example, an inner class or anonymous class for which
# there is no correspondent .java file, e.g., org.apache.commons.math3.util.MathArrays$OrderDirection
# from Math-25. Thus, try to find the correspondent .java file of X's parent class.
#
s/([^\$]*)(\$\S*)?/$1/;
if (defined $src->{$_}) {
push(@{$classes->{src}}, $_);
# Delete already loaded classes to avoid duplicates in the result
delete($src->{$_});
}
if (defined $test->{$_}) {
push(@{$classes->{test}}, $_);
# Delete already loaded classes to avoid duplicates in the result
delete($test->{$_});
}
}
}
return $classes;
}
Expand Down
15 changes: 15 additions & 0 deletions framework/core/Project/JacksonDatabind.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ sub new {
#
sub _post_checkout {
my ($self, $rev_id, $work_dir) = @_;
my $vid = $self->{_vcs}->lookup_vid($rev_id);

# Fix compilation errors if necessary
my $compile_errors = "$PROJECTS_DIR/$self->{pid}/compile-errors/";
opendir(DIR, $compile_errors) or die "Could not find compile-errors directory.";
my @entries = readdir(DIR);
closedir(DIR);
foreach my $file (@entries) {
if ($file =~ /-(\d+)-(\d+).diff/) {
if ($vid >= $1 && $vid <= $2) {
$self->apply_patch($work_dir, "$compile_errors/$file")
or confess("Couldn't apply patch ($file): $!");
}
}
}

my $project_dir = "$PROJECTS_DIR/$self->{pid}";
# Check whether ant build file exists
Expand Down
4 changes: 2 additions & 2 deletions framework/core/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ sub ensure_valid_bid {
my $project_dir = "$PROJECTS_DIR/$pid";

if ( ! -e "${project_dir}" ) {
confess("Error: ${pid} is a non-existent project\n");
confess("Error: ${pid} is not a project id; for a list, see https://github.com/rjust/defects4j#the-projects\n");
}

if ( ! -e "${project_dir}/trigger_tests/${bid}" ) {
confess("Error: ${pid}-${bid} is a non-existent bug\n");
confess("Error: ${pid}-${bid} is a not a bug id; for a list, see ${project_dir}/trigger_tests\n");
}

# Instantiate the project and get the list of all active bug ids
Expand Down
7 changes: 7 additions & 0 deletions framework/lib/test_generation/bin/evosuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ if [ $D4J_TEST_MODE != "regression" ]; then
die "Unsupported test mode: $D4J_TEST_MODE"
fi

# Confirm D4J_FILE_TARGET_CLASSES ends in a newline character. Not ending with a
# newline will lead to the below call to `wc -l` not counting the final line.
# This is very likely a mistake.
if [[ $(tail -c1 "$D4J_FILE_TARGET_CLASSES" | wc -l) -eq 0 ]]; then
die "File did not end in newline: $D4J_FILE_TARGET_CLASSES"
fi

# Compute the budget per target class; evenly split the time for search and assertions
num_classes=$(cat $D4J_FILE_TARGET_CLASSES | wc -l)
budget=$(echo "$D4J_TOTAL_BUDGET/2/$num_classes" | bc)
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
14 changes: 3 additions & 11 deletions framework/projects/Cli/patches/3.src.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
diff --git a/src/java/org/apache/commons/cli/TypeHandler.java b/src/java/org/apache/commons/cli/TypeHandler.java
index 0a0aa72..1ddde5b 100644
index 0a0aa72..addf90b 100644
--- a/src/java/org/apache/commons/cli/TypeHandler.java
+++ b/src/java/org/apache/commons/cli/TypeHandler.java
@@ -22,6 +22,7 @@ import java.net.URL;

import java.util.Date;

+import org.apache.commons.lang.math.NumberUtils;
/**
* This is a temporary implementation. TypeHandler will handle the
* pluggableness of OptionTypes and it will direct all of these types
@@ -158,17 +159,7 @@ public class TypeHandler {
@@ -158,17 +158,7 @@ public class TypeHandler {
{
try
{
Expand All @@ -25,7 +17,7 @@ index 0a0aa72..1ddde5b 100644
- return Long.valueOf(str);
- }
- }
+ return NumberUtils.createNumber(str);
+ return org.apache.commons.lang.math.NumberUtils.createNumber(str);
}
catch (NumberFormatException nfe)
{
14 changes: 3 additions & 11 deletions framework/projects/Cli/patches/36.src.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,15 @@ index dc6d5db..322053f 100644
/** the name of the selected option */
private String selected;
diff --git a/src/main/java/org/apache/commons/cli/Options.java b/src/main/java/org/apache/commons/cli/Options.java
index 796fe5c..0ee4eea 100644
index 796fe5c..721baaf 100644
--- a/src/main/java/org/apache/commons/cli/Options.java
+++ b/src/main/java/org/apache/commons/cli/Options.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -57,7 +58,7 @@ public class Options implements Serializable
@@ -57,7 +57,7 @@ public class Options implements Serializable
private final List<Object> requiredOpts = new ArrayList<Object>();

/** a map of the option groups */
- private final Map<String, OptionGroup> optionGroups = new LinkedHashMap<String, OptionGroup>();
+ private final Map<String, OptionGroup> optionGroups = new HashMap<String, OptionGroup>();
+ private final Map<String, OptionGroup> optionGroups = new java.util.HashMap<String, OptionGroup>();

/**
* Add the specified option group.
30 changes: 11 additions & 19 deletions framework/projects/Closure/patches/153.src.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/com/google/javascript/jscomp/Normalize.java b/src/com/google/javascript/jscomp/Normalize.java
index c14ac8f1..4c99858e 100644
index c14ac8f..4c99858 100644
--- a/src/com/google/javascript/jscomp/Normalize.java
+++ b/src/com/google/javascript/jscomp/Normalize.java
@@ -628,7 +628,6 @@ class Normalize implements CompilerPass {
Expand Down Expand Up @@ -54,18 +54,10 @@ index c14ac8f1..4c99858e 100644
}

diff --git a/src/com/google/javascript/jscomp/SyntacticScopeCreator.java b/src/com/google/javascript/jscomp/SyntacticScopeCreator.java
index eb6e1eab..04bafcf0 100644
index eb6e1ea..9494792 100644
--- a/src/com/google/javascript/jscomp/SyntacticScopeCreator.java
+++ b/src/com/google/javascript/jscomp/SyntacticScopeCreator.java
@@ -20,6 +20,7 @@ import com.google.common.base.Preconditions;
import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token;
+import com.google.javascript.rhino.jstype.JSType;


/**
@@ -91,7 +92,7 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -91,7 +91,7 @@ class SyntacticScopeCreator implements ScopeCreator {
// been declared in the outer scope.
String fnName = fnNameNode.getString();
if (!fnName.isEmpty() && NodeUtil.isFunctionExpression(n)) {
Expand All @@ -74,7 +66,7 @@ index eb6e1eab..04bafcf0 100644
}

// Args: Declare function variables
@@ -99,7 +100,7 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -99,7 +99,7 @@ class SyntacticScopeCreator implements ScopeCreator {
for (Node a = args.getFirstChild(); a != null;
a = a.getNext()) {
Preconditions.checkState(a.getType() == Token.NAME);
Expand All @@ -83,7 +75,7 @@ index eb6e1eab..04bafcf0 100644
}

// Body
@@ -121,7 +122,9 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -121,7 +121,9 @@ class SyntacticScopeCreator implements ScopeCreator {
for (Node child = n.getFirstChild();
child != null;) {
Node next = child.getNext();
Expand All @@ -94,7 +86,7 @@ index eb6e1eab..04bafcf0 100644
child = next;
}
return;
@@ -136,7 +139,7 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -136,7 +138,7 @@ class SyntacticScopeCreator implements ScopeCreator {
// This is invalid, but allow it so the checks can catch it.
return;
}
Expand All @@ -103,7 +95,7 @@ index eb6e1eab..04bafcf0 100644
return; // should not examine function's children

case Token.CATCH:
@@ -148,7 +151,7 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -148,7 +150,7 @@ class SyntacticScopeCreator implements ScopeCreator {
final Node var = n.getFirstChild();
final Node block = var.getNext();

Expand All @@ -112,7 +104,7 @@ index eb6e1eab..04bafcf0 100644
scanVars(block, n);
return; // only one child to scan

@@ -174,7 +177,8 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -174,7 +176,8 @@ class SyntacticScopeCreator implements ScopeCreator {
*/
interface RedeclarationHandler {
void onRedeclaration(
Expand All @@ -122,7 +114,7 @@ index eb6e1eab..04bafcf0 100644
}

/**
@@ -182,8 +186,8 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -182,8 +185,8 @@ class SyntacticScopeCreator implements ScopeCreator {
*/
private class DefaultRedeclarationHandler implements RedeclarationHandler {
public void onRedeclaration(
Expand All @@ -133,14 +125,14 @@ index eb6e1eab..04bafcf0 100644

// Don't allow multiple variables to be declared at the top level scope
if (scope.isGlobal()) {
@@ -228,17 +232,16 @@ class SyntacticScopeCreator implements ScopeCreator {
@@ -228,17 +231,16 @@ class SyntacticScopeCreator implements ScopeCreator {
* @param n The node corresponding to the variable name.
* @param declaredType The variable's type, according to JSDoc
*/
- private void declareVar(Node n) {
- Preconditions.checkState(n.getType() == Token.NAME);
+ private void declareVar(String name, Node n, Node parent,
+ Node gramps, JSType declaredType,
+ Node gramps, com.google.javascript.rhino.jstype.JSType declaredType,
+ Node nodeWithLineNumber) {

- CompilerInput input = compiler.getInput(sourceName);
Expand Down
18 changes: 5 additions & 13 deletions framework/projects/Closure/patches/158.src.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
index e2e102c6..3a7f427f 100644
index e2e102c..3a7f427 100644
--- a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
+++ b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
@@ -194,11 +194,12 @@ abstract class AbstractCommandLineRunner<A extends Compiler,
Expand Down Expand Up @@ -79,7 +79,7 @@ index e2e102c6..3a7f427f 100644
- }
}
diff --git a/src/com/google/javascript/jscomp/CommandLineRunner.java b/src/com/google/javascript/jscomp/CommandLineRunner.java
index b1a7472a..d9a381b5 100644
index b1a7472..d9a381b 100644
--- a/src/com/google/javascript/jscomp/CommandLineRunner.java
+++ b/src/com/google/javascript/jscomp/CommandLineRunner.java
@@ -23,7 +23,6 @@ import com.google.common.collect.Maps;
Expand Down Expand Up @@ -200,25 +200,17 @@ index b1a7472a..d9a381b5 100644
.setCharset(flags.charset)
.setManageClosureDependencies(flags.manage_closure_dependencies)
diff --git a/src/com/google/javascript/jscomp/DiagnosticGroups.java b/src/com/google/javascript/jscomp/DiagnosticGroups.java
index cf0beda1..271492f2 100644
index cf0beda..d2d38c5 100644
--- a/src/com/google/javascript/jscomp/DiagnosticGroups.java
+++ b/src/com/google/javascript/jscomp/DiagnosticGroups.java
@@ -20,6 +20,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

+import java.util.List;
import java.util.Map;

/**
@@ -182,10 +183,12 @@ public class DiagnosticGroups {
@@ -182,10 +182,12 @@ public class DiagnosticGroups {
/**
* Adds warning levels by name.
*/
- void setWarningLevel(CompilerOptions options,
- String name, CheckLevel level) {
+ void setWarningLevels(CompilerOptions options,
+ List<String> diagnosticGroups, CheckLevel level) {
+ java.util.List<String> diagnosticGroups, CheckLevel level) {
+ for (String name : diagnosticGroups) {
DiagnosticGroup group = forName(name);
Preconditions.checkNotNull(group, "No warning class for name: " + name);
Expand Down
2 changes: 2 additions & 0 deletions framework/projects/Gson/loaded_classes/10.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ com.google.gson.annotations.SerializedName
com.google.gson.FieldNamingPolicy
com.google.gson.FieldNamingStrategy
com.google.gson.Gson
com.google.gson.internal.$Gson$Preconditions
com.google.gson.internal.$Gson$Types
com.google.gson.internal.bind.ArrayTypeAdapter
com.google.gson.internal.bind.CollectionTypeAdapterFactory
com.google.gson.internal.bind.DateTypeAdapter
Expand Down
Loading

0 comments on commit 22870d3

Please sign in to comment.