WordPress.org

Make WordPress Core

Changeset 42760


Ignore:
Timestamp:
02/27/2018 12:31:33 AM (3 years ago)
Author:
iandunn
Message:

Build/Test Tools: Add watch:phpunit task.

This allow PHPUnit test groups to run automatically when files are changed, rather than having to be ran manually throughout the development process. This creates a smoother developer experience, and a tighter feedback loop.

Props iandunn, netweb, pento
Fixes #42282

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r42610 r42760  
    1111        BUILD_DIR = 'build/',
    1212        BANNER_TEXT = '/*! This file is auto-generated */',
    13         autoprefixer = require( 'autoprefixer' );
     13        autoprefixer = require( 'autoprefixer' ),
     14        phpUnitWatchGroup = grunt.option( 'group' );
     15
     16    if ( 'watch:phpunit' === grunt.cli.tasks[ 0 ] && ! phpUnitWatchGroup ) {
     17        grunt.log.writeln();
     18        grunt.fail.fatal(
     19            'Missing required parameters. Example usage: ' + '\n\n' +
     20            'grunt watch:phpunit --group=community-events' + '\n' +
     21            'grunt watch:phpunit --group=multisite,mail'
     22        );
     23    }
    1424
    1525    // Load tasks.
     
    743753                ],
    744754                tasks: ['qunit']
     755            },
     756            phpunit: {
     757                files: [ '**/*.php' ],
     758                tasks: [ 'phpunit:default' ]
    745759            }
    746760        }
     
    946960        grunt.util.spawn({
    947961            cmd: this.data.cmd,
    948             args: this.data.args,
     962            args: phpUnitWatchGroup ? this.data.args.concat( [ '--group', phpUnitWatchGroup ] ) : this.data.args,
    949963            opts: {stdio: 'inherit'}
    950964        }, this.async());
Note: See TracChangeset for help on using the changeset viewer.