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
=== modified file 'bin/u1trial'
--- bin/u1trial 2010-12-20 15:32:15 +0000
+++ bin/u1trial 2010-12-20 16:41:55 +0000
@@ -33,14 +33,26 @@
33sys.path.insert(0, os.path.abspath("."))33sys.path.insert(0, os.path.abspath("."))
3434
3535
36class TestRunner(TrialRunner):36def _install_reactor():
37 """The test runner implementation."""37 """Install the correct reactor according to the platform."""
3838 # the select reactor seems to be the most stable one in darwin
39 def __init__(self):39 # and win32, we will just install a reactor for windows and use
40 # the default one for the other platforms.
41 platform = sys.platform
42 if platform not in ['win32', 'darwin']:
40 # install the glib2reactor before any import of the reactor to avoid43 # install the glib2reactor before any import of the reactor to avoid
41 # using the default SelectReactor and be able to run the dbus tests44 # using the default SelectReactor and be able to run the dbus tests
42 from twisted.internet import glib2reactor45 from twisted.internet import glib2reactor
43 glib2reactor.install()46 glib2reactor.install()
47
48class TestRunner(TrialRunner):
49 """The test runner implementation."""
50
51 def __init__(self):
52 # install the correct reactor accrding to the platform, do
53 # this to ensure that we can instantiate the best reactor per
54 # platform
55 _install_reactor()
44 from twisted.trial.reporter import TreeReporter56 from twisted.trial.reporter import TreeReporter
4557
46 # setup a custom XDG_CACHE_HOME and create the logs directory58 # setup a custom XDG_CACHE_HOME and create the logs directory

Subscribers

People subscribed via source and target branches

to all changes: