defects4j
defects4j copied to clipboard
Fail more gracefully/fix build analyzer when junit task is not found in build file
The java build file analyzer for ant fails with a null pointer exception when there is no junit task found in the build file. For example:
31: commons-io
Checking out bcc797b5 to /tmp/initialize-revisions.pl_95078_1626835727/31b. OK
Run build-file analyzer on build.xml....................................... FAIL
Executed command: cd /tmp/initialize-revisions.pl_95078_1626835727/31b && java -jar /Users/audrey/github/bug_mining/defects4j/framework/lib/analyzer.jar /tmp/initialize-revisions.pl_95078_1626835727/31b /Users/audrey/github/bug_mining/defects4j/framework/bug-mining/io-bug-mining/framework/projects/Io/analyzer_output/31 build.xml 2>&1
Exception in thread "main" java.lang.NullPointerException
at testgetter.TestGetter.getPatterns(TestGetter.java:72)
at testgetter.TestGetter.<init>(TestGetter.java:31)
at Analyzer.<init>(Analyzer.java:39)
at Driver.main(Driver.java:26)
For commons-io
at commit bcc797b5
, this is what the test target looks like in the build.xml
file:
<target name="test" depends="compile.tests"
description="Run all unit test cases">
<antcall target="exec.test"><param name="testclass" value="org.apache.commons.io.PackageTestSuite"/></antcall>
<antcall target="exec.test"><param name="testclass" value="org.apache.commons.io.comparator.PackageTestSuite"/></antcall>
<antcall target="exec.test"><param name="testclass" value="org.apache.commons.io.filefilter.PackageTestSuite"/></antcall>
<antcall target="exec.test"><param name="testclass" value="org.apache.commons.io.input.PackageTestSuite"/></antcall>
<antcall target="exec.test"><param name="testclass" value="org.apache.commons.io.output.PackageTestSuite"/></antcall>
</target>
<target name="exec.test" description="Run a unit test case">
<echo message="Running Test ${testclass} ..."/>
<java classname="${test.runner}" fork="yes"
failonerror="${test.failonerror}">
<arg value="${testclass}"/>
<classpath refid="test.classpath"/>
</java>
</target>
Instead of using the junit ant task, it instead runs the junit test runner -- in this case, test.runner=junit.textui.TestRunner
.
Either the bug mining framework should fail more gracefully, perhaps by detecting the lack in the first case and outputting a message saying that there doesn't exist a junit ant task in the build file, or the build file analyzer should fail more gracefully with a more helpful error message.