Merge lp:~michihenning/unity/phablet-unity-api-whitespace-test into lp:unity/phablet

Proposed by Michi Henning
Status: Merged
Approved by: Jussi Pakkanen
Approved revision: no longer in the source branch.
Merged at revision: 575
Proposed branch: lp:~michihenning/unity/phablet-unity-api-whitespace-test
Merge into: lp:unity/phablet
Prerequisite: lp:~michihenning/unity/phablet-unity-api-merge-tests
Diff against target: 698 lines (+253/-122)
26 files modified
Bottombar/Bottombar.qml (+1/-1)
CMakeLists.txt (+4/-0)
Components/ListItems/Header.qml (+1/-1)
Components/Revealer.qml (+3/-3)
Components/UbuntuShapeForItem.qml (+89/-89)
Greeter/Greeter.qml (+3/-3)
Greeter/GreeterContent.qml (+1/-1)
Greeter/LoginList.qml (+1/-1)
Hud/AppStack.qml (+1/-1)
Hud/ResultList.qml (+1/-1)
Panel/Indicators.qml (+1/-1)
Shell.qml (+1/-1)
include/unity/api/CMakeLists.txt (+1/-1)
include/unity/api/Version.h.in (+2/-2)
plugins/Unity/bottombarvisibilitycommunicatorshell.h (+1/-1)
plugins/Unity/categories.cpp (+1/-1)
plugins/Unity/lens.cpp (+3/-3)
plugins/Utils/tests/CMakeLists.txt (+1/-1)
runtests.sh (+1/-2)
tests/CMakeLists.txt (+1/-0)
tests/autopilot/qml_phone_shell/tests/helpers.py (+2/-2)
tests/autopilot/qml_phone_shell/tests/testcases.py (+2/-2)
tests/qmluitests/UnityTestCase.qml (+1/-1)
tests/unittests/SideStage/tst_SideStage.qml (+3/-3)
tests/whitespace/CMakeLists.txt (+23/-0)
tests/whitespace/check_whitespace.py (+104/-0)
To merge this branch: bzr merge lp:~michihenning/unity/phablet-unity-api-whitespace-test
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Jussi Pakkanen (community) Approve
Michał Sawicz Needs Fixing
Pete Woods Pending
Review via email: mp+157329@code.launchpad.net

Commit message

Added test to scan for trailing whitespace in source files.

Description of the change

This MP adds a test to scan source files for trailing whitespace. File types examined are:

.cpp .h .py .sh .qml .js and CMakeLists.txt

Please suggest anything else that should be added.

I removed trailing whitespace from a bunch of source files so the test passes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

The failure comes from the prerequisite - once the other is fixed this should be fine again.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

I'm not sure i agree with this intolerance against whitespaces but the "Renamed Version.h.cmake to Version.h.in" seems like it doesn't belong in here, no?

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

The checker script is starting to push the limits of what should be implemented in shell. This one is fine but in the future I would like to see these kinds of things done in Python.

Other than that, approve with the same comment as aacid.

review: Approve
Revision history for this message
Pete Woods (pete-woods) wrote :

> The checker script is starting to push the limits of what should be
> implemented in shell. This one is fine but in the future I would like to see
> these kinds of things done in Python.

Indeed, for example it looks like this script wouldn't like files with spaces in the name.

>
> Other than that, approve with the same comment as aacid.

Revision history for this message
Pete Woods (pete-woods) wrote :

> > The checker script is starting to push the limits of what should be
> > implemented in shell. This one is fine but in the future I would like to see
> > these kinds of things done in Python.
>
> Indeed, for example it looks like this script wouldn't like files with spaces
> in the name.
>

I realise it's a bad idea to have source files with spaces in the name, it should just be a choice that these files would be disallowed, rather than it being because the whitespace script would break.

Revision history for this message
Michał Sawicz (saviq) wrote :

I'm all for having that test - better fix whitespaces sooner rather than later.

I agree that the script seems fragile... Also, it doesn't seem to check for \t? Why the two spaces in the regex?

Isn't there a ready-made solution for this? I'd also like to check for leading \t, or maybe just mixed \t\s?

review: Needs Fixing
Revision history for this message
Michi Henning (michihenning) wrote :

I did the rename of Version.h.cmake to Version.h.in because cmake generates lots of .cmake files. Those files contain lots of trailing space. Version.h.cmake is not a generated file so it should have a different extension.

