Merge lp:~pitti/autopilot-gtk/testsuite into lp:autopilot-gtk

Proposed by Martin Pitt
Status: Merged
Approved by: Francis Ginther
Approved revision: 46
Merged at revision: 44
Proposed branch: lp:~pitti/autopilot-gtk/testsuite
Merge into: lp:autopilot-gtk
Diff against target: 55 lines (+14/-0)
4 files modified
CMakeLists.txt (+3/-0)
debian/control (+4/-0)
debian/rules (+5/-0)
lib/CMakeLists.txt (+2/-0)
To merge this branch: bzr merge lp:~pitti/autopilot-gtk/testsuite
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Francis Ginther Approve
Martin Pitt (community) Needs Resubmitting
Thomi Richards (community) Approve
Review via email: mp+170607@code.launchpad.net

Commit message

Add make test/ctest integration, and run tests during package build

Description of the change

This branch makes it easier to run the tests.

There is no immediately obvious tests/run, "make check" or other command, and
it takes a nontrivial amount of time to figure out how to set $GTK_PATH and
which of the various test discovery alternatives to run for this.

With this branch, the standard cmake "make test" or "ctest" commands will work,
including with separate build trees.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

I tested this both in-tree:

  cmake . && make && ctest

and with a separate build tree:

  rm -rf build; mkdir build; cd build; cmake .. && make -j4 && ctest

both starting from a pristine/clean source tree.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~pitti/autopilot-gtk/testsuite updated
45. By Martin Pitt

Run testsuite during package build

The test needs to run with a session bus and an X server, and uses gedit.
Create the necessary test environment and add corresponding build dependencies.

Revision history for this message
Martin Pitt (pitti) wrote :

Indeed, wit the previous commit tests run during package build automatically. That needs a couple of extra build dependencies and some tweaking of the test environment. Package build succeeds now under sbuild with r45 for me.

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

While developing some actual tests in lp:~pitti/autopilot-gtk/add-tests I noticed that running under xvfb-run takes very long, and also has some quirks (like, the "has_focus" property is false for a GtkEntry where it ought to be true). I think we should take the "make test"/"ctest" integration, but I'd appreciate an opinion whether you want the tests to run during package build (in debian/rules), or whether there is a more elegant way to let them run for merge proposals (i. e. CI testing) which runs them in an actual X session?

Revision history for this message
Martin Pitt (pitti) wrote :

https://code.launchpad.net/~pitti/autopilot-gtk/add-tests/+merge/171036 is the MP for landing some actual tests. It depends on this one.

Revision history for this message
Francis Ginther (fginther) wrote :

> While developing some actual tests in lp:~pitti/autopilot-gtk/add-tests I
> noticed that running under xvfb-run takes very long, and also has some quirks
> (like, the "has_focus" property is false for a GtkEntry where it ought to be
> true). I think we should take the "make test"/"ctest" integration, but I'd
> appreciate an opinion whether you want the tests to run during package build
> (in debian/rules), or whether there is a more elegant way to let them run for
> merge proposals (i. e. CI testing) which runs them in an actual X session?

Running these tests under a real X environment is a next step. There is actually a blueprint item for this month to make this possible for lp:autopilot which can then be extended here. However, until that is ready, I'm ok with adding these tests and running them with xvfb in order to get some testing enabled. Eventually we'll need to split out the autopilot tests and create a separate set of unittests that will be run during package build (and not require X).

The only thing I would address in this MP is the test runner used. I believe we should be using autopilot, but I can't figure out how to make it work. I'm currently trying this:

add_test(autopilot-gtk-functional autopilot run -f xml -o test-autopilot-gtk-functional.xml -v tests)

but I don't have the source directory right and it can't find the tests.

review: Needs Fixing
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

This looks good, but, so far this is the only project to run autopilot tests as part of the package build using xvfb. I'm happy to trial this approach for this project, and we can see how it works and whether it's worth introducing elsewhere.

review: Approve
Revision history for this message
Martin Pitt (pitti) wrote :

