Ant task - distribution zip is unpacked to ${kotlin-home} and used for all tests.

This commit is contained in:
Evgeny Goldin
2012-01-17 00:26:28 +02:00
parent 1fc1301cb2
commit 4edf29da2f
+45 -30
View File
@@ -1,6 +1,7 @@
<project name="build-tools" default="buildToolsJar">
<property name="tests-dir" location="${output}/build-tools-test"/>
<property name="tests-dir" location="${output}/ant-test/build-tools-test"/>
<property name="kotlin-home" location="${output}/ant-test/kotlin-home"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
@@ -8,18 +9,36 @@
</classpath>
</taskdef>
<path id="dist.jars">
<fileset dir="${idea.sdk}" includes="*.jar"/>
<fileset dir="${basedir}/lib" includes="*.jar"/>
<fileset dir="${output}" includes="*.jar"/>
</path>
<presetdef name="run-java">
<java classpathref = "dist.jars" failonerror = "true">
<classpath path = "${tests-dir}"/>
<java failonerror = "true">
<classpath>
<pathelement path = "${tests-dir}"/>
<fileset dir = "${kotlin-home}/lib" includes = "*.jar"/>
</classpath>
</java>
</presetdef>
<!-- Re-creates ${kotlin-home} and defines <kotlin> task using its jars -->
<macrodef name="setup-kotlin-home">
<sequential>
<delete dir = "${kotlin-home}" failonerror="true"/>
<mkdir dir = "${kotlin-home}"/>
<unzip src = "${output}/${output.name}.zip"
dest = "${kotlin-home}"/>
<move todir = "${kotlin-home}">
<fileset dir = "${kotlin-home}/kotlinc"/>
</move>
<delete dir = "${kotlin-home}/kotlinc" failonerror="true"/>
<taskdef resource = "org/jetbrains/jet/buildtools/ant/antlib.xml">
<classpath>
<fileset dir = "${kotlin-home}/lib" includes = "*.jar"/>
</classpath>
</taskdef>
</sequential>
</macrodef>
<!-- Invokes <java> for compiled Hello class and verifies the output -->
<macrodef name="hello-java">
@@ -28,8 +47,8 @@
<attribute name="out"/>
<sequential>
<var name = "java-out" unset = "true"/>
<run-java outputproperty = "java-out" classname = "namespace">
<arg line = "@{args}"/>
<run-java outputproperty = "java-out" classname = "namespace">
<arg line = "@{args}"/>
</run-java>
<if>
<equals arg1="${java-out}" arg2="@{out}"/>
@@ -49,27 +68,21 @@
<attribute name="args" default=""/>
<attribute name="out"/>
<sequential>
<taskdef resource = "org/jetbrains/jet/buildtools/ant/antlib.xml"
classpathref = "dist.jars"/>
<delete dir = "${tests-dir}" includes = "**/*"/>
<kotlinc destdir = "${tests-dir}" file = "@{root}/Hello.kt"/>
<hello-java root = "@{root}" args = "@{args}" out = "@{out}"/>
<delete dir = "${tests-dir}" verbose = "false" includes = "**/*.class"/>
<kotlinc destdir = "${tests-dir}" file = "@{root}/Hello.kt" />
<hello-java root = "@{root}" args = "@{args}" out = "@{out}"/>
<delete dir = "${tests-dir}" verbose = "false" includes = "**/*.class"/>
<kotlinc destdir = "${tests-dir}" srcdir = "@{root}" />
<hello-java root = "@{root}" args = "@{args}" out = "@{out}"/>
<delete dir = "${tests-dir}" includes = "**/*"/>
<kotlinc destdir = "${tests-dir}" srcdir = "@{root}"/>
<hello-java root = "@{root}" args = "@{args}" out = "@{out}"/>
</sequential>
</macrodef>
<!-- Compiles and runs with <java> web demo longer examples -->
<macrodef name="longer-examples">
<sequential>
<taskdef resource = "org/jetbrains/jet/buildtools/ant/antlib.xml"
classpathref = "dist.jars"/>
<delete dir = "${tests-dir}" verbose = "false" includes="**/*.class"/>
<kotlinc destdir = "${tests-dir}" srcdir = "${basedir}/build-tools/test/longer-examples" />
<delete dir = "${tests-dir}" includes = "**/*"/>
<kotlinc destdir = "${tests-dir}" srcdir = "${basedir}/build-tools/test/longer-examples" />
<run-java classname = "bottles.namespace"/>
<run-java classname = "maze.namespace"/>
@@ -91,18 +104,20 @@
</dirset>
</src>
<classpath>
<path refid="classpath.kotlin"/>
<fileset dir="${idea.sdk}/ant/lib" includes="*.jar"/>
<path refid = "classpath.kotlin"/>
<fileset dir = "${idea.sdk}/ant/lib" includes="*.jar"/>
</classpath>
</javac>
<jar destfile="${output}/kotlin-build-tools.jar">
<fileset dir="${output}/classes/buildTools"/>
<fileset dir="${basedir}/build-tools/ant/src" includes="**/*.xml"/>
<fileset dir = "${output}/classes/buildTools"/>
<fileset dir = "${basedir}/build-tools/ant/src" includes="**/*.xml"/>
</jar>
</target>
<!-- Tests build tools distribution jar -->
<target name="buildToolsTest" depends="jarRT, jar, buildToolsJar">
<target name="buildToolsTest" depends="dist">
<setup-kotlin-home/>
<!-- Compiles every "Hello, World!" example and verifies the output of <java> run -->
<hello-test root="${basedir}/build-tools/test/hello/1" out="Hello, world!"/>