Ant task - all <java> invocations have their output checked in <run-java>; tests organization; no "dist" dependency
This commit is contained in:
+64
-41
@@ -3,25 +3,27 @@
|
|||||||
<property name="tests-dir" location="${output}/ant-test/build-tools-test"/>
|
<property name="tests-dir" location="${output}/ant-test/build-tools-test"/>
|
||||||
<property name="kotlin-home" location="${output}/ant-test/kotlin-home"/>
|
<property name="kotlin-home" location="${output}/ant-test/kotlin-home"/>
|
||||||
|
|
||||||
|
|
||||||
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement location="${basedir}/build-tools/lib/ant-contrib-1.0b3.jar"/>
|
<pathelement location="${basedir}/build-tools/lib/ant-contrib-1.0b3.jar"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
</taskdef>
|
</taskdef>
|
||||||
|
|
||||||
<presetdef name="run-java">
|
|
||||||
<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 -->
|
<!-- Re-creates ${kotlin-home} and defines <kotlin> tasks using "${kotlin-home}/lib" jars -->
|
||||||
<macrodef name="setup-kotlin-home">
|
<macrodef name="setup-kotlin-home">
|
||||||
<sequential>
|
<sequential>
|
||||||
|
|
||||||
|
<if>
|
||||||
|
<not>
|
||||||
|
<available file="${output}/${output.name}.zip"/>
|
||||||
|
</not>
|
||||||
|
<then>
|
||||||
|
<antcall target="dist"/>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
<delete dir = "${kotlin-home}" failonerror="true"/>
|
<delete dir = "${kotlin-home}" failonerror="true"/>
|
||||||
<mkdir dir = "${kotlin-home}"/>
|
<mkdir dir = "${kotlin-home}"/>
|
||||||
<unzip src = "${output}/${output.name}.zip"
|
<unzip src = "${output}/${output.name}.zip"
|
||||||
@@ -40,57 +42,86 @@
|
|||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
|
|
||||||
<!-- Invokes <java> for compiled Hello class and verifies the output -->
|
<!-- Runs <java> for compiled classes and verifies the output correctness -->
|
||||||
<macrodef name="hello-java">
|
<macrodef name="run-java">
|
||||||
<attribute name="root"/>
|
|
||||||
<attribute name="args" default=""/>
|
|
||||||
<attribute name="out"/>
|
<attribute name="out"/>
|
||||||
|
<attribute name="classname" default="namespace"/>
|
||||||
|
<attribute name="args" default=""/>
|
||||||
|
<attribute name="equals" default="true"/> <!-- Whether strict equality of output to @{out} required -->
|
||||||
<sequential>
|
<sequential>
|
||||||
<var name = "java-out" unset = "true"/>
|
<var name = "java-out" unset = "true"/>
|
||||||
<run-java outputproperty = "java-out" classname = "namespace">
|
<java outputproperty = "java-out"
|
||||||
|
classname = "@{classname}"
|
||||||
|
failonerror = "true">
|
||||||
|
<classpath>
|
||||||
|
<pathelement path = "${tests-dir}"/>
|
||||||
|
<fileset dir = "${kotlin-home}/lib" includes = "*.jar"/>
|
||||||
|
</classpath>
|
||||||
<arg line = "@{args}"/>
|
<arg line = "@{args}"/>
|
||||||
</run-java>
|
</java>
|
||||||
<if>
|
<if>
|
||||||
<equals arg1="${java-out}" arg2="@{out}"/>
|
<or>
|
||||||
|
<equals arg1="${java-out}" arg2="@{out}" forcestring="true"/>
|
||||||
|
<and>
|
||||||
|
<equals arg1="@{equals}" arg2="false"/>
|
||||||
|
<contains string="${java-out}" substring="@{out}"/>
|
||||||
|
</and>
|
||||||
|
</or>
|
||||||
<then>
|
<then>
|
||||||
<echo>${java-out}</echo>
|
<echo>${java-out}</echo>
|
||||||
</then>
|
</then>
|
||||||
<else>
|
<else>
|
||||||
<fail message="[@{root}] 'Hello' test failed: '${java-out}' (received) != '@{out}' (expected)"/>
|
<fail message="Test failed: '${java-out}' (received) != '@{out}' (expected), equals = [@{equals}]"/>
|
||||||
</else>
|
</else>
|
||||||
</if>
|
</if>
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
|
|
||||||
<!-- Compiles "Hello.kt" as a single file and a folder, runs <java> and verifies the output -->
|
<!-- Compiles "Hello.kt" as a single file and a folder, runs <java> and verifies the output -->
|
||||||
<macrodef name="hello-test">
|
<macrodef name="hello-test">
|
||||||
<attribute name="root"/>
|
<attribute name="root"/>
|
||||||
<attribute name="args" default=""/>
|
<attribute name="args" default=""/>
|
||||||
<attribute name="out"/>
|
<attribute name="out"/>
|
||||||
<sequential>
|
<sequential>
|
||||||
<delete dir = "${tests-dir}" includes = "**/*"/>
|
<delete dir = "${tests-dir}" includes = "**/*"/>
|
||||||
<kotlinc destdir = "${tests-dir}" file = "@{root}/Hello.kt"/>
|
<kotlinc destdir = "${tests-dir}" file = "@{root}/Hello.kt"/>
|
||||||
<hello-java root = "@{root}" args = "@{args}" out = "@{out}"/>
|
<run-java args = "@{args}" out = "@{out}"/>
|
||||||
|
|
||||||
<delete dir = "${tests-dir}" includes = "**/*"/>
|
<delete dir = "${tests-dir}" includes = "**/*"/>
|
||||||
<kotlinc destdir = "${tests-dir}" srcdir = "@{root}"/>
|
<kotlinc destdir = "${tests-dir}" srcdir = "@{root}"/>
|
||||||
<hello-java root = "@{root}" args = "@{args}" out = "@{out}"/>
|
<run-java args = "@{args}" out = "@{out}"/>
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
<!-- Compiles and runs with <java> web demo longer examples -->
|
|
||||||
<macrodef name="longer-examples">
|
<!-- Runs all Hello tests -->
|
||||||
|
<macrodef name="hello-tests">
|
||||||
|
<sequential>
|
||||||
|
<hello-test root="${basedir}/build-tools/test/hello/1" out="Hello, world!"/>
|
||||||
|
<hello-test root="${basedir}/build-tools/test/hello/2" args="Kotlin-Developer" out="Hello, Kotlin-Developer!"/>
|
||||||
|
<hello-test root="${basedir}/build-tools/test/hello/3" args="Mickey-Mouse" out="Hello, Mickey-Mouse!"/>
|
||||||
|
<hello-test root="${basedir}/build-tools/test/hello/4" args="IT" out="Ciao!"/>
|
||||||
|
<hello-test root="${basedir}/build-tools/test/hello/4" args="FR" out="Salut!"/>
|
||||||
|
<hello-test root="${basedir}/build-tools/test/hello/5" args="Donald-Duck" out="Hello, Donald-Duck!"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Compiles, runs and verifies the output of web demo longer examples -->
|
||||||
|
<macrodef name="longer-examples-tests">
|
||||||
<sequential>
|
<sequential>
|
||||||
<delete dir = "${tests-dir}" includes = "**/*"/>
|
<delete dir = "${tests-dir}" includes = "**/*"/>
|
||||||
<kotlinc destdir = "${tests-dir}" srcdir = "${basedir}/build-tools/test/longer-examples" />
|
<kotlinc destdir = "${tests-dir}" srcdir = "${basedir}/build-tools/test/longer-examples" />
|
||||||
|
|
||||||
<run-java classname = "bottles.namespace"/>
|
<run-java classname = "bottles.namespace" equals="false" out="12 bottles of beer on the wall, 12 bottles of beer." />
|
||||||
<run-java classname = "maze.namespace"/>
|
<run-java classname = "maze.namespace" equals="false" out="O ~OOOOOOOOOOOOOO"/>
|
||||||
<run-java classname = "life.namespace"/>
|
<run-java classname = "life.namespace" equals="false" out="*** ** ** ***"/>
|
||||||
<run-java classname = "html.namespace"/>
|
<run-java classname = "html.namespace" equals="false" out="<a href="http://jetbrains.com/kotlin">"/>
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
|
|
||||||
<!-- Creates build tools distribution jar -->
|
<!-- Creates build tools distribution jar -->
|
||||||
<target name="buildToolsJar" depends="compile">
|
<target name="buildToolsJar" depends="compile">
|
||||||
<mkdir dir ="${output}/classes/buildTools"/>
|
<mkdir dir ="${output}/classes/buildTools"/>
|
||||||
@@ -114,19 +145,11 @@
|
|||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
<!-- Tests build tools distribution jar -->
|
<!-- Tests build tools distribution jar -->
|
||||||
<target name="buildToolsTest" depends="dist">
|
<target name="buildToolsTest">
|
||||||
|
|
||||||
<setup-kotlin-home/>
|
<setup-kotlin-home/>
|
||||||
|
<hello-tests/>
|
||||||
<!-- Compiles every "Hello, World!" example and verifies the output of <java> run -->
|
<longer-examples-tests/>
|
||||||
<hello-test root="${basedir}/build-tools/test/hello/1" out="Hello, world!"/>
|
|
||||||
<hello-test root="${basedir}/build-tools/test/hello/2" args="Kotlin-Developer" out="Hello, Kotlin-Developer!"/>
|
|
||||||
<hello-test root="${basedir}/build-tools/test/hello/3" args="Mickey-Mouse" out="Hello, Mickey-Mouse!"/>
|
|
||||||
<hello-test root="${basedir}/build-tools/test/hello/4" args="IT" out="Ciao!"/>
|
|
||||||
<hello-test root="${basedir}/build-tools/test/hello/5" args="Donald-Duck" out="Hello, Donald-Duck!"/>
|
|
||||||
|
|
||||||
<!-- Compiles and runs web demo longer examples (99 Bottles of Beer, Maze, Life, HTML Builder) -->
|
|
||||||
<longer-examples/>
|
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user