Jhernandez has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/173025

Change subject: Tools: Run make qunit (and qunitdebug) with grunt
......................................................................

Tools: Run make qunit (and qunitdebug) with grunt

make qunit && make qunitdebug now run grunt
Same as grunt qunit && QUNIT_DEBUG=true grunt qunit

Change-Id: I4e139d9448eaae3a3838c597ef78a101cf3001d1
---
M Gruntfile.js
M Makefile
D dev-scripts/qunit.sh
D tests/externals/phantomjs-qunit-runner.js
4 files changed, 7 insertions(+), 164 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/25/173025/1

diff --git a/Gruntfile.js b/Gruntfile.js
index cb1b80d..31aaf4e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -17,6 +17,7 @@
 
        grunt.initConfig( {
                URL: process.env.URL || 'http://127.0.0.1:8080/w/index.php/',
+               QUNIT_DEBUG: ( process.env.QUNIT_DEBUG && '&debug=true' || '' ),
                QUNIT_FILTER: ( process.env.QUNIT_FILTER && '&filter=' + 
process.env.QUNIT_FILTER ) || '',
                QUNIT_MODULE: ( process.env.QUNIT_MODULE && '&module=' + 
process.env.QUNIT_MODULE ) || '',
                files: {
@@ -45,7 +46,10 @@
                qunit: {
                        all: {
                                options: {
-                                       urls: [ '<%= URL 
%>Special:JavaScriptTest/qunit?useformat=mobile<%= QUNIT_FILTER %><%= 
QUNIT_MODULE %>' ]
+                                       urls: [
+                                               '<%= URL 
%>Special:JavaScriptTest/qunit?useformat=mobile' +
+                                               '<%= QUNIT_DEBUG %><%= 
QUNIT_FILTER %><%= QUNIT_MODULE %>'
+                                       ]
                                }
                        }
                },
diff --git a/Makefile b/Makefile
index 0e55566..d66f154 100644
--- a/Makefile
+++ b/Makefile
@@ -81,10 +81,10 @@
        cd ${MW_INSTALL_PATH}/tests/phpunit && php phpunit.php --configuration 
${MW_INSTALL_PATH}/extensions/MobileFrontend/tests/phpunit/mfe.suite.xml 
--group=MobileFrontend
 
 qunit:                                 ## Run the QUnit test suite
-       @dev-scripts/qunit.sh
+       @grunt qunit
 
 qunitdebug:                            ## Run the QUnit test suite in debug 
mode
-       @dev-scripts/qunit.sh 'MobileFrontend&debug=true'
+       @QUNIT_DEBUG=true grunt qunit
 
 tests: jshint phplint phpunit qunit    ## Run the PHPUnit test suite and QUnit 
tests after linting them
 
diff --git a/dev-scripts/qunit.sh b/dev-scripts/qunit.sh
deleted file mode 100755
index 265ae1b..0000000
--- a/dev-scripts/qunit.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env bash
-echo "Running QUnit tests..."
-if command -v phantomjs > /dev/null ; then
-  URL=${MEDIAWIKI_URL:-"http://127.0.0.1:8080/w/index.php/"}
-  if [ -z "$1" ]; then
-    FILTER=""
-  else
-    FILTER="&filter=$1"
-  fi
-  echo "Using $URL as a development environment host."
-  echo "Please ensure \$wgEnableJavaScriptTest = true; in your 
LocalSettings.php"
-  echo "To specify a different host set MEDIAWIKI_URL environment variable"
-  echo '(e.g. by running "export 
MEDIAWIKI_URL=http://127.0.0.1:80/w/index.php/";)'
-  results=$(phantomjs tests/externals/phantomjs-qunit-runner.js 
"${URL}Special:JavaScriptTest/qunit?useformat=mobile$FILTER")
-       #Set the field separator to new line
-       IFS=$'\n'
-       # Iterate through each line
-       for item in $results
-       do
-               # Only print useful lines, don't print any with long urls in 
them
-               if [[ $item != *at\ http* && \
-                               $item != *at\ process\ \(* && \
-                               $item != *at\ runScript\ \(* && \
-                               $item != *at\ execute\ \(* && \
-                               $item != *at\ handlePending\ \(* ]]
-               then
-                 echo $item
-               fi
-       done
-else
-  echo "You need to install PhantomJS to run QUnit tests in terminal!"
-  echo "See http://phantomjs.org/";
-  exit 1
-fi
diff --git a/tests/externals/phantomjs-qunit-runner.js 
b/tests/externals/phantomjs-qunit-runner.js
deleted file mode 100644
index 4b1d38b..0000000
--- a/tests/externals/phantomjs-qunit-runner.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * QtWebKit-powered headless test runner using PhantomJS
- *
- * PhantomJS binaries: http://phantomjs.org/download.html
- * Requires PhantomJS 1.6+ (1.7+ recommended)
- *
- * Run with:
- *   phantomjs runner.js [url-of-your-qunit-testsuite]
- *
- * e.g.
- *   phantomjs runner.js http://localhost/qunit/test/index.html
- */
-
-/*jshint latedef:false */
-/*global phantom:false, require:false, console:false, window:false, 
QUnit:false */
-
-(function() {
-       'use strict';
-
-       var args = require('system').args;
-
-       // arg[0]: scriptName, args[1...]: arguments
-       if (args.length !== 2) {
-               console.error('Usage:\n  phantomjs runner.js 
[url-of-your-qunit-testsuite]');
-               phantom.exit(1);
-       }
-
-       var url = args[1],
-               page = require('webpage').create();
-
-       // Route `console.log()` calls from within the Page context to the main 
Phantom context (i.e. current `this`)
-       page.onConsoleMessage = function(msg) {
-               console.log(msg);
-       };
-
-       page.onInitialized = function() {
-               page.evaluate(addLogging);
-       };
-
-       page.onCallback = function(message) {
-               var result,
-                       failed;
-
-               if (message) {
-                       if (message.name === 'QUnit.done') {
-                               result = message.data;
-                               failed = !result || result.failed;
-
-                               phantom.exit(failed ? 1 : 0);
-                       }
-               }
-       };
-
-       page.open(url, function(status) {
-               if (status !== 'success') {
-                       console.error('Unable to access network: ' + status);
-                       phantom.exit(1);
-               } else {
-                       // Cannot do this verification with the 
'DOMContentLoaded' handler because it
-                       // will be too late to attach it if a page does not 
have any script tags.
-                       var qunitMissing = page.evaluate(function() { return 
(typeof QUnit === 'undefined' || !QUnit); });
-                       if (qunitMissing) {
-                               console.error('The `QUnit` object is not 
present on this page.');
-                               phantom.exit(1);
-                       }
-
-                       // Do nothing... the callback mechanism will handle 
everything!
-               }
-       });
-
-       function addLogging() {
-               window.document.addEventListener('DOMContentLoaded', function() 
{
-                       var current_test_assertions = [];
-
-                       QUnit.log(function(details) {
-                               var response;
-
-                               // Ignore passing assertions
-                               if (details.result) {
-                                       return;
-                               }
-
-                               response = details.message || '';
-
-                               if (typeof details.expected !== 'undefined') {
-                                       if (response) {
-                                               response += ', ';
-                                       }
-
-                                       response += 'expected: ' + 
details.expected + ', but was: ' + details.actual;
-                                       if (details.source) {
-                                               response += "\n" + 
details.source;
-                                       }
-                               }
-
-                               current_test_assertions.push('Failed assertion: 
' + response);
-                       });
-
-                       QUnit.testDone(function(result) {
-                               var i,
-                                       len,
-                                       name = result.module + ': ' + 
result.name;
-
-                               if (result.failed) {
-                                       console.log('Test failed: ' + name);
-
-                                       for (i = 0, len = 
current_test_assertions.length; i < len; i++) {
-                                               console.log('    ' + 
current_test_assertions[i]);
-                                       }
-                               }
-
-                               current_test_assertions.length = 0;
-                       });
-
-                       QUnit.done(function(result) {
-                               console.log('Took ' + result.runtime +  'ms to 
run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed 
+ ' failed.');
-
-                               if (typeof window.callPhantom === 'function') {
-                                       window.callPhantom({
-                                               'name': 'QUnit.done',
-                                               'data': result
-                                       });
-                               }
-                       });
-               }, false);
-       }
-})();

-- 
To view, visit https://gerrit.wikimedia.org/r/173025
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e139d9448eaae3a3838c597ef78a101cf3001d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to