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="kotlin-home" location="${output}/ant-test/kotlin-home"/>
|
||||
|
||||
|
||||
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
||||
<classpath>
|
||||
<pathelement location="${basedir}/build-tools/lib/ant-contrib-1.0b3.jar"/>
|
||||
</classpath>
|
||||
</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">
|
||||
<sequential>
|
||||
|
||||
<if>
|
||||
<not>
|
||||
<available file="${output}/${output.name}.zip"/>
|
||||
</not>
|
||||
<then>
|
||||
<antcall target="dist"/>
|
||||
</then>
|
||||
</if>
|
||||
|
||||
<delete dir = "${kotlin-home}" failonerror="true"/>
|
||||
<mkdir dir = "${kotlin-home}"/>
|
||||
<unzip src = "${output}/${output.name}.zip"
|
||||
@@ -40,57 +42,86 @@
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Invokes <java> for compiled Hello class and verifies the output -->
|
||||
<macrodef name="hello-java">
|
||||
<attribute name="root"/>
|
||||
<attribute name="args" default=""/>
|
||||
<!-- Runs <java> for compiled classes and verifies the output correctness -->
|
||||
<macrodef name="run-java">
|
||||
<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>
|
||||
<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}"/>
|
||||
</run-java>
|
||||
</java>
|
||||
<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>
|
||||
<echo>${java-out}</echo>
|
||||
</then>
|
||||
<else>
|
||||
<fail message="[@{root}] 'Hello' test failed: '${java-out}' (received) != '@{out}' (expected)"/>
|
||||
<fail message="Test failed: '${java-out}' (received) != '@{out}' (expected), equals = [@{equals}]"/>
|
||||
</else>
|
||||
</if>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Compiles "Hello.kt" as a single file and a folder, runs <java> and verifies the output -->
|
||||
<macrodef name="hello-test">
|
||||
<attribute name="root"/>
|
||||
<attribute name="args" default=""/>
|
||||
<attribute name="out"/>
|
||||
<sequential>
|
||||
<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}" includes = "**/*"/>
|
||||
<kotlinc destdir = "${tests-dir}" file = "@{root}/Hello.kt"/>
|
||||
<run-java args = "@{args}" out = "@{out}"/>
|
||||
|
||||
<delete dir = "${tests-dir}" includes = "**/*"/>
|
||||
<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}"/>
|
||||
<run-java args = "@{args}" out = "@{out}"/>
|
||||
</sequential>
|
||||
</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>
|
||||
<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"/>
|
||||
<run-java classname = "life.namespace"/>
|
||||
<run-java classname = "html.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" equals="false" out="O ~OOOOOOOOOOOOOO"/>
|
||||
<run-java classname = "life.namespace" equals="false" out="*** ** ** ***"/>
|
||||
<run-java classname = "html.namespace" equals="false" out="<a href="http://jetbrains.com/kotlin">"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- Creates build tools distribution jar -->
|
||||
<target name="buildToolsJar" depends="compile">
|
||||
<mkdir dir ="${output}/classes/buildTools"/>
|
||||
@@ -114,19 +145,11 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- Tests build tools distribution jar -->
|
||||
<target name="buildToolsTest" depends="dist">
|
||||
|
||||
<target name="buildToolsTest">
|
||||
<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!"/>
|
||||
<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/>
|
||||
<hello-tests/>
|
||||
<longer-examples-tests/>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user