Right, the script doesn't work with file names containing spaces. Not sure how serious this is.

@Sawicz: What looks like a double space is actually a blank and a tab :-)

I can rewrite this in Python, if you like. Not totally sure whether it's worth it though for something as simple as this?

I don't know of a ready-made tool to do this. If there is one, I'd be happy to look at it.

Revision history for this message
Michał Sawicz (saviq) wrote :

Please merge trunk, there's a conflict.

Please use '[[:space:]]$' for the regex, then, and there's three more files with whitespace issues when you merge trunk:

./Components/UbuntuShapeForItem.qml: trailing whitespace
./runtests.sh: trailing whitespace
./plugins/Unity/categories.cpp: trailing whitespace

Components/UbuntuShapeForItem.qml actually has \r\n - should be converted to unix newlines.

review: Needs Fixing
Revision history for this message
Michi Henning (michihenning) wrote :

As to trailing whitespace, it seems to be universally frowned upon, hence the test. Personally, I don't feel that strongly about it, but not having trailing whitespace makes it less likely for noise to be introduced into diffs, and it's tidier.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

I'm willing to accept this if a comment is added to the top saying:

- all future scripts of this type must be in Python
- if any changes to this script is needed, it must be rewritten in Python

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Yes indeed.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Bloody hell, why is it that jenkins compiles stuff that doesn't even exist in my tree? (Rhetorical question...)

And why do those source files get dropped into the source tree? The tests run the whitespace checker on ${CMAKE_SOURCE_DIR}, so how dome there is suddenly a new file there?

I'm looking for suggestions for how to fix the whitespace checking to avoid the problem...

Revision history for this message
Michał Sawicz (saviq) wrote :

/tmp/buildd/qml-phone-shell-1.69/ is ${CMAKE_SOURCE_DIR}, I think we might need to explicitly list the dirs / files we're interested in.

Revision history for this message
Michi Henning (michihenning) wrote :

> /tmp/buildd/qml-phone-shell-1.69/ is ${CMAKE_SOURCE_DIR}, I think we might
> need to explicitly list the dirs / files we're interested in.

What I don't get is where the extra source file comes from, and why it has trailing whitespace.

I mean, if I run a test in my local tree and it passes, why wouldn't the same test pass when run by Jenkins?

Revision history for this message
Michał Sawicz (saviq) wrote :

The file is generated by cmake when it tries to figure out the compilers and stuff. Why does it end up with a trailing whitespace I couldn't say :)

Revision history for this message
Pete Woods (pete-woods) wrote :

> I mean, if I run a test in my local tree and it passes, why wouldn't the same
> test pass when run by Jenkins?

Is Jenkins using a subdirectory for the binary directory and you a directory to the side, perhaps? That would be an explanation for why Jenkins would descend into the binary dir by recursive search from the source dir and you not..
</complete guess not having looked in any detail>

Revision history for this message
Michi Henning (michihenning) wrote :

Pete is right, the file is generated into the build dir. I'm not getting the failure locally because the version for raring i386 doesn't have trailing whitespace.

