Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Adding 'tests' target for modules and rollups.
Browse files Browse the repository at this point in the history
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
lsmith committed Feb 24, 2011
1 parent 5046355 commit 3c2a7bb
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
24 changes: 24 additions & 0 deletions componentbuild/3.x/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
25 changes: 25 additions & 0 deletions componentbuild/3.x/rollup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
20 changes: 20 additions & 0 deletions componentbuild/shared/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c2a7bb

Please sign in to comment.