Make WordPress Core

Changeset 51016


Ignore:
Timestamp:
05/25/2021 11:14:15 PM (8 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r50929 r51016  
    666666        phpunit: {
    667667            'default': {
    668                 cmd: 'phpunit',
    669668                args: ['--verbose', '-c', 'phpunit.xml.dist']
    670669            },
    671670            ajax: {
    672                 cmd: 'phpunit',
    673671                args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'ajax']
    674672            },
    675673            multisite: {
    676                 cmd: 'phpunit',
    677674                args: ['--verbose', '-c', 'tests/phpunit/multisite.xml']
    678675            },
    679676            'ms-ajax': {
    680                 cmd: 'phpunit',
    681677                args: ['--verbose', '-c', 'tests/phpunit/multisite.xml', '--group', 'ajax']
    682678            },
    683679            'ms-files': {
    684                 cmd: 'phpunit',
    685680                args: ['--verbose', '-c', 'tests/phpunit/multisite.xml', '--group', 'ms-files']
    686681            },
    687682            'external-http': {
    688                 cmd: 'phpunit',
    689683                args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'external-http']
    690684            },
    691685            'restapi-jsclient': {
    692                 cmd: 'phpunit',
    693686                args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient']
    694687            }
     
    16051598
    16061599    // Testing tasks.
    1607     grunt.registerMultiTask('phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() {
     1600    grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() {
     1601        var args = phpUnitWatchGroup ? this.data.args.concat( [ '--group', phpUnitWatchGroup ] ) : this.data.args;
     1602
     1603        args.unshift( 'test', '--' );
     1604
    16081605        grunt.util.spawn({
    1609             cmd: this.data.cmd,
    1610             args: phpUnitWatchGroup ? this.data.args.concat( [ '--group', phpUnitWatchGroup ] ) : this.data.args,
    1611             opts: {stdio: 'inherit'}
     1606            cmd: 'composer',
     1607            args: args,
     1608            opts: { stdio: 'inherit' }
    16121609        }, this.async());
    16131610    });
    16141611
    1615     grunt.registerTask('qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.',
    1616         ['build', 'copy:qunit', 'qunit']);
    1617 
    1618     grunt.registerTask('test', 'Runs all QUnit and PHPUnit tasks.', ['qunit:compiled', 'phpunit']);
     1612    grunt.registerTask( 'qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.',
     1613        ['build', 'copy:qunit', 'qunit']
     1614    );
     1615
     1616    grunt.registerTask( 'test', 'Runs all QUnit and PHPUnit tasks.', ['qunit:compiled', 'phpunit'] );
    16191617
    16201618    grunt.registerTask( 'format:php', 'Runs the code formatter on changed files.', function() {
     
    16221620        var flags = this.flags;
    16231621        var args = changedFiles.php;
     1622
    16241623        args.unshift( 'format' );
     1624
    16251625        grunt.util.spawn( {
    16261626            cmd: 'composer',
Note: See TracChangeset for help on using the changeset viewer.