TestCase: avoid circular refs between GTest and this
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 18 Mar 2013 19:00:43 +0000 (19:00 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 18 Mar 2013 21:01:44 +0000 (21:01 +0000)
commit8268c6efbe20a9274dc1b4ad2f61b18406dfb86c
tree76995b8d23c2ecb63bb23c2a19f238ca2d05091c
parentafb97caf1afd2e78daf43b702da9a64172151216
TestCase: avoid circular refs between GTest and this

Instead of running tests via the Adaptor inner class, run them via
a C helper that takes a weak ref to the TestCase. This relies on the
caller keeping a ref to the TestCase until after Test.run() - but I
recently converted the tests to do exactly that, so that's OK.

Adding a debug message which prints this.ref_count to final_tear_down()
reveals that some of our regression tests still leak the TestCase, but
many don't now.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=695381
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip@tecnocode.co.uk>
tests/lib/Makefile.am
tests/lib/test-case-helper.c [new file with mode: 0644]
tests/lib/test-case.vala