From e88da06b050448d88496a04b415bdb83c410edea Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 17 May 2013 12:00:57 +0800 Subject: [PATCH] Can pass test file argument to PHPUnit --- extra/bash_completion | 11 +++++++++-- lib/commands/phpunit.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) 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) -- 2.11.0