diff options
author | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2021-05-25 23:14:15 +0000 |
---|---|---|
committer | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2021-05-25 23:14:15 +0000 |
commit | b146e9ae59ce769d435691e74fe11b3565f7eeff (patch) | |
tree | e75fd075b8aa4cf7f8ff93aac6a9ba9f8ef3a181 /Gruntfile.js | |
parent | cb5a19f8c1ec60d3a5d56a54314f683568221acb (diff) | |
download | wordpress-b146e9ae59ce769d435691e74fe11b3565f7eeff.tar.gz wordpress-b146e9ae59ce769d435691e74fe11b3565f7eeff.zip |
Build/Test Tools: Use the Composer-installed version of PHPUnit for Grunt tasks.
This makes it easier to run `phpunit` Grunt tasks without having to figure out how and which PHPUnit version needs to be installed.
It also more closely matches the `format:php` task.
Follow-up to [47881].
Props ocean90.
Fixes #53015.
git-svn-id: https://develop.svn.wordpress.org/trunk@51016 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'Gruntfile.js')
-rw-r--r-- | Gruntfile.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Gruntfile.js b/Gruntfile.js index 34cac97e54..4be458980b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -665,31 +665,24 @@ module.exports = function(grunt) { }, phpunit: { 'default': { - cmd: 'phpunit', args: ['--verbose', '-c', 'phpunit.xml.dist'] }, ajax: { - cmd: 'phpunit', args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'ajax'] }, multisite: { - cmd: 'phpunit', args: ['--verbose', '-c', 'tests/phpunit/multisite.xml'] }, 'ms-ajax': { - cmd: 'phpunit', args: ['--verbose', '-c', 'tests/phpunit/multisite.xml', '--group', 'ajax'] }, 'ms-files': { - cmd: 'phpunit', args: ['--verbose', '-c', 'tests/phpunit/multisite.xml', '--group', 'ms-files'] }, 'external-http': { - cmd: 'phpunit', args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'external-http'] }, 'restapi-jsclient': { - cmd: 'phpunit', args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient'] } }, @@ -1604,24 +1597,31 @@ module.exports = function(grunt) { ] ); // Testing tasks. - grunt.registerMultiTask('phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() { + grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() { + var args = phpUnitWatchGroup ? this.data.args.concat( [ '--group', phpUnitWatchGroup ] ) : this.data.args; + + args.unshift( 'test', '--' ); + grunt.util.spawn({ - cmd: this.data.cmd, - args: phpUnitWatchGroup ? this.data.args.concat( [ '--group', phpUnitWatchGroup ] ) : this.data.args, - opts: {stdio: 'inherit'} + cmd: 'composer', + args: args, + opts: { stdio: 'inherit' } }, this.async()); }); - grunt.registerTask('qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.', - ['build', 'copy:qunit', 'qunit']); + grunt.registerTask( 'qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.', + ['build', 'copy:qunit', 'qunit'] + ); - grunt.registerTask('test', 'Runs all QUnit and PHPUnit tasks.', ['qunit:compiled', 'phpunit']); + grunt.registerTask( 'test', 'Runs all QUnit and PHPUnit tasks.', ['qunit:compiled', 'phpunit'] ); grunt.registerTask( 'format:php', 'Runs the code formatter on changed files.', function() { var done = this.async(); var flags = this.flags; var args = changedFiles.php; + args.unshift( 'format' ); + grunt.util.spawn( { cmd: 'composer', args: args, |