Skip to content

Commit

Permalink
[TEST] - Setting up CI for running unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webdetails-build-bot committed Jun 18, 2014
1 parent 9171c77 commit 0f21957
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 112 deletions.
123 changes: 28 additions & 95 deletions build-res/subfloor-js.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<property name="js.expanded.lib.dir" value="${js.lib.dir}/expanded"/>

<!-- Path to the karma configuration -->
<property name="js.karma.config" value="karma.conf.js"/>
<property name="js.karma.ci.config" value="karma.conf.js"/>

<!-- Path for node_modules dir -->
<property name="nodemodules.local.dir" value="node_modules" />
<property name="nodemodules.local.dir.bin" value="node_modules\.bin" />

<property name="js.karma.config" value="config/karma.ci.conf.js"/>
<property name="js.karma.ci.config" value="config/karma.ci.conf.js"/>

<property environment="env"/>

Expand Down Expand Up @@ -288,99 +283,48 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

</target>


<!-- Check to see if karma is on the PATH -->
<available file="karma" filepath="${env.PATH}" property="karma-is-available"/>

<!-- Only run if there is a package.json file -->
<target name="npm-install" depends="check-pentaho-js-build-downloaded">
<if>
<available file="package.json"/>
<then>
<if>
<isset property="isWindows"/>
<then>
<exec executable="npm.cmd">
<arg value="install"/>
</exec>
</then>
<else>
<exec executable="npm">
<arg value="install"/>
</exec>
</else>
</if>
<exec executable="npm">
<arg value="install"/>
</exec>
</then>
<else>
<echo>No package.json found, using the default</echo>
<if>
<isset property="isWindows"/>
<then>
<exec executable="npm.cmd">
<arg value="install"/>
<arg value="build-res/pentaho-js-build"/>
</exec>
</then>
<else>
<exec executable="npm">
<arg value="install"/>
<arg value="build-res/pentaho-js-build"/>
</exec>
</else>
</if>
<exec executable="npm">
<arg value="install"/>
<arg value="build-res/pentaho-js-build"/>
</exec>
</else>
</if>
</target>

<target name="test-js" depends="install-antcontrib, npm-install">
<!-- Check to see if karma is on the PATH -->
<available file="karma" filepath="${env.PATH}" property="karma-is-available"/>
<available file="karma.cmd" filepath="${nodemodules.local.dir.bin}" property="karma-is-available-windows"/>

<if>
<isset property="isWindows"/>
<not>
<isset property="karma-is-available"/>
</not>
<then>
<if>
<not>
<isset property="karma-is-available-windows"/>
</not>
<then>
<echo message="${nodemodules.local.dir.bin}"/>
<fail>karma.cmd is not available on the '${nodemodules.local.dir.bin}'. Unit tests could not be run.</fail>
</then>
</if>
<fail>karma is not available on the PATH. Unit tests could not be run.</fail>
</then>
<else>
<if>
<not>
<isset property="karma-is-available"/>
</not>
<then>
<fail>karma is not available on the PATH. Unit tests could not be run.</fail>
</then>
</if>
</else>
</if>
<if>
<available file="${js.karma.ci.config}"/>
<then>
<if>
<isset property="isWindows" />
<then>
<!-- we have karma available, use it to run the tests -->
<exec executable="${nodemodules.local.dir.bin}\karma.cmd">
<arg value="start"/>
<arg value="${js.karma.ci.config}"/>
<!-- if we are running via ant, then assume we must 'single-run' -->
<arg value="--single-run"/>
</exec>
</then>
<else>
<!-- we have karma available, use it to run the tests -->
<exec executable="karma">
<arg value="start"/>
<arg value="${js.karma.ci.config}"/>
<!-- if we are running via ant, then assume we must 'single-run' -->
<arg value="--single-run"/>
</exec>
</else>
</if>
<!-- we have karma available, use it to run the tests -->
<exec executable="karma">
<arg value="start"/>
<arg value="${js.karma.ci.config}"/>
<!-- if we are running via ant, then assume we must 'single-run' -->
<arg value="--single-run"/>
</exec>
</then>
<else>
<fail>There is no karma configuration file available (looking for: ${js.karma.ci.config})</fail>
Expand All @@ -397,21 +341,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<fail>There is no karma configuration file available (looking for: ${js.karma.config})</fail>
</then>
<else>
<if>
<isset property="isWindows" />
<then>
<exec executable="${nodemodules.local.dir.bin}\karma.cmd">
<arg value="start"/>
<arg value="${js.karma.config}"/>
</exec>
</then>
<else>
<exec executable="karma">
<arg value="start"/>
<arg value="${js.karma.config}"/>
</exec>
</else>
</if>
<exec executable="karma">
<arg value="start"/>
<arg value="${js.karma.config}"/>
</exec>
</else>
</if>

Expand Down
113 changes: 113 additions & 0 deletions cdf-core/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
description="Top level Properties customized for your particular project belong in this file." />



<!-- Overriding values in subfloor-js.xml -->
<property name="js.karma.config" value="karma.conf.js"/>
<property name="js.karma.ci.config" value="karma.conf.js"/>

<!-- Path for node_modules dir -->
<property name="nodemodules.local.dir" value="node_modules" />
<property name="nodemodules.local.dir.bin" value="node_modules\.bin" />



