Project: clover
Issue CLOV-1253: Some of per-test recording strategies do not work for multi-threaded applications
*Introduction* We've got five per-test recording strategies: * Diffing - clover.pertest.coverage=diff * Null - clover.pertest.coverage=off * SingleThreaded - clover.pertest.coverage= and clover.pertestcoverage.threading= - DEFAULT POLICY * Synchronized clover.pertest.coverage= and clover.pertestcoverage.threading=synchronized * Volatile - clover.pertest.coverage= and clover.pertestcoverage.threading=volatile *Current status* 1) A SingleThreaded does not work with multi-threaded apps. Of course it's designed for single thread only. But at least it should have a correct value of coverage for a test case from a current thread. Expected number of hit counts is between: {noformat} hits(current test) <= ... <= hits(curent test + all other concurrent tests) {noformat} but currently actualHits can be < than hits(current test) due to fact that CloverBitSet.set\(n\) is not thread-safe. 2) A Volatile strategy has a similar problem. CloverBitSet.set\(n\) is not thread safe. Starting/ending of test slices works fine. 3) A Synchronized is correct because we've got 'CloverBitSet.set\(n\)' wrapped in a synchronized block. Starting/ending of test slices works fine. 4) A Diffing needs more tests. *Possible fix* CloverBitSet could have two variants: * compact - store hits as bit mask in long[] array - set\(n\) is not thread-safe, can be used for report generation as it consumes less memory * exploded - store hits as boolean[] array - set\(n\) \{ arr[n] = true \} would be thread-safe, used for runtime recording; it consumes 8x more memory but on the other hand we usually don't have 10'000 tests running in parallel; number of parallel tests is ~ number of processor cores available
Story points: 5