From fc784a4e317bd21f4865a3811ecadcc2f4e2fba3 Mon Sep 17 00:00:00 2001 From: Xiaohui Chen Date: Fri, 21 Aug 2015 16:40:35 -0700 Subject: [PATCH] runtest: add --install-filter parameter --install-filter parameter is a regular expression that will be used to match the compiled apks to determine if it needs to be installed. This is very helpful when there are many apks in a test directory, but you only care about one during development. e.g. fw/base/core/tests/coretests Change-Id: I6a6a04640e549be4d90c9c659e557e7870af6771 --- testrunner/runtest.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/testrunner/runtest.py b/testrunner/runtest.py index 37b61984a..bb81a0fc5 100755 --- a/testrunner/runtest.py +++ b/testrunner/runtest.py @@ -177,6 +177,12 @@ class TestRunner(object): " This is the integer user id, e.g. 0 or 10." " If no user is specified, apk will be installed with" " adb's default behavior, which is currently all users.") + parser.add_option("--install-filter", dest="filter_re", + help="Regular expression which generated apks have to" + " match to be installed to target device. Default is None" + " and will install all packages built. This is" + " useful when the test path has a lot of apks but you" + " only care about one.") group = optparse.OptionGroup( parser, "Targets", "Use these options to direct tests to a specific " "Android target") @@ -318,9 +324,11 @@ class TestRunner(object): output = run_command.RunCommand(cmd, return_output=True, timeout_time=600) run_command.SetAbortOnError(False) logger.SilentLog(output) - self._DoInstall(output, test_requires_permissions) + filter_re = re.compile(self._options.filter_re) if self._options.filter_re else None - def _DoInstall(self, make_output, test_requires_permissions): + self._DoInstall(output, test_requires_permissions, filter_re=filter_re) + + def _DoInstall(self, make_output, test_requires_permissions, filter_re=None): """Install artifacts from build onto device. Looks for 'install:' text from make output to find artifacts to install. @@ -338,6 +346,8 @@ class TestRunner(object): # the remaining string is a space-separated list of build-generated files install_paths = m.group(2) for install_path in re.split(r'\s+', install_paths): + if filter_re and not filter_re.match(install_path): + continue if install_path.endswith(".apk"): abs_install_path = os.path.join(self._root_path, install_path) extra_flags = ""