From e6eaeee14935fbebc50f7e893d64f85cf2140195 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sat, 15 Aug 2015 19:08:08 +0200 Subject: [PATCH 01/10] bump version to 0.5.5-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0cd8a6..2f48e04 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "sourcejs", "description": "Living Style Guide Engine for Managing and Developing Front-end Components.", "author": "SourceJS", - "version": "0.5.4", + "version": "0.5.5-dev", "license": "MIT", "repository": { "type": "git", From 70eeb3ed5ab1289890dc5a8c9d5b56dfe07a663e Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 13:35:46 +0200 Subject: [PATCH 02/10] fix plugins load from npm sourcejs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f48e04..f549c13 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "tinyforever": "0.0.3" }, "scripts": { - "postinstall": "grunt update && node ./core/postInstall", + "postinstall": "node ./core/postInstall && grunt update", "build": "npm i", "start": "node app", "test": "grunt ci-pre-run && node app.js --test", From fe0d99073860732be619edb9a641fed6249cd392 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 18:18:05 +0200 Subject: [PATCH 03/10] add functional tests --- Gruntfile.js | 33 ++++++++++++---- app.js | 2 +- assets/js/modules/codeSource.js | 2 +- assets/js/modules/parseFileTree.js | 2 +- assets/js/modules/search.js | 6 +++ package.json | 1 + test/casperjs/common.js | 44 +++++++++++++++++++++ test/casperjs/globalNav.js | 33 ++++++++++++++++ test/casperjs/search.js | 50 ++++++++++++++++++++++++ test/casperjs/snippets.md | 62 ++++++++++++++++++++++++++++++ 10 files changed, 225 insertions(+), 10 deletions(-) create mode 100644 test/casperjs/common.js create mode 100644 test/casperjs/globalNav.js create mode 100644 test/casperjs/search.js create mode 100644 test/casperjs/snippets.md diff --git a/Gruntfile.js b/Gruntfile.js index 0565e6e..677dc41 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,6 +7,8 @@ global.pathToApp = pathToApp; var loadOptions = require('./core/loadOptions'); module.exports = function(grunt) { + var appPort = grunt.option('app-port') || 8080; + // load all grunt tasks matching the `grunt-*` pattern require('load-grunt-tasks')(grunt); @@ -177,11 +179,18 @@ module.exports = function(grunt) { mochaTest: { test: { - src: ['test/**/*.js'] + src: ['test/specs/**/*.js'] }, noApp: { src: ['test/specs/lib/**/*.js'] } + }, + + casperjs: { + options: { + casperjsOptions: ['--app-port='+appPort] + }, + files: ['test/casperjs/**/*.js'] } }); @@ -286,7 +295,8 @@ module.exports = function(grunt) { ]); grunt.registerTask('ci-post-run', [ - 'test' + 'test', + 'test-func' ]); /* @@ -297,14 +307,23 @@ module.exports = function(grunt) { // Test task. Execute with running app grunt.registerTask('test', 'Run ALL tests or specified by second param', function () { + // if custom mask set - `grunt test --spec=test/specs/middleware/**/*.js` var spec = grunt.option('spec'); - if (spec) { - // if custom mask set - `grunt test --spec=test/specs/middleware/**/*.js` grunt.config.set('mochaTest.test.src', [spec]); - grunt.task.run('mochaTest'); - } else { - grunt.task.run('mochaTest'); } + + grunt.task.run('mochaTest'); + }); + + // Test task. Execute with running app + grunt.registerTask('test-func', 'Run ALL functional tests or specified by second param', function () { + // if custom mask set - `grunt test --spec=test/specs/middleware/**/*.js` + var spec = grunt.option('spec'); + if (spec) { + grunt.config.set('casperjs.files', [spec]); + } + + grunt.task.run('casperjs'); }); }; diff --git a/app.js b/app.js index 5b31a29..5261d61 100644 --- a/app.js +++ b/app.js @@ -230,7 +230,7 @@ if (!module.parent) { if (commander.test) { var spawn = require('cross-spawn'); - spawn('./node_modules/grunt-cli/bin/grunt', ['ci-post-run'], {stdio: 'inherit'}) + spawn('./node_modules/grunt-cli/bin/grunt', ['ci-post-run', '--port='+port], {stdio: 'inherit'}) .on('close', function (code) { if (code === 0) { log.info('Test successful'); diff --git a/assets/js/modules/codeSource.js b/assets/js/modules/codeSource.js index 7d3c776..931e7ea 100644 --- a/assets/js/modules/codeSource.js +++ b/assets/js/modules/codeSource.js @@ -222,7 +222,7 @@ define([ }; if ($('[class*="src-"]:not(.source_visible)')[0]) { - innerNavigation.addMenuItem(RES_TOGGLER_SHOW_CODE, showAllCode, hideAllCode); + innerNavigation.addMenuItem(RES_TOGGLER_SHOW_CODE, showAllCode, hideAllCode, 'source_source-code_action-item'); } showStaticCode(); diff --git a/assets/js/modules/parseFileTree.js b/assets/js/modules/parseFileTree.js index 2d67dd2..58e88ed 100644 --- a/assets/js/modules/parseFileTree.js +++ b/assets/js/modules/parseFileTree.js @@ -17,7 +17,7 @@ define([ ], function ($, module, data, allSpecs) { function ParseFileTree() { - this.json = $.parseJSON(data.toString()); + this.json = JSON.parse(data); } ParseFileTree.prototype = module.createInstance(); diff --git a/assets/js/modules/search.js b/assets/js/modules/search.js index 3fe0350..27f5f49 100644 --- a/assets/js/modules/search.js +++ b/assets/js/modules/search.js @@ -39,12 +39,18 @@ Search.prototype.constructor = Search; Search.prototype = module.createInstance(); Search.prototype.init = function() { + var _this = this; + this.activated = false; this.targetField = $('#livesearch'); this.header = $('.source_header'); this.prepareAutoCompleteData(); this.initSearchField(); + + setTimeout(function() { + _this.targetField.attr('data-initialized', 'true'); + }, 1); }; Search.prototype.prepareAutoCompleteData = function() { diff --git a/package.json b/package.json index f549c13..2361e65 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "devDependencies": { "assert": "~1.1.1", "cross-spawn": "^0.4.0", + "grunt-casperjs": "^2.1.0", "grunt-mocha-test": "^0.12.4", "mocha": "^2.0.1", "should": "~4.0.4", diff --git a/test/casperjs/common.js b/test/casperjs/common.js new file mode 100644 index 0000000..9b6e497 --- /dev/null +++ b/test/casperjs/common.js @@ -0,0 +1,44 @@ +var appPort = casper.cli.get("app-port") || 8080; +var url = 'http://127.0.0.1:' + appPort; + +casper.options.viewportSize = {width: 1024, height: 768}; + +var urlsToCheck = [ + url, + url + '/docs/spec/', + url + '/docs/' +]; + +urlsToCheck.forEach(function(item){ + casper.test.begin('Check availability and JS errors on ' + item, 2, function(test) { + var error = {}; + + casper.once("page.error", function onError(msg, trace) { + error.msg = msg; + + this.echo("Error: " + msg, "ERROR"); + this.echo("file: " + trace[0].file, "WARNING"); + this.echo("line: " + trace[0].line, "WARNING"); + this.echo("function: " + trace[0]["function"], "WARNING"); + }); + + casper.start(item).then(function(response) { + if (response.status !== 200) { + test.fail("Page load error, expected status 200, got " + response.status); + } else { + test.pass("Status 200 OK"); + } + }).then(function() { + if (typeof error.msg === 'string') { + test.fail("JS errors found: "+ error.msg); + } else { + test.pass("No JS errors"); + } + + casper.wait(200, function(){ + // Slow down a bit, because of strange API bug + }); + + }).run(function() { test.done() }).clear(); + }); +}); \ No newline at end of file diff --git a/test/casperjs/globalNav.js b/test/casperjs/globalNav.js new file mode 100644 index 0000000..c5caee1 --- /dev/null +++ b/test/casperjs/globalNav.js @@ -0,0 +1,33 @@ +var appPort = casper.cli.get('app-port') || 8080; +var url = 'http://127.0.0.1:' + appPort + '/docs/'; + +casper.options.viewportSize = {width: 1024, height: 768}; + +casper.test.begin('Check navigaton page', 3, function suite(test) { + casper.start(url).then(function() { + var _this = this; + var nav = '.source_catalog_list .source_catalog_list_i'; + + this.waitForSelector(nav, + function pass() { + test.assertEval(function (nav) { + return document.querySelectorAll(nav).length > 5; + }, 'Should have more than 5 nav items', [nav]); + + test.assertEval(function (nav) { + return !!document.querySelector(nav + ' .source_catalog_a[href="/docs/base"]') && + !!document.querySelector(nav + ' .source_catalog_a[href="/docs/clarify"]') && + !!document.querySelector(nav + ' .source_catalog_a[href="/docs/starting"]'); + }, 'Right nav items in set', [nav]); + }, + function fail() { + test.fail(nav); + } + ); + + }).then(function(){ + this.click('.source_catalog_image-tumbler'); + test.assertExists('.source_catalog.__show-preview', 'Show preview toggled'); + + }).run(function() { test.done() }).clear(); +}); \ No newline at end of file diff --git a/test/casperjs/search.js b/test/casperjs/search.js new file mode 100644 index 0000000..83107fe --- /dev/null +++ b/test/casperjs/search.js @@ -0,0 +1,50 @@ +var appPort = casper.cli.get('app-port') || 8080; +var url = 'http://127.0.0.1:' + appPort; + +casper.options.viewportSize = {width: 1024, height: 768}; + +casper.test.begin('Checking search', 3, function suite(test) { + casper.start(url).then(function() { + var _this = this; + var input = '.source_search .source_search_it'; + var autoComplete = '.autocomplete-wrapper .autocomplete-suggestion:first-child a'; + var searchField = '.source_search_it[data-initialized]'; + + test.assertExists(input, 'Search input exists'); + + this.waitForSelector(searchField, + function pass() { + casper.sendKeys(searchField, 'main', {keepFocus: true}); + + _this.waitForSelector(autoComplete, + function pass() { + this.click(autoComplete); + }, + function fail() { + test.fail(autoComplete); + } + ); + }, + function fail() { + test.fail(searchField); + } + ); + + }).then(function() { + + this.waitFor( + function check() { + return (this.getCurrentUrl() === url+'/docs/base/'); + }, + function then() { // step to execute when check() is ok + test.assertExists('.source_main > h1', 'Spec header exists'); + + test.assertEquals(this.getCurrentUrl(), url+'/docs/base/', 'New page URL is right') + }, + function timeout() { // step to execute if check has failed + this.echo('Failed to navigate to search result'); + } + ); + + }).run(function() { test.done() }).clear(); +}); \ No newline at end of file diff --git a/test/casperjs/snippets.md b/test/casperjs/snippets.md new file mode 100644 index 0000000..44dd4ad --- /dev/null +++ b/test/casperjs/snippets.md @@ -0,0 +1,62 @@ +# CasperJS code snippets + +Timeout + +``` +casper.wait(1000, function () { +}); +``` + +Screenshot + +``` +this.capture('test.png'); + +this.capture('test.png', { + top: 0, + left: 0, + width: 1024, + height: 768 +}); +``` + +Wait for + +``` +_this.waitForSelector(autoComplete, + function pass() { + this.click(autoComplete); + }, + function fail() { + test.fail(autoComplete); + } +); + +this.waitFor( + function check() { + return (this.getCurrentUrl() === url+'/docs/base/'); + }, + function then() { // step to execute when check() is ok + test.assertExists('.source_main > h1', 'Spec header exists'); + + test.assertEquals(this.getCurrentUrl(), url+'/docs/base/', 'New page URL is right') + }, + function timeout() { // step to execute if check has failed + this.echo('Failed to navigate to search result'); + } +); +``` + +Eval + +``` +var nav = 'some' +test.assertEval(function (nav) { + return document.querySelectorAll(nav).length > 5; +}, 'Should have more than 5 nav items', [nav]); + +var js = this.evaluate(function() { + return document; +}); +this.echo(js.all[0].outerHTML); +``` From 1760afcf690927ab9387189f58933b016b0cd85a Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 18:32:49 +0200 Subject: [PATCH 04/10] add spec page test, improve common tests --- test/casperjs/common.js | 29 +++++++------ test/casperjs/specpage.js | 89 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 13 deletions(-) create mode 100644 test/casperjs/specpage.js diff --git a/test/casperjs/common.js b/test/casperjs/common.js index 9b6e497..238f45f 100644 --- a/test/casperjs/common.js +++ b/test/casperjs/common.js @@ -9,20 +9,27 @@ var urlsToCheck = [ url + '/docs/' ]; +var error = {}; + +casper.on("page.error", function(msg, trace) { + error.msg = msg; + + this.echo("Error: " + msg, "ERROR"); + this.echo("file: " + trace[0].file, "WARNING"); + this.echo("line: " + trace[0].line, "WARNING"); + this.echo("function: " + trace[0]["function"], "WARNING"); +}); + urlsToCheck.forEach(function(item){ casper.test.begin('Check availability and JS errors on ' + item, 2, function(test) { - var error = {}; + error = {}; - casper.once("page.error", function onError(msg, trace) { - error.msg = msg; + casper.start(item).then(function(response) { - this.echo("Error: " + msg, "ERROR"); - this.echo("file: " + trace[0].file, "WARNING"); - this.echo("line: " + trace[0].line, "WARNING"); - this.echo("function: " + trace[0]["function"], "WARNING"); - }); + casper.wait(300, function(){ + // Slow down a bit, because of strange API bug + }); - casper.start(item).then(function(response) { if (response.status !== 200) { test.fail("Page load error, expected status 200, got " + response.status); } else { @@ -35,10 +42,6 @@ urlsToCheck.forEach(function(item){ test.pass("No JS errors"); } - casper.wait(200, function(){ - // Slow down a bit, because of strange API bug - }); - }).run(function() { test.done() }).clear(); }); }); \ No newline at end of file diff --git a/test/casperjs/specpage.js b/test/casperjs/specpage.js new file mode 100644 index 0000000..adcf794 --- /dev/null +++ b/test/casperjs/specpage.js @@ -0,0 +1,89 @@ +var appPort = casper.cli.get('app-port') || 8080; +var url = 'http://127.0.0.1:' + appPort + '/docs/spec/'; + +casper.options.viewportSize = {width: 1024, height: 768}; + +casper.test.begin('Checking inner navigation', 3, function suite(test) { + casper.start(url).then(function() { + var _this = this; + var menu = '.source_nav.__loaded'; + + this.waitForSelector(menu, + function pass() { + this.click('.source_nav .source_main_nav_li:nth-child(2) a'); + + test.assertEquals(this.getCurrentUrl(), url+'#2', 'URL with hash is right') + }, + function fail() { + test.fail(menu); + } + ); + + }).then(function() { + var highlighted = '.source_nav .source_main_nav_li:nth-child(2).__active a.__active'; + + this.waitForSelector(highlighted, + function pass() { + test.assertEval(function () { + return window.pageYOffset > 1000 && window.pageYOffset < 2500; + }, 'Page should be scrolled to section'); + + test.assertExists(highlighted, 'Menu item highlighted'); + }, + function fail() { + test.fail(highlighted); + } + ); + + }).run(function() { test.done() }).clear(); +}); + +casper.test.begin('Code source', 2, function suite(test) { + casper.start(url).then(function() { + var _this = this; + var actionItem = '.source_main_nav_ac_item.source_source-code_action-item'; + + this.waitForSelector(actionItem, + function pass() { + this.click(actionItem + ' .source_slider_frame'); + test.assertExists(actionItem + ' .source_slider_frame.source_slider_frame__on', 'Toggler is highlighted'); + }, + function fail() { + test.fail(actionItem); + } + ); + + }).then(function() { + var codeSource = '.source_source-code.source_source-code__show'; + + this.waitForSelector(codeSource, + function pass() { + test.assertExists(codeSource, 'Code source is shown'); + this.capture('test.png'); + }, + function fail() { + test.fail(codeSource); + } + ); + + }).run(function() { test.done() }).clear(); +}); + +casper.test.begin('Hash link openning', 2, function suite(test) { + casper.start(url + '#2').then(function() { + var highlighted = '.source_nav .source_main_nav_li:nth-child(2).__active a.__active'; + + this.waitForSelector(highlighted, + function pass() { + test.assertEval(function () { + return window.pageYOffset > 1000 && window.pageYOffset < 2500; + }, 'Page should be scrolled to section'); + + test.assertExists(highlighted, 'Menu item highlighted'); + }, + function fail() { + test.fail(highlighted); + } + ); + }).run(function() { test.done() }).clear(); +}); \ No newline at end of file From 9b777a49e2be8bdf2ae59b47c73c9b08a973d950 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 18:48:27 +0200 Subject: [PATCH 05/10] update main docs according to 0.5.5 --- docs/base/readme.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/base/readme.md b/docs/base/readme.md index 02c9703..fa8abdc 100644 --- a/docs/base/readme.md +++ b/docs/base/readme.md @@ -26,9 +26,9 @@ To set-up a new engine instance chose the first option `Init SourceJS in this fo To install SourceJS as a NPM package, first clone clean `user` configuration folder and then execute `npm install`. ```html -git clone https://github.com/sourcejs/init.git my-sourcejs && cd my-sourcejs +git clone https://github.com/sourcejs/init.git -b npm my-sourcejs && cd my-sourcejs npm install sourcejs --save -node ./node_modules/sourcejs/app +npm start ``` Starting from 0.6.0 we're planning to change official install path to one with NPM packages. Yeoman generator will be also replaced by [sourcejs-cli](https://github.com/sourcejs/sourcejs-cli) with commands like `run`, `install` (plugin), `init`, `create`. @@ -37,12 +37,12 @@ Starting from 0.6.0 we're planning to change official install path to one with N If you're running Windows and have some issues with [JSDom](https://github.com/tmpvar/jsdom) dependencies compilation, please check this [topic](https://github.com/sourcejs/Source/issues/23). -Alternatively with 0.5.4 we prepared a special build without JSDom, until it's full removal from core at 0.6.0. +Alternatively with 0.5.5 we prepared a special build without JSDom, until it's full removal from core at 0.6.0. ```html npm install -g yo generator-sourcejs mkdir sourcejs && cd sourcejs -yo sourcejs --branch 0.5.4-no-jsdom +yo sourcejs --branch 0.5.5-no-jsdom ``` Please note that Clarify feature is not available in `no-jsdom` version. If you had generator installed before, run `npm update -g generator-sourcejs` (v.0.4.2+ required). @@ -50,27 +50,27 @@ Please note that Clarify feature is not available in `no-jsdom` version. If you And installing same build from NPM: ```html -git clone https://github.com/sourcejs/init.git my-sourcejs && cd my-sourcejs -npm install sourcejs@0.5.4-no-jsdom --save -node .\node_modules\sourcejs\app +git clone https://github.com/sourcejs/init.git -b npm my-sourcejs && cd my-sourcejs +npm install sourcejs@0.5.5-no-jsdom --save +npm start ``` ## Commands ### Run -Installation wizard will offer to start SourceJS right after initialization. To run it manually, trigger this command in newly created folder: +Installation wizard will offer to start SourceJS right after initialization. To run it manually, trigger this command in newly created folder with SourceJS app: ```html -node app +npm start ``` -To set an alternative server port, pass `-p 8081` option. +To set an alternative server port, pass `-- -p 8081` option. Other configuration arguments are described in the help section: ```html -node app -h +npm start -- -h ``` ### Build @@ -88,7 +88,7 @@ It will trigger `npm i` and `grunt default` commands for updating dependencies a For updating SourceJS to a newer version, just pull the latest changes and trigger build: ```html -git pull && npm install +git pull && npm run build ``` ## Creating First Spec From 425bd1ce225198cfea50331fae1c9d7dce3036a6 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 18:49:02 +0200 Subject: [PATCH 06/10] announcing 0.5.5 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6ced1c3..cf8dcdb 100755 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ If you notice some bugs, or need to help finding a better solution in your proce [Materials for presentations](https://github.com/sourcejs/pres). ## Updates +* 16.08.15 [0.5.5](https://github.com/sourcejs/Source/releases/tag/0.5.5) and [0.5.5-no-jsdom](https://github.com/sourcejs/Source/releases/tag/0.5.5-no-jsdom) patch release with `` tag fix and set of functional tests * 15.08.15 [0.5.4](https://github.com/sourcejs/Source/releases/tag/0.5.4) and [0.5.4-no-jsdom](https://github.com/sourcejs/Source/releases/tag/0.5.4-no-jsdom) with middleware loader, relative paths in navigation support and other improvements * 28.05.15 [0.5.3](https://github.com/sourcejs/Source/releases/tag/0.5.3) context options support, source-as-npm package, CI integration, watcher stability improvements and other great features * 28.05.15 [0.5.3-no-jsdom](https://github.com/sourcejs/Source/releases/tag/0.5.3-no-jsdom) special release without JSDom for Windows users From 33541dad2552ecc3c3098edb74f54c9c2188f243 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 18:57:58 +0200 Subject: [PATCH 07/10] increase delay for common func test, because of some fails --- test/casperjs/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/casperjs/common.js b/test/casperjs/common.js index 238f45f..ee31bf6 100644 --- a/test/casperjs/common.js +++ b/test/casperjs/common.js @@ -26,7 +26,7 @@ urlsToCheck.forEach(function(item){ casper.start(item).then(function(response) { - casper.wait(300, function(){ + casper.wait(500, function(){ // Slow down a bit, because of strange API bug }); From abebfd51abf22f6c3145e370550552dad59df52b Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 19:18:04 +0200 Subject: [PATCH 08/10] remove temp debug screenshoting --- test/casperjs/specpage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/casperjs/specpage.js b/test/casperjs/specpage.js index adcf794..c2b1d3c 100644 --- a/test/casperjs/specpage.js +++ b/test/casperjs/specpage.js @@ -59,7 +59,6 @@ casper.test.begin('Code source', 2, function suite(test) { this.waitForSelector(codeSource, function pass() { test.assertExists(codeSource, 'Code source is shown'); - this.capture('test.png'); }, function fail() { test.fail(codeSource); From 373aec3d4bcda5dcb4b389195a506a973639a91a Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 19:18:21 +0200 Subject: [PATCH 09/10] bump version to 0.5.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2361e65..032285f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "sourcejs", "description": "Living Style Guide Engine for Managing and Developing Front-end Components.", "author": "SourceJS", - "version": "0.5.5-dev", + "version": "0.5.5", "license": "MIT", "repository": { "type": "git", From 7c2d698a86cb23c41ead25cff9a56bd57cc08f16 Mon Sep 17 00:00:00 2001 From: Robert Haritonov Date: Sun, 16 Aug 2015 20:06:23 +0200 Subject: [PATCH 10/10] turn off func testing on win CI --- Gruntfile.js | 4 ++++ app.js | 3 ++- appveyor.yml | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 677dc41..1f0e084 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -299,6 +299,10 @@ module.exports = function(grunt) { 'test-func' ]); + grunt.registerTask('ci-post-run-win', [ + 'test' + ]); + /* * * Utils diff --git a/app.js b/app.js index 5261d61..1b5577b 100644 --- a/app.js +++ b/app.js @@ -33,6 +33,7 @@ commander .option('--html', 'Turn on HTML parser on app start (requires installed and enabled parser).') .option('--test', 'Run app with tests.') .option('--no-watch', 'Run with disabled watcher.') + .option('--post-grunt [string]', 'Define Grunt command to run after app start', 'ci-post-run') .parse(process.argv); global.commander = commander; @@ -230,7 +231,7 @@ if (!module.parent) { if (commander.test) { var spawn = require('cross-spawn'); - spawn('./node_modules/grunt-cli/bin/grunt', ['ci-post-run', '--port='+port], {stdio: 'inherit'}) + spawn('./node_modules/grunt-cli/bin/grunt', [commander.postGrunt, '--port='+port], {stdio: 'inherit'}) .on('close', function (code) { if (code === 0) { log.info('Test successful'); diff --git a/appveyor.yml b/appveyor.yml index a78117f..ae75ddf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,8 +16,8 @@ before_test: "git clone https://github.com/sourcejs/init.git user" test_script: - node --version && npm --version - - ps: "npm run ci-test # PowerShell" # Pass comment to PS for easier debugging - - cmd: "npm run ci-test-nw" # Run without watch because of CI bug + - ps: "npm run ci-test-win # PowerShell" # Pass comment to PS for easier debugging + - cmd: "npm run ci-test-win" # Run without watch because of CI bug matrix: fast_finish: true diff --git a/package.json b/package.json index 032285f..a454dad 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "start": "node app", "test": "grunt ci-pre-run && node app.js --test", "ci-test": "grunt ci-pre-run && node app.js --test --log trace", - "ci-test-nw": "grunt ci-pre-run && node app.js --test --log trace --no-watch" + "ci-test-win": "grunt ci-pre-run && node app.js --post-grunt ci-post-run-win --test --log trace --no-watch" }, "devDependencies": { "assert": "~1.1.1",