DescriptionHelper: test a function for correct locking.
(The diff still includes that of https://codereview.appspot.com/10433043 for which I haven't had a second review vote yet — please ignore that part here, and focus on testLockingFunction(), its uses, and its tests.)
This is the outcome of discussion at
https://code.launchpad.net/~jtv/juju-core/create-gwacl-sessions/+merge/170032
but produces a helper that is much, much simpler. It could become generic,
although one thing is still missing: it currently only works for locks that
are of type sync.Mutex. It probably ought to work for any type of lock.
Failure of a function to acquire the right lock(s) is a constant risk in
concurrent programs, so one of the things most worth testing, but it's also
relatively hard to test for and so nobody ever does it. Of course if you
can forget the locking you can also forget the test, but this helper makes it
very easy to guard against regressions.
https://code.launchpad.net/~jtv/juju-core/generic-locking-test/+merge/170477
(do not edit description out of merge proposal)
Patch Set 1 #
Total comments: 7
MessagesTotal messages: 5
|