From bab82b3b66b11f4eae44df001e9c491b8c274248 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 9 Nov 2013 21:18:23 +0000 Subject: [PATCH] Add `grunt phpunit` which runs three tasks: phpunit, ajax tests, and phpunit as multisite. You can also run `grunt phpunit:default`, `grunt phpunit:ajax`, and grunt `phpunit:multisite` separately. `grunt test` now runs the qunit task (both compiled and uncompiled scripts) and the phpunit tasks. props bpetty. fixes #25854, see #25781. git-svn-id: https://develop.svn.wordpress.org/trunk@26064 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4bfe5c3dc7..d2673cbada 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -66,7 +66,7 @@ module.exports = function(grunt) { dest: BUILD_DIR, src: [] }, - 'qunit-compiled': { + qunit: { src: 'tests/qunit/index.html', dest: 'tests/qunit/compiled.html', options: { @@ -159,6 +159,20 @@ module.exports = function(grunt) { qunit: { files: ['tests/qunit/**/*.html'] }, + phpunit: { + default: { + cmd: 'phpunit', + args: ['-c', 'phpunit.xml.dist'] + }, + ajax: { + cmd: 'phpunit', + args: ['-c', 'phpunit.xml.dist', '--group', 'ajax'] + }, + multisite: { + cmd: 'phpunit', + args: ['-c', 'tests/phpunit/multisite.xml'] + } + }, uglify: { core: { expand: true, @@ -260,8 +274,17 @@ module.exports = function(grunt) { 'uglify:tinymce', 'concat:tinymce', 'compress:tinymce', 'clean:tinymce']); // Testing tasks. - grunt.registerTask('test', ['qunit']); - grunt.registerTask('test:compiled', ['build', 'clean:qunit', 'copy:qunit-compiled', 'qunit']); + grunt.registerMultiTask('phpunit', "Runs PHPUnit tests, including the ajax and multisite tests.", function() { + grunt.util.spawn({ + cmd: this.data.cmd, + args: this.data.args, + opts: {stdio: 'inherit'} + }, this.async()); + }); + + grunt.registerTask('qunit:compiled', "Runs QUnit tests on compiled as well as uncompiled scripts.", + ['build', 'copy:qunit', 'qunit', 'clean:qunit']); + grunt.registerTask('test', "Runs all QUnit and PHPUnit tasks.", ['qunit:compiled', 'phpunit']); // Default task. grunt.registerTask('default', ['build']);