From: Frederic Massart Date: Fri, 17 May 2013 04:00:57 +0000 (+0800) Subject: Can pass test file argument to PHPUnit X-Git-Tag: v0.4~12 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=e88da06b050448d88496a04b415bdb83c410edea;p=mdk.git Can pass test file argument to PHPUnit --- diff --git a/extra/bash_completion b/extra/bash_completion index 21c909d..c02e95e 100644 --- a/extra/bash_completion +++ b/extra/bash_completion @@ -134,8 +134,15 @@ function _moodle() { esac ;; phpunit) - OPTS="--force --run" - OPTS="$OPTS $($BIN info -ln)" + if [[ "${PREV}" == "--unittest" ]]; then + # Basic autocomplete for --unittest, should append a / at the end of directory names. + compopt +o nospace + OPTS="$(compgen -A file $CUR)" + compopt -o nospace + else + OPTS="--force --run --unittest" + OPTS="$OPTS $($BIN info -ln)" + fi ;; purge) OPTS="--all --integration --stable" diff --git a/lib/commands/phpunit.py b/lib/commands/phpunit.py index 51cec73..b051922 100644 --- a/lib/commands/phpunit.py +++ b/lib/commands/phpunit.py @@ -48,6 +48,14 @@ class PhpunitCommand(Command): } ), ( + ['-u', '--unittest'], + { + 'default': None, + 'help': 'test file to run. This sets --run.', + 'metavar': 'path' + } + ), + ( ['name'], { 'default': None, @@ -92,12 +100,18 @@ class PhpunitCommand(Command): try: M.initPHPUnit(force=args.force) logging.info('PHPUnit ready!') + + if args.unittest: + args.run = True + if args.run: cmd = [] if M.branch_compare(25): cmd.append('vendor/bin/phpunit') else: cmd.append('phpunit') + if args.unittest: + cmd.append(args.unittest) cmd = ' '.join(cmd) logging.info('Executing %s', cmd) process(cmd, M.get('path'), None, None)