DoubleDown.DynamicFacade.Cover (double_down v0.60.3)

Copy Markdown View Source

Ensures DynamicFacade-shimmed modules retain :cover instrumentation.

When ExCoverall or :cover compiles a module with coverage instrumentation, DynamicFacade.setup/1 renames the on-disk (non-instrumented) bytecode to Module.__dd_original__, stripping coverage from the backup. This module preserves coverage by:

  1. Exporting pre-shim coverdata
  2. Re-instrumenting the backup via :cover.compile_beams/1
  3. Providing merge/1 to rewrite backup coverdata back to the original name

Summary

Functions

Merge coverdata from the __dd_original__ backup into the original module name.

Merge coverdata for all registered DynamicFacade modules.

Functions

merge(module)

Merge coverdata from the __dd_original__ backup into the original module name.

Exports coverdata for Module.__dd_original__, rewrites all module-name references back to Module, imports the result, and cleans up the temp file.

Call this after all tests have completed to ensure ExCoverall sees coverage for DynamicFacade-shimmed modules under their original names.

merge_all()

Merge coverdata for all registered DynamicFacade modules.

Iterates all modules set up via DynamicFacade.setup/1 and calls merge/1 for each. No-op if :cover is not available or has no instrumented modules.

Call this from test/test_helper.exs after all tests complete:

ExUnit.after_suite(fn _ -> DoubleDown.DynamicFacade.Cover.merge_all() end)