8157061: Add support for running jtreg tests from IntelliJ project
Add basic capabilities for running jtreg tests from the IDE using a custom ant target Reviewed-by: chegar
This commit is contained in:
parent
23043ca1e6
commit
16eae50cca
@ -155,6 +155,14 @@ addBuildDir() {
|
||||
printf "%s\n" "$mn" >> $IDEA_ANT
|
||||
}
|
||||
|
||||
JTREG_HOME=" <property name=\"jtreg.home\" value=\"####\" />"
|
||||
|
||||
addJtregHome() {
|
||||
DIR=`dirname $SPEC`
|
||||
mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`"
|
||||
printf "%s\n" "$mn" >> $IDEA_ANT
|
||||
}
|
||||
|
||||
### Generate ant.xml
|
||||
|
||||
rm -f $IDEA_ANT
|
||||
@ -162,6 +170,8 @@ while IFS= read -r line
|
||||
do
|
||||
if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then
|
||||
addModuleName
|
||||
elif echo "$line" | egrep "^ .* <property name=\"jtreg.home\"" > /dev/null ; then
|
||||
addJtregHome
|
||||
elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then
|
||||
addBuildDir
|
||||
else
|
||||
|
@ -35,5 +35,6 @@ else #with SPEC
|
||||
$(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT)
|
||||
$(ECHO) "CYGPATH=\"$(CYGPATH)\"" >> $(OUT)
|
||||
$(ECHO) "SPEC=\"$(SPEC)\"" >> $(OUT)
|
||||
$(ECHO) "JT_HOME=\"$(JT_HOME)\"" >> $(OUT)
|
||||
|
||||
endif
|
||||
|
@ -5,9 +5,8 @@
|
||||
<properties>
|
||||
<property name="boot.java.home" value="$JDKPath$" />
|
||||
<property name="jtreg.tests" value="$FilePath$" />
|
||||
<property name="jtreg.home" value="###" />
|
||||
<property name="jtreg.home" value="jtreg.home" />
|
||||
<property name="build.target.dir" value="specDir" /> <!-- this will be replaced -->
|
||||
<property name="jtreg.jpda.jvmargs" value="-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5900,suspend=y" />
|
||||
<property name="module.name" value="java.base" /> <!-- this will be replaced -->
|
||||
</properties>
|
||||
<executeOn event="afterCompilation" target="post-make" />
|
||||
|
@ -16,6 +16,10 @@
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
|
||||
<target name="-check-jtreg.home" depends="-def-check">
|
||||
<check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
|
||||
</target>
|
||||
|
||||
<property name="test.dir" value="${basedir}/jdk/test"/>
|
||||
|
||||
<macrodef name="call-make">
|
||||
@ -29,26 +33,6 @@
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="exec-target">
|
||||
<attribute name="antfile" default="${ant.file}" />
|
||||
<attribute name="target" />
|
||||
<sequential>
|
||||
<java classname="org.apache.tools.ant.Main" fork="true" spawn="true">
|
||||
<arg value="-f"/>
|
||||
<arg value="@{antfile}"/>
|
||||
<arg value="-Dboot.java.home=${boot.java.home}"/>
|
||||
<arg value="-Dbuild.target.dir=${build.target.dir}"/>
|
||||
<arg value="-Djtreg.home=${jtreg.home}"/>
|
||||
<arg value="-Djtreg.tests=${jtreg.tests}"/>
|
||||
<arg value="-Djtreg.jpda.jvmargs=${jtreg.jpda.jvmargs}"/>
|
||||
<arg value="@{target}"/>
|
||||
<classpath>
|
||||
<pathelement path="${java.class.path}"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="post-make" depends="build-module"/>
|
||||
|
||||
<!--
|
||||
@ -59,7 +43,7 @@
|
||||
<echo message="base = ${basedir}"/>
|
||||
<call-make dir = "${build.target.dir}" args = "clean"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="-do-configure">
|
||||
<echo message="base = ${basedir}"/>
|
||||
<fail message="Not part of a full JDK forest">
|
||||
@ -122,5 +106,68 @@
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
<macrodef name="exec-target">
|
||||
<attribute name="antfile" default="${ant.file}" />
|
||||
<attribute name="target" />
|
||||
<sequential>
|
||||
<java classname="org.apache.tools.ant.Main" fork="true" spawn="true">
|
||||
<arg value="-f"/>
|
||||
<arg value="@{antfile}"/>
|
||||
<arg value="-Dbuild.target.dir=${build.target.dir}"/>
|
||||
<arg value="-Djtreg.home=${jtreg.home}"/>
|
||||
<arg value="-Djtreg.tests=${jtreg.tests}"/>
|
||||
<arg value="-Djtreg.jpda.jvmargs=${jtreg.jpda.jvmargs}"/>
|
||||
<arg value="@{target}"/>
|
||||
<classpath>
|
||||
<pathelement path="${java.class.path}"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="jtreg" depends="images,-def-jtreg">
|
||||
<jtreg-tool name="all" tests="${jtreg.tests}"/>
|
||||
</target>
|
||||
|
||||
<target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home">
|
||||
<taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
|
||||
<classpath>
|
||||
<pathelement location="${jtreg.home}/lib/jtreg.jar"/>
|
||||
<pathelement location="${jtreg.home}/lib/javatest.jar"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<macrodef name="jtreg-tool">
|
||||
<attribute name="name"/>
|
||||
<attribute name="tests"/>
|
||||
<attribute name="jdk" default="${build.target.dir}/images/jdk"/>
|
||||
<attribute name="agentvm" default="true"/>
|
||||
<attribute name="verbose" default="${default.jtreg.verbose}"/>
|
||||
<attribute name="options" default="${other.jtreg.options}"/>
|
||||
<attribute name="keywords" default="-keywords:!ignore"/>
|
||||
<attribute name="jpda.jvmargs" default=""/>
|
||||
<attribute name="extra.jvmargs" default=""/>
|
||||
<attribute name="build.modules" default="${build.modules}"/>
|
||||
<sequential>
|
||||
<property name="coverage.options" value=""/> <!-- default -->
|
||||
<property name="coverage.classpath" value=""/> <!-- default -->
|
||||
<property name="default.jtreg.verbose" value="summary"/> <!-- default -->
|
||||
<property name="other.jtreg.options" value=""/> <!-- default -->
|
||||
<property name="jtreg.classfiles.to.modules" value="@{agentvm}"/>
|
||||
<jtreg
|
||||
dir="${test.dir}"
|
||||
workDir="${build.target.dir}/idea/@{name}/work"
|
||||
reportDir="${build.target.dir}/idea/@{name}/report"
|
||||
jdk="@{jdk}"
|
||||
agentvm="@{agentvm}" verbose="@{verbose}"
|
||||
failonerror="false" resultproperty="jtreg.@{name}.result">
|
||||
<arg value="-debug:@{jpda.jvmargs}"/>
|
||||
<arg line="@{keywords}"/>
|
||||
<arg line="@{options}"/>
|
||||
<arg line="@{tests}"/>
|
||||
</jtreg>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<property name="jtreg.defined" value="true"/>
|
||||
</target>
|
||||
</project>
|
||||
|
@ -99,7 +99,9 @@ public final class JdkIdeaAntLogger extends DefaultLogger {
|
||||
/** jtreg test failure */
|
||||
JTREG_TEST_FAILED(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "FAILED: "),
|
||||
/** jtreg test error */
|
||||
JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: ");
|
||||
JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: "),
|
||||
/** jtreg report */
|
||||
JTREG_TEST_REPORT(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Report written");
|
||||
|
||||
StringBinaryPredicate sbp;
|
||||
int priority;
|
||||
@ -132,7 +134,7 @@ public final class JdkIdeaAntLogger extends DefaultLogger {
|
||||
MAKE("exec", MessageKind.MAKE_ERROR, MessageKind.MAKE_WARNING, MessageKind.MAKE_NOTE,
|
||||
MessageKind.MAKE_OTHER, MessageKind.JAVAC_CRASH),
|
||||
/** jtreg task - invoked during test execution */
|
||||
JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR),
|
||||
JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR, MessageKind.JTREG_TEST_REPORT),
|
||||
/** initial synthetic task when the logger is created */
|
||||
ROOT("") {
|
||||
@Override
|
||||
|
@ -8,6 +8,14 @@
|
||||
<component name="StructureViewFactory">
|
||||
<option name="ACTIVE_ACTIONS" value=",ALPHA_COMPARATOR" />
|
||||
</component>
|
||||
<component name="RunManager" selected="Ant Target.jtreg">
|
||||
<configuration default="false" name="jtreg" type="AntRunConfiguration" factoryName="Ant Target">
|
||||
<antsettings antfile="file://$PROJECT_DIR$/.idea/build.xml" target="jtreg" />
|
||||
<method>
|
||||
<option name="Make" enabled="false" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="antWorkspaceConfiguration">
|
||||
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user