Can pass test file argument to PHPUnit
authorFrederic Massart <fred@moodle.com>
Fri, 17 May 2013 04:00:57 +0000 (12:00 +0800)
committerFrederic Massart <fred@moodle.com>
Fri, 17 May 2013 04:00:59 +0000 (12:00 +0800)
extra/bash_completion
lib/commands/phpunit.py

index 21c909d..c02e95e 100644 (file)
@@ -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"
index 51cec73..b051922 100644 (file)
@@ -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)