Merge lp:~dpm/ubuntu-filemanager-app/run-ap-from-out-of-source-build into lp:ubuntu-filemanager-app

Proposed by David Planella
Status: Merged
Merged at revision: 253
Proposed branch: lp:~dpm/ubuntu-filemanager-app/run-ap-from-out-of-source-build
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~dpm/ubuntu-filemanager-app/fix-desktop-run
Diff against target: 155 lines (+132/-2)
2 files modified
tests/autopilot/filemanager/CMakePluginParser.py (+120/-0)
tests/autopilot/filemanager/tests/__init__.py (+12/-2)
To merge this branch: bzr merge lp:~dpm/ubuntu-filemanager-app/run-ap-from-out-of-source-build
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Leo Arias Pending
Nicholas Skaggs Pending
Review via email: mp+217510@code.launchpad.net

Commit message

Enable detection of the build dir and running the autopilot tests from there.

Description of the change

Enable detection of the build dir and running the autopilot tests from there.

The idea is that we can dogfood the tools we're providing to developers, thus this branch brings the ability of building the app with Qt Creator and then running the AP tests from that same build directory.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
175. By David Planella

Fix pep8 warnings

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Thanks David, this makes it easier to review.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

David, I need Leo's feedback here again, but initially speaking about this, I think we would rather see an argument to autopilot, rather than the test parse something. Leo should have a bug around for this. I don't want to let this languish, so certainly we can land something as a stop-gap if needed.

Revision history for this message
David Planella (dpm) wrote :

The issue with an argument is that is less automated (i.e. with this branch I can just run autopilot with the right build dir being auto-detected, whereas with an argument I'd have to look for the build dir and pass it to AP).

However, if you guys have got a better solution that supersedes this branch, happy to go with that too.

Revision history for this message
David Planella (dpm) wrote :

I'll mark this as Work in progress, to drop the dependency on python-lxml, which is not installed in the phone images.

Revision history for this message
Leo Arias (elopio) wrote :

> The issue with an argument is that is less automated (i.e. with this branch I
> can just run autopilot with the right build dir being auto-detected, whereas
> with an argument I'd have to look for the build dir and pass it to AP).

What I think is that we shouldn't call autopilot run directly if we are developing the app. IMO, we should call the cmake autopilot tasks.
I'm also thinking about more complex scenarios that need to start fake servers or set up fake services. For example, on the click scope we run:
make test-click-scope-autopilot-fake-servers
And it takes care of passing the right variables to the scripts to find the compiled scope and to set the right addresses for the servers.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'tests/autopilot/filemanager/CMakePluginParser.py'
--- tests/autopilot/filemanager/CMakePluginParser.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/filemanager/CMakePluginParser.py 2014-04-29 12:03:28 +0000
@@ -0,0 +1,120 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation; version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Author:
18# David Planella <david.planella@ubuntu.com>
19
20"""
21This module parses a configuration file from the Qt Creator's CMake plugin and
22enables programmatical read-only access to several of its configuration options
23"""
24
25import sys
26from lxml import etree
27
28
29class CMakePluginParseError(Exception):
30 """
31 Custom exception for errors during the parsing of a
32 CMakeLists.txt.user file
33 """
34 def __init__(self, message):
35 Exception.__init__(self, message)
36
37
38class CMakePluginParser(object):
39 """
40 Parses a CMake plugin's config file and provides R/O access to its
41 configuration options """
42
43 def __init__(self, cmakelists_usr_file='CMakeLists.txt.user'):
44 self.usr_file = cmakelists_usr_file
45
46 try:
47 self.info = etree.parse(self.usr_file)
48 except:
49 sys.stderr.write("Could not open the given " +
50 "CMakeLists.txt.user file: " + self.info)
51 raise
52
53 def _get_active_build_target(self):
54 """
55 Return the active build target from the current project in Qt Creator
56 """
57
58 try:
59 active_build_target_nr = self.info.xpath(
60 "./data/variable" +
61 "[text()='ProjectExplorer.Project.ActiveTarget']" +
62 "/../value")[0].text
63 except:
64 raise CMakePluginParseError("Could not find the active build " +
65 "target in the CMake plugin's config")
66
67 active_build_target = "ProjectExplorer.Project.Target." + \
68 active_build_target_nr
69
70 return active_build_target
71
72 def _get_active_build_config(self, active_build_target):
73 """Return the active build config from the active build targed"""
74
75 try:
76 active_build_config_nr = self.info.xpath(
77 "./data/variable[text()='{0}']".format(active_build_target) +
78 "/..//value[@key="
79 "'ProjectExplorer.Target.ActiveBuildConfiguration']")[0].text
80 except:
81 raise CMakePluginParseError("Could not find the active build " +
82 "target's active build config " +
83 "in the CMake plugin's config")
84
85 active_build_config = "ProjectExplorer.Target.BuildConfiguration." + \
86 active_build_config_nr
87
88 return active_build_config
89
90 def _get_active_build_config_path(self):
91 """Return the active build config's absolute path"""
92
93 active_build_target = self._get_active_build_target()
94 active_build_config = \
95 self._get_active_build_config(active_build_target)
96
97 try:
98 active_build_config_node = self.info.xpath(
99 "./data/variable[text()='{0}']".format(active_build_target) +
100 "/..//valuemap[@key='{0}']".format(active_build_config))[0]
101 except:
102 raise CMakePluginParseError("Could not find the active " +
103 "build config's node " +
104 "in the CMake plugin's config")
105
106 try:
107 active_build_config_path = active_build_config_node.xpath(
108 "./value[@key=" +
109 "'ProjectExplorer.BuildConfiguration.BuildDirectory']")[0].text
110 except:
111 raise CMakePluginParseError("Could not find the active build " +
112 "directory in the CMake plugin's " +
113 "config")
114
115 return active_build_config_path
116
117 @property
118 def active_build_dir(self):
119 """Return the active build config's directory as an absolute path"""
120 return self._get_active_build_config_path()
0121
=== modified file 'tests/autopilot/filemanager/tests/__init__.py'
--- tests/autopilot/filemanager/tests/__init__.py 2014-04-29 12:03:28 +0000
+++ tests/autopilot/filemanager/tests/__init__.py 2014-04-29 12:03:28 +0000
@@ -13,7 +13,7 @@
13import logging13import logging
1414
15import fixtures15import fixtures
16from filemanager import emulators16from filemanager import emulators, CMakePluginParser
1717
18from autopilot.input import Mouse, Touch, Pointer18from autopilot.input import Mouse, Touch, Pointer
19from autopilot.platform import model19from autopilot.platform import model
@@ -73,7 +73,17 @@
73 self.app = self.launch_test_click()73 self.app = self.launch_test_click()
7474
75 def _get_build_dir(self):75 def _get_build_dir(self):
76 build_dir = self.source_dir76 """
77 Returns the build dir after having parsed the CMake config file
78 generated by Qt Creator. If it cannot find it or it cannot be parsed,
79 an in-tree build is assumed and thus returned.
80 """
81 try:
82 cmake_config = CMakePluginParser.CMakePluginParser(os.path.join(
83 self.source_dir, 'CMakeLists.txt.user'))
84 build_dir = cmake_config.active_build_dir
85 except:
86 build_dir = self.source_dir
7787
78 return build_dir88 return build_dir
7989

Subscribers

People subscribed via source and target branches