OK, seems like I'll have to add an option to the script to ignore the build dir.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Bottombar/Bottombar.qml'
2--- Bottombar/Bottombar.qml 2013-04-09 12:30:58 +0000
3+++ Bottombar/Bottombar.qml 2013-04-11 01:54:24 +0000
4@@ -116,7 +116,7 @@
5 onOpenReleased: {
6 if (hudButton.opacity != 0 && hudButton.mouseOver) {
7 hudButtonShowable.hide()
8- if (shell.applicationManager.sideStageFocusedApplication &&
9+ if (shell.applicationManager.sideStageFocusedApplication &&
10 ((hudButtonRevealer.pressedX > bottombar.width - bottombar.sideStageWidth) || !shell.applicationManager.mainStageFocusedApplication))
11 {
12 theHud.showSideStage()
13
14=== modified file 'CMakeLists.txt'
15--- CMakeLists.txt 2013-04-10 02:41:39 +0000
16+++ CMakeLists.txt 2013-04-11 01:54:24 +0000
17@@ -7,6 +7,10 @@
18
19 project(qml-phone-shell C CXX)
20
21+if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
22+ message(FATAL_ERROR "In-tree build attempt detected, aborting. Set your build dir outside your source dir, delete CMakeCache.txt from source root and try again.")
23+endif()
24+
25 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
26
27 # Instruct CMake to run moc automatically when needed.
28
29=== modified file 'Components/ListItems/Header.qml'
30--- Components/ListItems/Header.qml 2013-01-15 11:37:07 +0000
31+++ Components/ListItems/Header.qml 2013-04-11 01:54:24 +0000
32@@ -27,7 +27,7 @@
33
34 /* When this header is used in a ListViewWithPageHeader with CurrentLabelAtStart mode, to stop
35 the list's delegates contents being visible through this header, they clip themselves
36- depending on their position. However to allow delegates underlap the bottom X pixels of this
37+ depending on their position. However to allow delegates underlap the bottom X pixels of this
38 header (so delegate appears through ThinDivider say) we set an offset property here. */
39 readonly property int bottomBorderAllowedOverlap: bottomBorder.allowedBottomOverlap
40
41
42=== modified file 'Components/Revealer.qml'
43--- Components/Revealer.qml 2013-03-19 12:07:14 +0000
44+++ Components/Revealer.qml 2013-04-11 01:54:24 +0000
45@@ -70,7 +70,7 @@
46 value -= hintDisplacement
47 }
48 }
49-
50+
51 return value
52 }
53 property var draggingArea: leftDraggingArea.enabled ? leftDraggingArea : rightDraggingArea
54@@ -160,7 +160,7 @@
55 id: leftDraggingArea
56
57 property bool isOpeningArea: revealer.direction == Qt.LeftToRight
58-
59+
60 height: orientation == Qt.Vertical ? handleSize : parent.height
61 width: orientation == Qt.Horizontal ? handleSize : parent.width
62 orientation: revealer.orientation
63@@ -201,7 +201,7 @@
64 id: rightDraggingArea
65
66 property bool isOpeningArea: revealer.direction == Qt.RightToLeft
67-
68+
69 x: orientation == Qt.Vertical ? 0 : parent.width - width
70 y: orientation == Qt.Vertical ? parent.height - height : 0
71 height: orientation == Qt.Vertical ? handleSize : parent.height
72
73=== modified file 'Components/UbuntuShapeForItem.qml'
74--- Components/UbuntuShapeForItem.qml 2013-02-07 12:18:24 +0000
75+++ Components/UbuntuShapeForItem.qml 2013-04-11 01:54:24 +0000
76@@ -1,89 +1,89 @@
77-/*
78- * Copyright (C) 2012 Canonical, Ltd.
79- *
80- * This program is free software; you can redistribute it and/or modify
81- * it under the terms of the GNU General Public License as published by
82- * the Free Software Foundation; version 3.
83- *
84- * This program is distributed in the hope that it will be useful,
85- * but WITHOUT ANY WARRANTY; without even the implied warranty of
86- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87- * GNU General Public License for more details.
88- *
89- * You should have received a copy of the GNU General Public License
90- * along with this program. If not, see <http://www.gnu.org/licenses/>.
91- */
92-
93-import QtQuick 2.0
94-import Ubuntu.Components 0.1 as Theming
95-
96-/* FIXME: This component is duplicating the UbuntuShape from the SDK, but shapes more
97- * general (Item-based) components. This ability should be incorporated into the SDK's
98- * UbuntuShape so this file can be removed.
99- * Bug: https://bugs.launchpad.net/tavastia/+bug/1089595
100- */
101-
102-Item {
103- id: shape
104-
105- Theming.ItemStyle.class: "UbuntuShape-radius-" + radius
106-
107- property string radius: "small"
108- property url maskSource: Theming.ComponentUtils.style(shape, "maskSource", "")
109- property url borderSource: Theming.ComponentUtils.style(shape, "borderIdle", "")
110- property Item image
111-
112- implicitWidth: units.gu(8)
113- implicitHeight: units.gu(8)
114-
115- onWidthChanged: __updateImageDimensions()
116- onHeightChanged: __updateImageDimensions()
117- onImageChanged: __updateImageDimensions()
118-
119- function __updateImageDimensions() {
120- if (!image) return;
121- image.width = shape.width;
122- image.height = shape.height;
123- image.visible = false;
124- }
125-
126- ShaderEffect {
127- anchors.fill: parent
128- visible: shape.image
129-
130- property ShaderEffectSource mask: ShaderEffectSource {
131- sourceItem: BorderImage {
132- width: shape.width
133- height: shape.height
134- source: shape.maskSource
135- visible: false
136- }
137- }
138-
139- property ShaderEffectSource image: ShaderEffectSource {
140- sourceItem: shape.image
141- }
142-
143- fragmentShader:
144- "
145- varying highp vec2 qt_TexCoord0;
146- uniform lowp float qt_Opacity;
147- uniform sampler2D mask;
148- uniform sampler2D image;
149-
150- void main(void)
151- {
152- lowp vec4 maskColor = texture2D(mask, qt_TexCoord0.st);
153- lowp vec4 imageColor = texture2D(image, qt_TexCoord0.st);
154- gl_FragColor = imageColor * maskColor.a * qt_Opacity;
155- }
156- "
157- }
158-
159- BorderImage {
160- id: border
161-
162- anchors.fill: parent
163- source: shape.borderSource
164- }
165-}
166+/*
167+ * Copyright (C) 2012 Canonical, Ltd.
168+ *
169+ * This program is free software; you can redistribute it and/or modify
170+ * it under the terms of the GNU General Public License as published by
171+ * the Free Software Foundation; version 3.
172+ *
173+ * This program is distributed in the hope that it will be useful,
174+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
175+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176+ * GNU General Public License for more details.
177+ *
178+ * You should have received a copy of the GNU General Public License
179+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
180+ */
181+
182+import QtQuick 2.0
183+import Ubuntu.Components 0.1 as Theming
184+
185+/* FIXME: This component is duplicating the UbuntuShape from the SDK, but shapes more
186+ * general (Item-based) components. This ability should be incorporated into the SDK's
187+ * UbuntuShape so this file can be removed.
188+ * Bug: https://bugs.launchpad.net/tavastia/+bug/1089595
189+ */
190+
191+Item {
192+ id: shape
193+
194+ Theming.ItemStyle.class: "UbuntuShape-radius-" + radius
195+
196+ property string radius: "small"
197+ property url maskSource: Theming.ComponentUtils.style(shape, "maskSource", "")
198+ property url borderSource: Theming.ComponentUtils.style(shape, "borderIdle", "")
199+ property Item image
200+
201+ implicitWidth: units.gu(8)
202+ implicitHeight: units.gu(8)
203+
204+ onWidthChanged: __updateImageDimensions()
205+ onHeightChanged: __updateImageDimensions()
206+ onImageChanged: __updateImageDimensions()
207+
208+ function __updateImageDimensions() {
209+ if (!image) return;
210+ image.width = shape.width;
211+ image.height = shape.height;
212+ image.visible = false;
213+ }
214+
215+ ShaderEffect {
216+ anchors.fill: parent
217+ visible: shape.image
218+
219+ property ShaderEffectSource mask: ShaderEffectSource {
220+ sourceItem: BorderImage {
221+ width: shape.width
222+ height: shape.height
223+ source: shape.maskSource
224+ visible: false
225+ }
226+ }
227+
228+ property ShaderEffectSource image: ShaderEffectSource {
229+ sourceItem: shape.image
230+ }
231+
232+ fragmentShader:
233+ "
234+ varying highp vec2 qt_TexCoord0;
235+ uniform lowp float qt_Opacity;
236+ uniform sampler2D mask;
237+ uniform sampler2D image;
238+
239+ void main(void)
240+ {
241+ lowp vec4 maskColor = texture2D(mask, qt_TexCoord0.st);
242+ lowp vec4 imageColor = texture2D(image, qt_TexCoord0.st);
243+ gl_FragColor = imageColor * maskColor.a * qt_Opacity;
244+ }
245+ "
246+ }
247+
248+ BorderImage {
249+ id: border
250+
251+ anchors.fill: parent
252+ source: shape.borderSource
253+ }
254+}
255
256=== modified file 'Greeter/Greeter.qml'
257--- Greeter/Greeter.qml 2013-03-26 18:39:27 +0000
258+++ Greeter/Greeter.qml 2013-04-11 01:54:24 +0000
259@@ -29,10 +29,10 @@
260
261 readonly property bool narrowMode: width <= units.gu(60)
262 readonly property bool multiUser: !narrowMode // TODO: populate with real value
263-
264+
265 signal selected(int uid)
266 signal unlocked(int uid)
267-
268+
269 ListModel {
270 id: userList
271 objectName: "userList"
272@@ -79,7 +79,7 @@
273 property bool guestAccount: item ? item.guestAccount : false
274
275 source: required ? "GreeterContent.qml" : ""
276-
277+
278
279 Connections {
280 target: greeterContentLoader.item
281
282=== modified file 'Greeter/GreeterContent.qml'
283--- Greeter/GreeterContent.qml 2013-03-19 11:59:54 +0000
284+++ Greeter/GreeterContent.qml 2013-04-11 01:54:24 +0000
285@@ -24,7 +24,7 @@
286
287 property bool guestAccount: loginLoader.status == Loader.Ready && loginLoader.item.guestAccount
288 property bool ready: wallpaper.status == Image.Ready
289-
290+
291 signal selected(int uid)
292 signal unlocked(int uid)
293
294
295=== modified file 'Greeter/LoginList.qml'
296--- Greeter/LoginList.qml 2013-03-19 17:18:48 +0000
297+++ Greeter/LoginList.qml 2013-04-11 01:54:24 +0000
298@@ -180,7 +180,7 @@
299 }
300 }
301
302- // This is needed because PathView.moving is not true if the PathView
303+ // This is needed because PathView.moving is not true if the PathView
304 // moves because of an internal event (e.g. currentIndex has changed)
305 Timer {
306 id: moveTimer
307
308=== modified file 'Hud/AppStack.qml'
309--- Hud/AppStack.qml 2013-03-19 12:52:03 +0000
310+++ Hud/AppStack.qml 2013-04-11 01:54:24 +0000
311@@ -45,7 +45,7 @@
312 Connections {
313 target: model
314 // Accumulate count changes since hud clears
315- // and then readds items to the models which means
316+ // and then readds items to the models which means
317 // even if the result is the same we get lots of count changes
318 onCountChanged: mergeModelsTimer.restart()
319 }
320
321=== modified file 'Hud/ResultList.qml'
322--- Hud/ResultList.qml 2013-03-19 12:52:03 +0000
323+++ Hud/ResultList.qml 2013-04-11 01:54:24 +0000
324@@ -32,7 +32,7 @@
325 Connections {
326 target: model
327 // Accumulate count changes since hud clears
328- // and then readds items to the models which means
329+ // and then readds items to the models which means
330 // even if the result is the same we get lots of count changes
331 onCountChanged: updateModelTimer.restart()
332 }
333
334=== modified file 'Panel/Indicators.qml'
335--- Panel/Indicators.qml 2013-04-10 09:45:49 +0000
336+++ Panel/Indicators.qml 2013-04-11 01:54:24 +0000
337@@ -248,7 +248,7 @@
338 if (showAnimation.running) {
339 if (indicators.state == "initial") {
340 openOverview()
341- }
342+ }
343 indicators.state = "commit"
344 }
345 }
346
347=== modified file 'Shell.qml'
348--- Shell.qml 2013-03-26 13:45:29 +0000
349+++ Shell.qml 2013-04-11 01:54:24 +0000
350@@ -389,7 +389,7 @@
351 height: parent.height - panel.panelHeight
352
353 onShownChanged: if (shown) greeter.forceActiveFocus()
354-
355+
356 onUnlocked: greeter.hide()
357 onSelected: shell.background = greeter.model.get(uid).background;
358
359
360=== modified file 'include/unity/api/CMakeLists.txt'
361--- include/unity/api/CMakeLists.txt 2013-04-05 03:18:14 +0000
362+++ include/unity/api/CMakeLists.txt 2013-04-11 01:54:24 +0000
363@@ -21,7 +21,7 @@
364 #
365 # Generated headers
366 #
367-configure_file(Version.h.cmake Version.h)
368+configure_file(Version.h.in Version.h)
369 set(headers ${headers} ${CMAKE_CURRENT_BINARY_DIR}/Version.h)
370
371 install(FILES ${headers} DESTINATION ${HDR_INSTALL_DIR}/unity/api)
372
373=== renamed file 'include/unity/api/Version.h.cmake' => 'include/unity/api/Version.h.in'
374--- include/unity/api/Version.h.cmake 2013-04-10 02:41:39 +0000
375+++ include/unity/api/Version.h.in 2013-04-11 01:54:24 +0000
376@@ -20,11 +20,11 @@
377 * Authored by: Michi Henning <michi.henning@canonical.com>
378 */
379
380+#include <unity/config.h>
381+
382 #ifndef UNITY_API_VERSION_H
383 #define UNITY_API_VERSION_H
384
385-#include <unity/config.h>
386-
387 #define UNITY_API_VERSION_MAJOR @UNITY_API_MAJOR@
388 #define UNITY_API_VERSION_MINOR @UNITY_API_MINOR@
389 #define UNITY_API_VERSION_MICRO @UNITY_API_MICRO@
390
391=== modified file 'plugins/Unity/bottombarvisibilitycommunicatorshell.h'
392--- plugins/Unity/bottombarvisibilitycommunicatorshell.h 2013-02-11 18:11:16 +0000
393+++ plugins/Unity/bottombarvisibilitycommunicatorshell.h 2013-04-11 01:54:24 +0000
394@@ -22,7 +22,7 @@
395 class QDBusInterface;
396
397 /** This is an internal class used to talk with the bottom bar used by either
398- * applications or the SDK.
399+ * applications or the SDK.
400 * There is a method to force the bottom bar to be hidden or otherwise behave as usual
401 */
402
403
404=== modified file 'plugins/Unity/categories.cpp'
405--- plugins/Unity/categories.cpp 2013-04-10 08:11:52 +0000
406+++ plugins/Unity/categories.cpp 2013-04-11 01:54:24 +0000
407@@ -125,7 +125,7 @@
408 QVector<int> roles;
409 roles.append(Categories::RoleCount);
410 Q_FOREACH(CategoryFilter* filter, m_timerFilters) {
411- QModelIndex changedIndex = index(filter->index());
412+ QModelIndex changedIndex = index(filter->index());
413 Q_EMIT dataChanged(changedIndex, changedIndex, roles);
414 }
415 m_timerFilters.clear();
416
417=== modified file 'plugins/Unity/lens.cpp'
418--- plugins/Unity/lens.cpp 2013-04-10 08:11:52 +0000
419+++ plugins/Unity/lens.cpp 2013-04-11 01:54:24 +0000
420@@ -123,7 +123,7 @@
421 {
422 return m_globalSearchQuery;
423 }
424-
425+
426 QString Lens::noResultsHint() const
427 {
428 return m_noResultsHint;
429@@ -161,7 +161,7 @@
430 Q_EMIT globalSearchQueryChanged();
431 }
432 }
433-
434+
435 void Lens::setNoResultsHint(const QString& hint) {
436 if (hint != m_noResultsHint) {
437 m_noResultsHint = hint;
438@@ -320,7 +320,7 @@
439 {
440 Q_EMIT viewTypeChanged( (Lens::ViewType) viewType);
441 }
442-
443+
444 void Lens::onSearchFinished(unity::dash::Lens::Hints const &hints)
445 {
446 QString hint;
447
448=== modified file 'plugins/Utils/tests/CMakeLists.txt'
449--- plugins/Utils/tests/CMakeLists.txt 2013-04-05 14:00:32 +0000
450+++ plugins/Utils/tests/CMakeLists.txt 2013-04-11 01:54:24 +0000
451@@ -7,7 +7,7 @@
452 macro(run_tests)
453 set(_test_list "")
454 foreach(_test ${ARGN})
455- add_test(NAME ${_test}
456+ add_test(NAME ${_test}
457 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${_test}
458 -o ${CMAKE_BINARY_DIR}/${_test}.xml,xunitxml
459 -o -,txt
460
461=== modified file 'runtests.sh'
462--- runtests.sh 2013-04-08 10:06:50 +0000
463+++ runtests.sh 2013-04-11 01:54:24 +0000
464@@ -1,4 +1,4 @@
465-#!/bin/bash
466+#!/bin/bash
467
468 # This is a very quick and dirty attempt to figure some metrics for our tests
469 # It monitors all qml files with inotifywatch and generates a cobertura
470@@ -131,4 +131,3 @@
471 echo " </package>" >> $coveragefile
472 echo " </packages>" >> $coveragefile
473 echo "</coverage>" >> $coveragefile
474-
475
476=== modified file 'tests/CMakeLists.txt'
477--- tests/CMakeLists.txt 2013-04-10 00:02:36 +0000
478+++ tests/CMakeLists.txt 2013-04-11 01:54:24 +0000
479@@ -71,3 +71,4 @@
480 add_subdirectory(gtest)
481 add_subdirectory(unittests)
482 add_subdirectory(qmluitests)
483+add_subdirectory(whitespace)
484
485=== modified file 'tests/autopilot/qml_phone_shell/tests/helpers.py'
486--- tests/autopilot/qml_phone_shell/tests/helpers.py 2013-03-22 11:47:00 +0000
487+++ tests/autopilot/qml_phone_shell/tests/helpers.py 2013-04-11 01:54:24 +0000
488@@ -75,7 +75,7 @@
489 bottombar = self.main_window.get_bottombar()
490
491 # if we have huge amounts of pixels (e.g. Nexus10), but slow video (e.g. VM) it might take a little
492- # until the dash is fully rendered after sliding away the greeter/lockscreen and the click might
493+ # until the dash is fully rendered after sliding away the greeter/lockscreen and the click might
494 # go to the void for the first time because there's no real way to know what the display has
495 # painted already. Give it another (max retries) chance.
496 try:
497@@ -86,7 +86,7 @@
498 self.open_first_dash_home_app(retries-1)
499 else:
500 logger.warning("Failed to launch app. Giving up. Tests may fail...")
501-
502+
503
504 def show_hud(self, retries=2):
505 self.open_first_dash_home_app()
506
507=== modified file 'tests/autopilot/qml_phone_shell/tests/testcases.py'
508--- tests/autopilot/qml_phone_shell/tests/testcases.py 2013-03-13 18:29:47 +0000
509+++ tests/autopilot/qml_phone_shell/tests/testcases.py 2013-04-11 01:54:24 +0000
510@@ -9,10 +9,10 @@
511 # This file contains general purpose test cases for Unity.
512 # Each test written in this file will be executed for a variety of
513 # configurations, such as Phone, Tablet or Desktop form factors.
514-#
515+#
516 # Sometimes there is the need to disable a certain test for a particular
517 # configuration. To do so, add this in a new line directly below your test:
518-#
519+#
520 # test_testname.blacklist = (FormFactors.Tablet, FormFactors.Desktop,)
521 #
522 # Available form factors are:
523
524=== modified file 'tests/qmluitests/UnityTestCase.qml'
525--- tests/qmluitests/UnityTestCase.qml 2013-03-28 11:03:01 +0000
526+++ tests/qmluitests/UnityTestCase.qml 2013-04-11 01:54:24 +0000
527@@ -27,7 +27,7 @@
528 }
529
530 // Flickable won't recognise a single mouse move as dragging the flickable.
531- // Use 5 steps because it's what
532+ // Use 5 steps because it's what
533 // Qt uses in QQuickViewTestUtil::flick
534 // speed is in pixels/second
535 function mouseFlick(item, x, y, toX, toY, pressMouse, releaseMouse,
536
537=== modified file 'tests/unittests/SideStage/tst_SideStage.qml'
538--- tests/unittests/SideStage/tst_SideStage.qml 2013-04-10 07:44:42 +0000
539+++ tests/unittests/SideStage/tst_SideStage.qml 2013-04-11 01:54:24 +0000
540@@ -31,17 +31,17 @@
541 handleSizeCollapsed: units.gu(2)
542 handleSizeExpanded: units.gu(5)
543 }
544-
545+
546 function test_handle_data() {
547 return [
548 {tag: "expanded", expanded: true},
549 {tag: "collapsed", expanded: false}
550 ]
551 }
552-
553+
554 function test_handle(data) {
555 sideStage.handleExpanded = data.expanded
556-
557+
558 if (data.expanded) {
559 tryCompare(findChild(sideStage, "sideStageHandle"), "width", sideStage.handleSizeExpanded);
560 } else {
561
562=== added directory 'tests/whitespace'
563=== added file 'tests/whitespace/CMakeLists.txt'
564--- tests/whitespace/CMakeLists.txt 1970-01-01 00:00:00 +0000
565+++ tests/whitespace/CMakeLists.txt 2013-04-11 01:54:24 +0000
566@@ -0,0 +1,23 @@
567+#
568+# Copyright (C) 2013 Canonical Ltd
569+#
570+# This program is free software: you can redistribute it and/or modify
571+# it under the terms of the GNU General Public License version 3 as
572+# published by the Free Software Foundation.
573+#
574+# This program is distributed in the hope that it will be useful,
575+# but WITHOUT ANY WARRANTY; without even the implied warranty of
576+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
577+# GNU General Public License for more details.
578+#
579+# You should have received a copy of the GNU General Public License
580+# along with this program. If not, see <http://www.gnu.org/licenses/>.
581+#
582+# Authored by: Michi Henning <michi.henning@canonical.com>
583+#
584+
585+#
586+# Test that all source files, cmakefiles, etc. do not contain trailing whitespace.
587+#
588+
589+add_test(whitespace ${CMAKE_CURRENT_SOURCE_DIR}/check_whitespace.py ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
590
591=== added file 'tests/whitespace/check_whitespace.py'
592--- tests/whitespace/check_whitespace.py 1970-01-01 00:00:00 +0000
593+++ tests/whitespace/check_whitespace.py 2013-04-11 01:54:24 +0000
594@@ -0,0 +1,104 @@
595+#! /usr/bin/env python
596+
597+#
598+# Copyright (C) 2013 Canonical Ltd
599+#
600+# This program is free software: you can redistribute it and/or modify
601+# it under the terms of the GNU General Public License version 3 as
602+# published by the Free Software Foundation.
603+#
604+# This program is distributed in the hope that it will be useful,
605+# but WITHOUT ANY WARRANTY; without even the implied warranty of
606+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
607+# GNU General Public License for more details.
608+#
609+# You should have received a copy of the GNU General Public License
610+# along with this program. If not, see <http://www.gnu.org/licenses/>.
611+#
612+# Authored by: Michi Henning <michi.henning@canonical.com>
613+#
614+
615+#
616+# Little helper program to test that source files do not contain trailing whitespace.
617+#
618+# Usage: check_whitespace.py directory [ignore_prefix]
619+#
620+# The directory specifies the (recursive) location of the source files. Any files with a path that starts
621+# with ignore_prefix are not checked. This is useful to exclude files that are generated into the build directory.
622+#
623+# See the file_pat definition below for a list of files that are checked.
624+#
625+
626+import argparse
627+import os
628+import re
629+import sys
630+
631+progname = sys.argv[0]
632+
633+# Print msg on stderr, preceded by program name and followed by newline
634+
635+def error(msg):
636+ print >> sys.stderr, progname + ": " + msg + "\n"
637+
638+# Function to raise errors encountered by os.walk
639+
640+def raise_error(e):
641+ raise e
642+
643+# Scan lines in file_path for trailing whitespace. For each file, print the line number of the first occurrence,
644+# and the total number of occurrences if more than one.
645+
646+whitespace_pat = re.compile(r'.*[ \t]$')
647+
648+def scan_for_trailing_whitespace(file_path):
649+ with open(file_path, 'rt') as file:
650+ line_num = 0
651+ num_errors = 0
652+ for line in file:
653+ line_num += 1
654+ if whitespace_pat.match(line):
655+ if num_errors == 0:
656+ print file_path + ":" + str(line_num) + ": trailing whitespace",
657+ num_errors += 1
658+ if num_errors > 1:
659+ print "(" + str(num_errors) + " lines with trailing whitespace in total)",
660+ if num_errors != 0:
661+ print
662+ return num_errors != 0
663+
664+# Parse args
665+
666+parser = argparse.ArgumentParser(description = 'Test that source files do not contain trailing whitespace.')
667+parser.add_argument('dir', nargs = 1, help = 'The directory to (recursively) search for source files')
668+parser.add_argument('ignore_prefix', nargs = '?', default="",
669+ help = 'Ignore source files with a path that starts with the given prefix.')
670+args = parser.parse_args()
671+progname = parser.prog
672+
673+# Files we want to check for trailing whitespace.
674+
675+file_pat = r'(.*\.(c|cpp|h|in|install|js|py|qml|sh)$)|(.*CMakeLists\.txt$)'
676+pat = re.compile(file_pat)
677+
678+# Find all the files with matching file extension in the specified directory and check them for trailing whitespace.
679+
680+dir = args.dir[0]
681+ignore = args.ignore_prefix
682+
683+found_whitespace = False
684+try:
685+ for root, dirs, files in os.walk(dir, onerror = raise_error):
686+ for file in files:
687+ path = os.path.join(root, file)
688+ if not path.startswith(ignore) and pat.match(file):
689+ if scan_for_trailing_whitespace(path):
690+ found_whitespace = True
691+except OSError as e:
692+ error("cannot create file list for \"" + dir + "\": " + e.strerror)
693+ sys.exit(1)
694+
695+if found_whitespace:
696+ sys.exit(1)
697+
698+sys.exit(0)

Subscribers

People subscribed via source and target branches