<!-- Import subfloor.xml which contains all the default tasks -->
<import file="../build-res/subfloor.xml" id="subfloor"/>
<import file="../build-res/subfloor-js.xml"/>
Expand Down Expand Up @@ -137,4 +148,106 @@
<ivy:retrieve conf="runtime" pattern="${runtimelib.dir}/[module]-[revision](-[classifier]).[ext]" />
</target>

<!-- Only run if there is a package.json file -->
<target name="npm-install" depends="check-pentaho-js-build-downloaded">
<if>
<available file="package.json"/>
<then>
<if>
<isset property="isWindows"/>
<then>
<exec executable="npm.cmd">
<arg value="install"/>
</exec>
</then>
<else>
<exec executable="npm">
<arg value="install"/>
</exec>
</else>
</if>
</then>
<else>
<echo>No package.json found, using the default</echo>
<if>
<isset property="isWindows"/>
<then>
<exec executable="npm.cmd">
<arg value="install"/>
<arg value="build-res/pentaho-js-build"/>
</exec>
</then>
<else>
<exec executable="npm">
<arg value="install"/>
<arg value="build-res/pentaho-js-build"/>
</exec>
</else>
</if>
</else>
</if>
</target>

<target name="test-js" depends="install-antcontrib, npm-install">
<!-- Check to see if karma is on the PATH -->
<available file="karma" filepath="${env.PATH}" property="karma-is-available"/>
<available file="karma.cmd" filepath="${nodemodules.local.dir.bin}" property="karma-is-available-windows"/>

<if>
<isset property="isWindows"/>
<then>
<if>
<not>
<isset property="karma-is-available-windows"/>
</not>
<then>
<echo message="${nodemodules.local.dir.bin}"/>
<fail>karma.cmd is not available on the '${nodemodules.local.dir.bin}'. Unit tests could not be run.</fail>
</then>
</if>
</then>
<else>
<if>
<not>
<isset property="karma-is-available"/>
</not>
<then>
<fail>karma is not available on the PATH. Unit tests could not be run.</fail>
</then>
</if>
</else>
</if>
<if>
<available file="${js.karma.ci.config}"/>
<then>
<if>
<isset property="isWindows" />
<then>
<!-- we have karma available, use it to run the tests -->
<exec executable="${nodemodules.local.dir.bin}\karma.cmd">
<arg value="start"/>
<arg value="${js.karma.ci.config}"/>
<!-- if we are running via ant, then assume we must 'single-run' -->
<arg value="--single-run"/>
</exec>
</then>
<else>
<!-- we have karma available, use it to run the tests -->
<exec executable="karma">
<arg value="start"/>
<arg value="${js.karma.ci.config}"/>
<!-- if we are running via ant, then assume we must 'single-run' -->
<arg value="--single-run"/>
</exec>
</else>
</if>
</then>
<else>
<fail>There is no karma configuration file available (looking for: ${js.karma.ci.config})</fail>
</else>
</if>
</target>



</project>
50 changes: 33 additions & 17 deletions cdf-core/karma.ci.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@ module.exports = function(config) {


// list of files / patterns to load in the browser
files: [
//'resource/js/jquery.js',
//'resource/js/jquery.jeditable.js',
//'resource/js/Base.js',
//'test-js/mockDashboards.js',
//'resource/js/cdf-dd-config.js',
//'resource/js/cdf-dd-tablemanager.js',
//'resource/js/cdf-dd-wizardmanager.js',
//'resource/js/cdf-dd.js',
files: [
'cdf/js/lib/shims.js',
'cdf/js/lib/pen-shim.js',
'test-js/testUtils.js',
'cdf/js/wd.js',
'cdf/js/json.js',
'cdf/js/jquery.js',
'cdf/js/jquery.ui.js',
'cdf/js/jquery.blockUI.js',
'cdf/js/underscore.js',
'cdf/js/backbone.js',
'cdf/js/mustache.js',
'cdf/js/Base.js',
'../cdf-pentaho5/cdf/js/cdf-base.js',
'cdf/js/Dashboards.Main.js',
'cdf/js/Dashboards.Query.js',
'cdf/js/Dashboards.Bookmarks.js',
'cdf/js/Dashboards.Startup.js',
'cdf/js/Dashboards.Utils.js',
'cdf/js/Dashboards.Legacy.js',
'cdf/js/Dashboards.Notifications.js',
'cdf/js/Dashboards.RefreshEngine.js',
'cdf/js/components/core.js',
'cdf/js/queries/coreQueries.js',
'test-js/lib/test-components.js',
'test-js/main.js',
{pattern: 'test-js/**/*-spec.js', included: false}
],
Expand All @@ -33,18 +49,20 @@ module.exports = function(config) {


preprocessors: {
"resource/js/cdf-dd.js" : 'coverage'
"cdf/js/*.js" : 'coverage'
},

// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress', 'junit', 'html', 'coverage'],

//reporter: coverage
coverageReporter: {
type : 'cobertura',
dir : 'bin/coverage/reports/'
},

//reporter: junit
junitReporter: {
outputFile: 'bin/test/test-results.xml',
suite: 'unit'
Expand All @@ -56,13 +74,11 @@ module.exports = function(config) {
templatePath: 'node_modules/karma-html-reporter/jasmine_template.html'
},


// the default configuration
htmlReporter: {
outputDir: 'bin/test/karma_html',
templatePath: 'node_modules/karma-html-reporter/jasmine_template.html'
},

//hostname
hostname: [
'localhost'
],

// web server port
port: 9876,

Expand Down

0 comments on commit 0f21957

Please sign in to comment.