Permalink
Browse files

Adding 'tests' target for modules and rollups.

Pulls module source from
src/{component}/tests/src/{component}.js

and creates
src/{component}/tests/{component}-tests.js

containing a module in the form of
YUI.add('{component}-tests', function (Y) {
    /* code from src */
}, '@VERSION@', { requires: ['{component}', 'test'] });

Paths and file lists are configurable.  See
shared/properties.xml for details (search for 'tests.')
  • Loading branch information...
1 parent 5046355 commit 3c2a7bb00f1f5402ad90f254446a73230a9bd700 @lsmith lsmith committed Feb 24, 2011
Showing with 69 additions and 0 deletions.
  1. +24 −0 componentbuild/3.x/module.xml
  2. +25 −0 componentbuild/3.x/rollup.xml
  3. +20 −0 componentbuild/shared/properties.xml
View
24 componentbuild/3.x/module.xml
@@ -105,4 +105,28 @@
</concat>
</target>
+ <!-- Tests -->
+ <target name="tests" depends="-lint-server">
+ <echo level="info">Generating test module for ${component}</echo>
+ <echo level="info"> Test module: ${tests.component}</echo>
+ <echo level="info"> Test module source directory: ${tests.srcdir}</echo>
+ <echo level="info"> Test module source files: ${tests.jsfiles}</echo>
+ <echo level="info"> Test module output directory: ${tests.builddir}</echo>
+ <echo level="info"> Test module file: ${tests.builddir}/${tests.component}.js</echo>
+ <echo level="info"> </echo>
+
+ <available file="${tests.srcdir}" type="dir" property="tests.srcdir.exists"/>
+ <var name="buildfile" value="${tests.builddir}/${tests.component}.js"/>
+ <arrayliteral from="tests.requires" to="tests.details.requires" key="requires"/>
+ <concatsource destfile="${buildfile}" sourcedir="${tests.srcdir}" sourcefiles="${tests.jsfiles}"/>
+ <addmodule file="${buildfile}" module="${tests.component}" details="{${tests.details.requires}}"/>
+
+ <jslint>
+ <jsfiles>
+ <fileset file="${buildfile}"/>
+ </jsfiles>
+ </jslint>
+
+ <echo level="info">Test module ${tests.component} created</echo>
+ </target>
</project>
View
25 componentbuild/3.x/rollup.xml
@@ -77,4 +77,29 @@
</then>
</if>
</target>
+
+ <target name="tests">
+ <subant target="tests" inheritall="false" >
+ <filelist dir="${buildfile.dir}" files="${component.rollup.modules.buildfiles}" />
+ <property name="rollup" value="true" />
+ <property name="rollup.component" value="${tests.component}" />
+ </subant>
+
+ <arrayliteral from="tests.rollup.modules" to="tests.details.use" key="use"/>
+ <propertyregex property="tests.rollup.module.files"
+ override="true"
+ input="${tests.rollup.modules}"
+ casesensitive="false"
+ regexp="([^\,\s]+)"
+ replace="\1.js"
+ />
+
+ <concat destfile="${tests.builddir}/${tests.component}.js" append="true" fixlastline="true">
+ <filelist dir="${tests.builddir}" files="${tests.rollup.module.files}"/>
+ </concat>
+
+ <addrollup module="${tests.component}" file="${tests.builddir}/${tests.component}.js" details="{${tests.details.use}}" />
+
+ <echo level="info">Rollup test module ${tests.component} created</echo>
+ </target>
</project>
View
20 componentbuild/shared/properties.xml
@@ -106,6 +106,26 @@
</and>
</condition>
+ <!-- component test module properties -->
+ <property name="testsdir" value="./tests"/>
+ <property name="tests.srcdir" value="${testsdir}/src"/>
+ <property name="tests.builddir" value="${testsdir}"/>
+ <property name="tests.component" value="${component}-tests"/>
+ <property name="tests.jsfiles" value="${component}.js"/>
+ <property name="tests.requires" value="${component}, test"/>
+ <if>
+ <istrue value="${component.rollup}"/>
+ <then>
+ <propertyregex property="tests.rollup.modules"
+ override="true"
+ input="${component.use}"
+ casesensitive="false"
+ regexp="([^\,\s]+)"
+ replace="\1-tests"
+ />
+ </then>
+ </if>
+
<!--
DEPRECATED: component.basefilename and component.releasetype are deprecated
We used to mark filenames with suffixes (-beta, -experimental), which we no longer do

0 comments on commit 3c2a7bb

Please sign in to comment.