Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate version-3 and Java-11 branches #594

Merged
merged 10 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
- run: carton exec ./test_bug_mining.sh
name: test_bug_mining.sh
working-directory: "./framework/test"
- run: carton exec ./test_style.sh
name: test_style.sh
working-directory: "./framework/test"

# Verify a few select bugs to detect serious breakages early.
- run: carton exec ./test_verify_bugs.sh -p Lang -b 24 -A
Expand Down
34 changes: 19 additions & 15 deletions framework/lib/test_generation/bin/_tool.source
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# separate words.
#

# shellcheck shell=bash
mernst marked this conversation as resolved.
Show resolved Hide resolved

################################################################################
# Helper functions
################################################################################
Expand All @@ -22,56 +24,58 @@ die() {
# Check whether an environment variable is set -- if not, die with an error message
check_env() {
local var="$1"
local val=$(eval echo \$$var)
local val
# shellcheck disable=SC2086 # would quoting even work?
val=$(eval echo \$$var)
mernst marked this conversation as resolved.
Show resolved Hide resolved
[ -z "$val" ] && die "Variable $var not set!"
}

# Get the relative path (relative to the Defects4J working directory) to the
# source file of the provided class name.
get_rel_src_path() {
local class="$1"
local src_dir=$($D4J_HOME/framework/bin/defects4j \
export -p dir.src.classes -w $D4J_DIR_WORKDIR 2> /dev/null)
echo "$src_dir/$(echo $class | tr '.' '/').java"
local src_dir; src_dir=$("$D4J_HOME"/framework/bin/defects4j \
export -p dir.src.classes -w "$D4J_DIR_WORKDIR" 2> /dev/null)
echo "$src_dir/$(echo "$class" | tr '.' '/').java"
}

# Get the absolute path to the source file of the provided class name.
get_abs_src_path() {
local class="$1"
echo "$D4J_DIR_WORKDIR/$(get_rel_src_path $class)"
echo "$D4J_DIR_WORKDIR/$(get_rel_src_path "$class")"
}

# Get the project classpath -- that is, the classpath to compile and run the
# checked-out Defects4J project version.
get_project_cp() {
$D4J_HOME/framework/bin/defects4j \
export -p cp.compile -w $D4J_DIR_WORKDIR 2> /dev/null
"$D4J_HOME"/framework/bin/defects4j \
export -p cp.compile -w "$D4J_DIR_WORKDIR" 2> /dev/null
}

# Parse a tool's config file: ignore comments and replace newlines with spaces.
parse_config() {
local file=$1
grep -v "\s*#" $file | tr '\n' ' '
grep -v "\s*#" "$file" | tr '\n' ' '
}

# Returns the list of all classes for the current bug
get_all_classes() {
local src_dir=$($D4J_HOME/framework/bin/defects4j \
export -p dir.src.classes -w $D4J_DIR_WORKDIR 2> /dev/null)
(cd $D4J_DIR_WORKDIR/$src_dir && \
local src_dir; src_dir=$("$D4J_HOME"/framework/bin/defects4j \
export -p dir.src.classes -w "$D4J_DIR_WORKDIR" 2> /dev/null)
(cd "$D4J_DIR_WORKDIR/$src_dir" && \
find . -name "*.java" | tr '/' '.' | sed -e 's/^\.*//g' | sed -e 's/\.java//g')
}

# Returns the list of all relevant classes for the current bug
get_relevant_classes() {
$D4J_HOME/framework/bin/defects4j \
export -p classes.relevant -w $D4J_DIR_WORKDIR 2> /dev/null
"$D4J_HOME"/framework/bin/defects4j \
export -p classes.relevant -w "$D4J_DIR_WORKDIR" 2> /dev/null
}

# Returns the list of all modified classes for the current bug
get_modified_classes() {
$D4J_HOME/framework/bin/defects4j \
export -p classes.modified -w $D4J_DIR_WORKDIR 2> /dev/null
"$D4J_HOME"/framework/bin/defects4j \
export -p classes.modified -w "$D4J_DIR_WORKDIR" 2> /dev/null
}

# Output a command, execute it, and print whether it succeeded or failed.
Expand Down
18 changes: 9 additions & 9 deletions framework/lib/test_generation/bin/_tool.template
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Wrapper script for <generator name>
#
Expand Down Expand Up @@ -26,25 +26,25 @@ if [ -z "$D4J_DIR_TESTGEN_BIN" ]; then
fi

# General helper functions
source $D4J_DIR_TESTGEN_BIN/_tool.source
source "$D4J_DIR_TESTGEN_BIN"/_tool.source

# The classpath to compile and run the project
project_cp=$(get_project_cp)
project_cp="$(get_project_cp)"

# Read all additional configuration parameters
add_config=$(parse_config $D4J_DIR_TESTGEN_BIN/<generator id>.config)
add_config=$(parse_config "$D4J_DIR_TESTGEN_BIN"/<generator id>.config)

# Make sure the provided test mode is supported
if [ $D4J_TEST_MODE == "regression" ]; then
...
elif [ $D4J_TEST_MODE == "error-revealing" ]; then
...
if [ "$D4J_TEST_MODE" = "regression" ]; then
: # TODO ...
elif [ "$D4J_TEST_MODE" = "error-revealing" ]; then
: # TODO ...
else
die "Unsupported test mode: $D4J_TEST_MODE"
fi

# The command that invokes the test generator
cmd="... $add_config"
cmd="... $add_config ... $project_cp ..."

# Run the test-generation command
if ! exec_cmd "$cmd"; then
Expand Down
12 changes: 7 additions & 5 deletions framework/lib/test_generation/bin/evosuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ if [ -z "$D4J_DIR_TESTGEN_BIN" ]; then
fi

# General helper functions
source $D4J_DIR_TESTGEN_BIN/_tool.source
source "$D4J_DIR_TESTGEN_BIN"/_tool.source

# The classpath to compile and run the project
project_cp=$(get_project_cp)

# Read all additional configuration parameters
add_config=$(parse_config $D4J_DIR_TESTGEN_BIN/evosuite.config)
add_config=$(parse_config "$D4J_DIR_TESTGEN_BIN"/evosuite.config)

# Make sure the provided test mode is supported
if [ $D4J_TEST_MODE != "regression" ]; then
if [ "$D4J_TEST_MODE" != "regression" ]; then
die "Unsupported test mode: $D4J_TEST_MODE"
fi

Expand All @@ -47,10 +47,12 @@ if [[ $(tail -c1 "$D4J_FILE_TARGET_CLASSES" | wc -l) -eq 0 ]]; then
fi

# Compute the budget per target class; evenly split the time for search and assertions
num_classes=$(cat $D4J_FILE_TARGET_CLASSES | wc -l)
num_classes=$(wc -l < "$D4J_FILE_TARGET_CLASSES")
budget=$(echo "$D4J_TOTAL_BUDGET/2/$num_classes" | bc)

for class in $(cat $D4J_FILE_TARGET_CLASSES); do
# shellcheck disable=SC2013 # reading words rather than lines, I suppose
for class in $(cat "$D4J_FILE_TARGET_CLASSES"); do
#shellcheck disable=SC2153 # D4J_DIR_TESTGEN_LIB is not a typo of D4J_DIR_TESTGEN_BIN
cmd="java -cp $D4J_DIR_TESTGEN_LIB/evosuite-current.jar org.evosuite.EvoSuite \
-class $class \
-projectCP $project_cp \
Expand Down
2 changes: 2 additions & 0 deletions framework/lib/test_generation/bin/randoop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ REG_BASE_NAME=RegressionTest
ERR_BASE_NAME=ErrorTest

# Print Randoop version
#shellcheck disable=SC2153 # D4J_DIR_TESTGEN_LIB is not a typo of D4J_DIR_TESTGEN_BIN
version=$(java -cp "$D4J_DIR_TESTGEN_LIB/randoop-current.jar" randoop.main.Main | head -1)
printf "\n(%s)" "$version" >&2
# shellcheck disable=SC1083
printf ".%.0s" {1..expr 73 - length "$version"} >&2
printf " " >&2

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
index f7d1517ed..0fc5e357d 100644
--- a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
@@ -80,7 +80,7 @@ public class IllegalTypesCheckTest extends BaseMapTest
public void testJDKTypes1855() throws Exception
{
// apparently included by JDK?
- _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");
+// _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");

// also: we can try some form of testing, even if bit contrived...
_testIllegalType(BogusPointcutAdvisor.class);
13 changes: 13 additions & 0 deletions framework/projects/JacksonDatabind/compile-errors/test-93-97.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
index f7d1517ed..0fc5e357d 100644
--- a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
@@ -80,7 +80,7 @@ public class IllegalTypesCheckTest extends BaseMapTest
public void testJDKTypes1855() throws Exception
{
// apparently included by JDK?
- _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");
+// _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");

// also: we can try some form of testing, even if bit contrived...
_testIllegalType(BogusPointcutAdvisor.class);
13 changes: 13 additions & 0 deletions framework/projects/JacksonDatabind/compile-errors/test-99-109.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
index f7d1517ed..0fc5e357d 100644
--- a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
@@ -80,7 +80,7 @@ public class IllegalTypesCheckTest extends BaseMapTest
public void testJDKTypes1855() throws Exception
{
// apparently included by JDK?
- _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");
+// _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");

// also: we can try some form of testing, even if bit contrived...
_testIllegalType(BogusPointcutAdvisor.class);
6 changes: 3 additions & 3 deletions framework/projects/Mockito/chooseDepedencyVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# $1 = workDir
# $2 = D4J_HOME

cd $1
cd "$1" || (echo "cannot cd to workdir $1" && exit 1)
./gradlew dependencies >> tmpDepend.txt
if grep -q buddy tmpDepend.txt; then
version=`cat tmpDepend.txt | grep buddy | cut -d: -f 3 | head -1`
cp $2/framework/projects/Mockito/byte-buddy/byte-buddy-$version.jar $1/compileLib/
version=$(grep buddy tmpDepend.txt | cut -d: -f 3 | head -1)
cp "$2/framework/projects/Mockito/byte-buddy/byte-buddy-$version.jar" "$1"/compileLib/
mernst marked this conversation as resolved.
Show resolved Hide resolved
fi
rm tmpDepend.txt
12 changes: 7 additions & 5 deletions framework/projects/Mockito/setMutationCompiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# $1 = working directory
# $2 = location of Defects4J (D4J_HOME)

WORK_DIR=$1
D4J_HOME=$2
WORK_DIR="$1"
D4J_HOME="$2"

BUILD_FILE="build.gradle"

echo >> $WORK_DIR/$BUILD_FILE
echo "compileJava.options.fork = true" >> $WORK_DIR/$BUILD_FILE
echo "compileJava.options.forkOptions.executable = '$D4J_HOME/major/bin/major'" >> $WORK_DIR/$BUILD_FILE
{
echo;
echo "compileJava.options.fork = true";
echo "compileJava.options.forkOptions.executable = '$D4J_HOME/major/bin/major'";
} >> "$WORK_DIR/$BUILD_FILE"
15 changes: 9 additions & 6 deletions framework/test/get_klocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
################################################################################

# Must use Java version 8.
JAVA_VERSION_STRING=`java -version 2>&1 | head -1`
JAVA_RELEASE_NUMBER=`echo $JAVA_VERSION_STRING | sed 's/^.*1\.\(.\).*/\1/'`
JAVA_VERSION_STRING=$(java -version 2>&1 | head -1)
# shellcheck disable=SC2001 # variable substitution does not suffice; needs sed.
JAVA_RELEASE_NUMBER=$(echo "$JAVA_VERSION_STRING" | sed 's/^.*1\.\(.\).*/\1/')
if [[ "$JAVA_RELEASE_NUMBER" != "8" ]]; then
echo Must use Java version 8
exit
Expand Down Expand Up @@ -37,18 +38,20 @@ if [ -z "$1" ] ; then
bids=( 1 2 3 4 5 )
else
# Generate tests for supplied project list
# shellcheck disable=SC2206
projects=( $1 )
if [ -z "$2" ] ; then
# Generate tests for all bids
bids=( 1 2 3 4 5 )
else
# Generate tests for supplied bid list
# shellcheck disable=SC2206
bids=( $2 )
fi
fi

echo "Projects: ${projects[@]}"
echo "Bug ids: ${bids[@]}"
echo "Projects: " "${projects[@]}"
echo "Bug ids: " "${bids[@]}"

# We want the 'fixed' version of the sample.
type=f
Expand All @@ -57,9 +60,9 @@ for pid in "${projects[@]}"; do
for bid in "${bids[@]}"; do
vid=${bid}$type

run_klocs.pl -p $pid -v $vid -n 1 -o $randoop_dir || die "run klocs on $pid-$vid"
run_klocs.pl -p "$pid" -v "$vid" -n 1 -o "$randoop_dir" || die "run klocs on $pid-$vid"
done
done

# delete tmp file directory
rm -rf $randoop_dir
rm -rf "$randoop_dir"
Loading
Loading