> The only thing I would address in this MP is the test runner used. I believe we should be using autopilot,

I actually tried that first as it seems more natural. It doesn't seem to have a discovery mode, and if I naively try

$ autopilot run tests/autopilot/tests
ImportError: Import by filename is not supported.

$ autopilot run tests.autopilot.tests
ImportError: No module named tests

Apparently one would need some __init__.py there? NB that I didn't invent this rather deep tests/autopilot/tests/ hierarchy, that was already there. (I'd just put everything into tests/ directly, ap-gtk isn't going to have a terribly huge test suite).

What we could do is

$ cd tests/autopilot; GTK_PATH=../../lib/ autopilot run tests

That works, but would look a bit ugly in CMakeList (as that's just a program to run, not a shell command). I used what autopilot itself uses in debian/rules, but if you prefer calling autopilot run, I'm happy to move all files to tests/ directoy, and just call "autopilot run tests" instead?

lp:~pitti/autopilot-gtk/testsuite updated
46. By Martin Pitt

use "autopilot run" instead of testtools discover

Revision history for this message
Martin Pitt (pitti) wrote :

I updated the test runner invocation to use "autopilot run".

review: Needs Resubmitting
Revision history for this message
Martin Pitt (pitti) wrote :

> Eventually we'll need to split out the autopilot tests and create a separate set of unittests that will be run during package build (and not require X).

For the record, this likely isn't going to happen. The lowest sensible layer at which we can test is the D-BUS interface, but this already requires that some GTK app is running, which requires a $DISPLAY. The autopilot API bits on top of that don't need $DISPLAY, so we wouldn't gain anything by testing teh D-BUS layer instead of the autopilot API IMHO.

Revision history for this message
Francis Ginther (fginther) wrote :

It works!

review: Approve
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 'CMakeLists.txt'
2--- CMakeLists.txt 2012-11-28 16:57:09 +0000
3+++ CMakeLists.txt 2013-06-25 14:44:27 +0000
4@@ -9,3 +9,6 @@
5 set (CMAKE_CXX_FLAGS "-DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++11 -fno-permissive")
6 INCLUDE(FindPkgConfig)
7 add_subdirectory(lib)
8+
9+enable_testing()
10+add_test(nose sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/tests/autopilot; GTK_PATH=${CMAKE_CURRENT_BINARY_DIR}/lib autopilot run tests")
11
12=== modified file 'debian/control'
13--- debian/control 2013-04-18 05:15:53 +0000
14+++ debian/control 2013-06-25 14:44:27 +0000
15@@ -8,6 +8,10 @@
16 libglib2.0-dev,
17 libgtk-3-dev,
18 libxpathselect-dev (>= 1.3),
19+ xvfb,
20+ dbus-x11,
21+ python-autopilot,
22+ gedit
23 Standards-Version: 3.9.4
24 Section: libs
25 Homepage: https://launchpad.net/autopilot-gtk
26
27=== modified file 'debian/rules'
28--- debian/rules 2013-01-14 23:42:40 +0000
29+++ debian/rules 2013-06-25 14:44:27 +0000
30@@ -6,8 +6,13 @@
31 %:
32 dh $@
33
34+override_dh_auto_test:
35+ mkdir -p debian/tmp/home
36+ env HOME=debian/tmp/home xvfb-run dbus-launch dh_auto_test
37+
38 override_dh_install:
39 dh_install --fail-missing
40
41 override_dh_makeshlibs:
42 dh_makeshlibs -V
43+
44
45=== modified file 'lib/CMakeLists.txt'
46--- lib/CMakeLists.txt 2013-01-25 02:43:03 +0000
47+++ lib/CMakeLists.txt 2013-06-25 14:44:27 +0000
48@@ -31,5 +31,7 @@
49 ${GTK_LIBRARIES}
50 ${XPATHSELECT_LIBRARIES})
51
52+execute_process(COMMAND ln -s . lib/modules)
53+
54 install(TARGETS autopilot
55 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gtk-3.0/modules)

Subscribers

People subscribed via source and target branches

to all changes: