mojo-pytest
mojo-pytest copied to clipboard
Code coverage support
The initial implementation of mojo-pytest simply uses mojo run, however using mojo build; mojo debug and passing appropriate LLDB commands to the process, could maybe enable pytest code coverage reporting.
Mojo build has this warning in it's help banner:
Please note that there are issues when generating debug info for some Mojo programs that have yet to be addressed.
Alas, I tried some experiments with the mojo debugger, but failed to emit the file and line number of the mojo source:
$ mojo build --no-optimization --debug-info-language Mojo --debug-level full pytest_experiment.mojo
$ mojo debug pytest_experiment
Current executable set to '/Users/guidorice/mojo/scratch/pytest_experiment' (arm64).
(lldb) b main
Breakpoint 1: 2 locations.
(lldb) r
Process 82556 launched: '/Users/guidorice/mojo/scratch/pytest_experiment' (arm64)
Process 82556 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
frame #0: 0x0000000100008d98 pytest_experiment`main
pytest_experiment`main:
-> 0x100008d98 <+0>: stp x29, x30, [sp, #-0x10]!
0x100008d9c <+4>: bl 0x100008724 ; _builtin__startup___wrap_and_execute_main_fn_None_builtin_simd_SIMD_si32_1___mlir_type_kgen_pointer_pointer_scalar_ui8__12x5_main_func_pytest_experiment_mainkA6A6AkA6A6AcBoApAgAtA_AgAeBoAkA6A6AkA6A6AcB8B_BsAgA8B_BeBsAuAhAuA8A8A8A_A_A_ApAsA9ABBiAkA6A6AoApAiA
0x100008da0 <+8>: ldp x29, x30, [sp], #0x10
0x100008da4 <+12>: ret
(lldb) image lookup --address 0x100008d98
Address: pytest_experiment[0x0000000100008d98] (pytest_experiment.__TEXT.__text + 17744)
Summary: pytest_experiment`main
Reference: https://stackoverflow.com/questions/59013694/how-to-get-line-numbers-same-as-lldb-using-atos-addr2line-llvm-symbolizer-lldb-i
Need to re-evaluate if this is feasible, after #17 .
Closing this until such time as mojo test produces code coverage info in it's diagnostic output.