Merge lp:~mandel/ubuntuone-dev-tools/use_correct_reactor into lp:ubuntuone-dev-tools

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 17
Merged at revision: 17
Proposed branch: lp:~mandel/ubuntuone-dev-tools/use_correct_reactor
Merge into: lp:ubuntuone-dev-tools
Diff against target: 34 lines (+16/-4)
1 file modified
bin/u1trial (+16/-4)
To merge this branch: bzr merge lp:~mandel/ubuntuone-dev-tools/use_correct_reactor
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
dobey (community) Approve
Review via email: mp+44211@code.launchpad.net

Commit message

Added code to select the correct reactor according to the platform so that u1trial can be used in platforms that do not have glib by default to fix lp:692507

Description of the change

Added code to select the correct reactor according to the platform so that u1trial can be used in platforms that do not have glib by default to fix lp:692507

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

This is a bit backwards from what is being done in the ubuntuone projects, where dbus is getting used on non-Windows platforms. There will also have to be more work to be able to do this, as tests that use the DBus runner are going to require the glib reactor for doing async calls. So I guess we also need to have some way to check that the reactor and service runners are compatible in some way, otherwise you will get lots of weird errors running the tests on something other than Linux.

review: Needs Fixing
16. By Manuel de la Peña

Check if the OS is not windows since on windows we do not have the glib reactor.

17. By Manuel de la Peña

Added darwin to the list of platforms where the glib reactor is not present.

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

It's ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1trial'
2--- bin/u1trial 2010-12-20 15:32:15 +0000
3+++ bin/u1trial 2010-12-20 16:41:55 +0000
4@@ -33,14 +33,26 @@
5 sys.path.insert(0, os.path.abspath("."))
6
7
8-class TestRunner(TrialRunner):
9- """The test runner implementation."""
10-
11- def __init__(self):
12+def _install_reactor():
13+ """Install the correct reactor according to the platform."""
14+ # the select reactor seems to be the most stable one in darwin
15+ # and win32, we will just install a reactor for windows and use
16+ # the default one for the other platforms.
17+ platform = sys.platform
18+ if platform not in ['win32', 'darwin']:
19 # install the glib2reactor before any import of the reactor to avoid
20 # using the default SelectReactor and be able to run the dbus tests
21 from twisted.internet import glib2reactor
22 glib2reactor.install()
23+
24+class TestRunner(TrialRunner):
25+ """The test runner implementation."""
26+
27+ def __init__(self):
28+ # install the correct reactor accrding to the platform, do
29+ # this to ensure that we can instantiate the best reactor per
30+ # platform
31+ _install_reactor()
32 from twisted.trial.reporter import TreeReporter
33
34 # setup a custom XDG_CACHE_HOME and create the logs directory

Subscribers

People subscribed via source and target branches

to all changes: