summaryrefslogtreecommitdiffstats
path: root/tools/cr
diff options
context:
space:
mode:
authorpetrcermak <petrcermak@chromium.org>2014-11-17 03:53:55 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-17 11:54:16 +0000
commitc39ccf5724057a6671fef3c0dc3c1933c1668ba8 (patch)
treee2573b14c4f5733b956f2c6e452c86ee8844a2ab /tools/cr
parent8380eb3d43e19bc539b2e240b039d80b68f83c85 (diff)
downloadchromium_src-c39ccf5724057a6671fef3c0dc3c1933c1668ba8.zip
chromium_src-c39ccf5724057a6671fef3c0dc3c1933c1668ba8.tar.gz
chromium_src-c39ccf5724057a6671fef3c0dc3c1933c1668ba8.tar.bz2
Automatically build instrumentation target when running instrumentation tests using cr.
This removes the need to manually install the instrumented file (e.g. "content_shell") when running instrumentation tests (e.g. "content_shell_test"). Thus, instead of: cr install content_shell cr run content_shell_test you can simply run: cr run content_shell_test (This patch is a follow-up for https://codereview.chromium.org/690833005/) BUG=315541 Review URL: https://codereview.chromium.org/728813003 Cr-Commit-Position: refs/heads/master@{#304411}
Diffstat (limited to 'tools/cr')
-rw-r--r--tools/cr/cr/commands/run.py7
-rw-r--r--tools/cr/cr/targets/chrome.py1
-rw-r--r--tools/cr/cr/targets/chrome_shell.py1
-rw-r--r--tools/cr/cr/targets/content_shell.py1
-rw-r--r--tools/cr/cr/targets/target.py4
5 files changed, 12 insertions, 2 deletions
diff --git a/tools/cr/cr/commands/run.py b/tools/cr/cr/commands/run.py
index cbfc421..1b97b75 100644
--- a/tools/cr/cr/commands/run.py
+++ b/tools/cr/cr/commands/run.py
@@ -30,7 +30,10 @@ class RunCommand(cr.Command):
return parser
def Run(self):
- targets = cr.Target.GetTargets()
+ original_targets = cr.Target.GetTargets()
+ targets = original_targets[:]
+ for target in original_targets:
+ targets.extend(target.GetRunDependencies())
test_targets = [target for target in targets if target.is_test]
run_targets = [target for target in targets if not target.is_test]
if cr.Installer.Skipping():
@@ -46,5 +49,5 @@ class RunCommand(cr.Command):
else:
cr.Runner.Kill(run_targets, [])
cr.Installer.Reinstall(run_targets, [])
- cr.Runner.Invoke(targets, cr.context.remains)
+ cr.Runner.Invoke(original_targets, cr.context.remains)
diff --git a/tools/cr/cr/targets/chrome.py b/tools/cr/cr/targets/chrome.py
index a988a5e..25e37e8 100644
--- a/tools/cr/cr/targets/chrome.py
+++ b/tools/cr/cr/targets/chrome.py
@@ -20,4 +20,5 @@ class ChromeTestTarget(cr.NamedTarget):
CONFIG = cr.Config.From(
CR_TARGET_NAME='ChromeTest',
CR_TEST_TYPE=cr.Target.INSTRUMENTATION_TEST,
+ CR_RUN_DEPENDENCIES=[ChromeTarget.NAME],
)
diff --git a/tools/cr/cr/targets/chrome_shell.py b/tools/cr/cr/targets/chrome_shell.py
index 8a543262..47685b91 100644
--- a/tools/cr/cr/targets/chrome_shell.py
+++ b/tools/cr/cr/targets/chrome_shell.py
@@ -22,5 +22,6 @@ class ChromeShellTestTarget(cr.NamedTarget):
CONFIG = cr.Config.From(
CR_TARGET_NAME='ChromeShellTest',
CR_TEST_TYPE=cr.Target.INSTRUMENTATION_TEST,
+ CR_RUN_DEPENDENCIES=[ChromeShellTarget.NAME],
)
diff --git a/tools/cr/cr/targets/content_shell.py b/tools/cr/cr/targets/content_shell.py
index 1661d2e..753e848 100644
--- a/tools/cr/cr/targets/content_shell.py
+++ b/tools/cr/cr/targets/content_shell.py
@@ -22,4 +22,5 @@ class ContentShellTestTarget(cr.NamedTarget):
CONFIG = cr.Config.From(
CR_TARGET_NAME='ContentShellTest',
CR_TEST_TYPE=cr.Target.INSTRUMENTATION_TEST,
+ CR_RUN_DEPENDENCIES=[ContentShellTarget.NAME],
)
diff --git a/tools/cr/cr/targets/target.py b/tools/cr/cr/targets/target.py
index 8f7f7731..1bd8eca 100644
--- a/tools/cr/cr/targets/target.py
+++ b/tools/cr/cr/targets/target.py
@@ -45,6 +45,7 @@ class Target(cr.base.context.Context, cr.AutoExport):
'{CR_TARGET}{CR_TARGET_SUFFIX}', '{CR_TARGET}'),
CR_RUN_ARGUMENTS='',
CR_TEST_TYPE=test_type,
+ CR_RUN_DEPENDENCIES=[],
)
self._data = cr.context.data
self.AddChildren(config, cr.context)
@@ -55,6 +56,9 @@ class Target(cr.base.context.Context, cr.AutoExport):
self.test_type = self.Find('CR_TEST_TYPE')
self.target_name = self.Find('CR_TARGET_NAME')
+ def GetRunDependencies(self):
+ return map(Target.CreateTarget, self.Get('CR_RUN_DEPENDENCIES'))
+
@property
def build_target(self):
return self.Get('CR_BUILD_TARGET')