Permalink
Browse files

Merge pull request #148 from jose/dir.bin.tests

Export property 'dir.bin.tests'
  • Loading branch information...
rjust committed Nov 29, 2018
2 parents 272a52d + 60c8516 commit e6a420fa6ec5d353268409a5ed5a64d9faeebd65
@@ -34,6 +34,7 @@ jobs:
- script: carton exec ./test_mutation_analysis.sh
- script: carton exec ./test_randoop.sh
- script: carton exec ./test_fix_test_suite.sh
- script: carton exec ./test_export_command.sh
# Verify that all bugs are reproducible (run multiple jobs for projects that
# take a long time to finish).
- stage: verify-bugs
@@ -132,6 +132,7 @@ directory to export a version-specific property:
| dir.src.classes | Source directory of classes (relative to working directory) |
| dir.bin.classes | Target directory of classes (relative to working directory) |
| dir.src.tests | Source directory of tests (relative to working directory) |
| dir.bin.tests | Target directory of test classes (relative to working directory) |
| tests.all | List of all developer-written test classes |
| tests.relevant | List of relevant tests classes (a test class is relevant if, when executed, the JVM loads at least one of the modified classes) |
| tests.trigger | List of test methods that trigger (expose) the bug |
@@ -33,6 +33,7 @@ of the checked-out project version.
<property name="test.home" value="${d4j.workdir}/build-tests" />
<property name="build.home" value="${d4j.workdir}" />
<property name="classes.dir" value="${d4j.workdir}/build" />
<property name="test.classes.dir" value="${test.home}" />
<path id="compile.classpath" refid="build.classpath" />
<!-- Clean up working directory, i.e., delete classes and test classes. -->
@@ -51,6 +51,7 @@ of the checked-out project version.
<!-- Values necessary for mutation scripting to work -->
<property name="test.home" value="${testClasses.dir}" />
<property name="build.home" value="${build.dir}" />
<property name="test.classes.dir" value="${test.home}" />
<target name="compile.tests" depends="compile-tests" />
@@ -46,6 +46,9 @@ of the checked-out project version.
existing tests -->
<property name="d4j.test.dir" value="${test.home}"/>
<property name="classes.dir" value="${build.home}/classes"/>
<condition property="test.classes.dir" value="${maven.build.testOutputDir}" else="${build.home}/tests">
<isset property="maven.build.testOutputDir" />
</condition>
<!-- List of all developer-written tests that reliably pass on the fixed version -->
<fileset id="all.manual.tests" dir="${test.home}" excludes="${d4j.tests.exclude}">
@@ -32,6 +32,7 @@ of the checked-out project version.
<!-- build.home is not set in old repository layout -->
<property name="build.home" value="${classesdir}/.." />
<property name="classes.dir" value="${build.home}/classes" />
<property name="test.classes.dir" value="${build.home}/test-classes" />
<!-- Directory of the test sources, the default is the directory of the
existing tests -->
@@ -30,6 +30,7 @@
<condition property="test.src.home" value="${basedir}/src/test" else="${basedir}/test">
<istrue value="${use.ant}"/>
</condition>
<property name="test.classes.dir" value="${test.home}" />
<condition property="build.home" value="${basedir}/target" else="${basedir}/build">
<istrue value="${use.ant}"/>
@@ -57,6 +57,10 @@ of the checked-out project version.
<condition property="classes.dir" value="${maven.build.outputDir}" else="${build.classes}">
<isset property="maven.build.outputDir" />
</condition>
<condition property="test.classes.dir" value="${maven.build.testOutputDir}" else="${build.tests}">
<isset property="maven.build.testOutputDir" />
</condition>
<property name="build.home" value="${classes.dir}/.." />
<target name="compile.tests" depends="joda-time.compile.tests"> </target>
@@ -56,6 +56,16 @@ be used stand-alone.
<echo message="${dir.rel.src.tests}" file="${file.export}"/>
</target>
<!-- Target directory of test classes -->
<target name="export.dir.bin.tests"
description="Target directory of test classes"
depends="sanity.check">
<fail message="Property file.export not set!" unless="file.export" />
<property name="dir.rel.bin.tests" value="${test.classes.dir}" relative="yes" />
<echo message="${dir.rel.bin.tests}" file="${file.export}"/>
</target>
<!-- Compile classpath -->
<target name="export.cp.compile"
description="Classpath to compile the project"
@@ -7,6 +7,9 @@ Test and analysis scripts
generated test suites are compatible with the coverage, mutation, and bug
detection analyses.
* `test_export_command.sh`: Tests the
[export](https://github.com/rjust/defects4j/blob/master/framework/bin/d4j/d4j-export) command.
* `test_fix_test_suite.sh`: Tests the
[fix_test_suite.pl](https://github.com/rjust/defects4j/blob/master/framework/util/fix_test_suite.pl) script.
@@ -0,0 +1,119 @@
#!/usr/bin/env bash
################################################################################
#
# This script tests the export command.
#
################################################################################
HERE=$(cd `dirname $0` && pwd)
# Import helper subroutines and variables, and init Defects4J
source "$HERE/test.include" || exit 1
init
# ------------------------------------------------------------- Common functions
_run_export_command() {
[ $# -eq 2 ] || die "Usage: ${FUNCNAME[0]} <working directory> <export command>"
local work_dir="$1"
local exp_cmp="$2"
local exp_out=""
pushd . > /dev/null 2>&1
cd "$work_dir"
exp_out=$(defects4j export -p "$exp_cmp")
if [ $? -ne 0 ]; then
popd > /dev/null 2>&1
return 1
fi
popd > /dev/null 2>&1
echo "$exp_out"
return 0
}
# ------------------------------------------------------------------- Test Cases
test_ExportTestClassesDir() {
local test_dir="$TMP_DIR/test_ExportTestClassesDir"
rm -rf "$test_dir"; mkdir -p "$test_dir"
# Iterate over all projects
for pid in $(cd "$BASE_DIR/framework/core/Project" && ls *.pm | sed -e 's/\.pm//g'); do
# Iterate over all bugs
local bids=$(cut -f1 -d',' "$BASE_DIR/framework/projects/$pid/commit-db")
for bid in $bids; do
local work_dir="$test_dir/$pid/$bid"
mkdir -p "$work_dir"
defects4j checkout -p "$pid" -v "${bid}b" -w "$work_dir" || die "Checkout of $pid-$bid has failed"
local test_classes_dir=""
test_classes_dir=$(_run_export_command "$work_dir" "dir.bin.tests")
if [ $? -ne 0 ]; then
die "Export command of $pid-$bid has failed"
fi
local expected=""
if [ "$pid" == "Chart" ]; then
expected="build-tests"
elif [ "$pid" == "Closure" ]; then
expected="build/test"
elif [ "$pid" == "Lang" ]; then
if [ "$bid" -ge "1" ] && [ "$bid" -le "20" ]; then
expected="target/tests"
elif [ "$bid" -ge "21" ] && [ "$bid" -le "41" ]; then
expected="target/test-classes"
elif [ "$bid" -ge "42" ] && [ "$bid" -le "65" ]; then
expected="target/tests"
fi
elif [ "$pid" == "Math" ]; then
expected="target/test-classes"
elif [ "$pid" == "Mockito" ]; then
if [ "$bid" -ge "1" ] && [ "$bid" -le "11" ]; then
expected="build/classes/test"
elif [ "$bid" -ge "12" ] && [ "$bid" -le "17" ]; then
expected="target/test-classes"
elif [ "$bid" -ge "18" ] && [ "$bid" -le "21" ]; then
expected="build/classes/test"
elif [ "$bid" -ge "22" ] && [ "$bid" -le "38" ]; then
expected="target/test-classes"
fi
elif [ "$pid" == "Time" ]; then
if [ "$bid" -ge "1" ] && [ "$bid" -le "11" ]; then
expected="target/test-classes"
elif [ "$bid" -ge "12" ] && [ "$bid" -le "27" ]; then
expected="build/tests"
fi
fi
# Assert
[ "$test_classes_dir" == "$expected" ] || die "Actual test classes directory of $pid-$bid ('$test_classes_dir') is not the one expected ('$expected')"
# Clean up
rm -rf "$work_dir"
done
done
# Clean up
rm -rf "$test_dir"
}
# Run all test cases (and log all results), regardless of whether errors occur
HALT_ON_ERROR=0
test_ExportTestClassesDir || die "Test 'test_ExportTestClassesDir' has failed!"
HALT_ON_ERROR=1
# Print a summary of what went wrong
if [ "$ERROR" -ne "0" ]; then
printf '=%.s' $(seq 1 80) 1>&2
echo 1>&2
echo "The following errors occurred:" 1>&2
cat $LOG 1>&2
fi
# Indicate whether an error occurred
exit "$ERROR"

0 comments on commit e6a420f

Please sign in to comment.