[rfc][icedtea-web][policyeditor] Unit tests fix after last PolicyEditor async IO patch

Omair Majid omajid at redhat.com
Tue Jun 3 21:23:44 UTC 2014


* Andrew Azores <aazores at redhat.com> [2014-06-02 17:08]:
> There's a race between the unit tests and PolicyEditor instances that is
> causing several PolicyEditor tests to sporadically fail, due to the tests
> asserting certain conditions about the contents of the policy file model
> before it has actually been opened and parsed. This patch fixes the race by
> adding a "performingIO" field to the editor, which is simply marked true
> immediately before starting an IO operation and marked false immediately
> after completing it. The test cases then poll the editor every 50ms, waiting
> for it to complete its IO, before performing the actual tests.

I am not sure I like this. Wouldn't it be better if the test was more
controlled and predictable? I am thinking that the test should avoid
executing thing async. Instead, it should get hold of a Runnable or
something and then execute it in the current thread. This makes sure
exceptions are caught (side note: SwingWorker and SwingUtilities can
silently swallow exceptions [1]) and also avoids races and makes things
run in a more predictable location.

Thanks,
Omair

[1] http://jonathangiles.net/blog/?p=341

-- 
PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681


More information about the distro-pkg-dev mailing list