quasi-survey on writing mozmill tests for thunderbird

Andrew Sutherland asutherland at asutherland.org
Thu Mar 17 19:28:14 UTC 2011


On 03/17/2011 11:56 AM, Ben Bucksch wrote:
> On 17.03.2011 18:59, Andrew Sutherland wrote:
>> Was the fake-server code trying to spin its own nested event loop?  
>> While I think it would be preferable to have the fake-server running 
>> in its own dedicated thread (basically impossible with recent 
>> XPConnect changes) or own process, it seems like the mozmill test 
>> environment is roughly equivalent to the xpcshell environment, except 
>> that mozmill spins nested event loops all over the place and thus 
>> it's not safe for any other code to do the same unless the mozmill 
>> environment is prepared for it and able to transfer control to some 
>> other testing function (like we do for modal dialogs).
>
> And, FWIW, that was the other reason why the test framework was 
> unusable for me, it took me *days* (where I lost lots of hair) to get 
> my test half-way working because of this, and the tests I wrote are 
> still failing randomly until this day.

Can you elaborate on this?  Was the problem the nested event loop 
spinning, or that the fake server was not already operational?

If it is the former, I initially was not a fan of the nested event loop 
spinning, but it grew on me when it became clear how easy it was to 
accidentally violate the invariants of properly yielding back to the 
"root" event loop.  Specifically, I refer to the AsyncTestUtils 
framework I wrote ( 
https://developer.mozilla.org/en/MailNews/AsyncTestUtils_Extended_Framework 
) which is used a lot by our xpcshell tests.

(Although we could attempt to fashion a third way where we use a worker 
thread to provide a synchronous view of the world for the unit tests, 
that would have its own serious problems since it would still need to 
access things only accessible from the main thread, and the races with 
transparent proxying would likely be much more horrible.)

Andrew



More information about the tb-planning mailing list