Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage support #3

Closed
guidorice opened this issue Nov 6, 2023 · 3 comments
Closed

Code coverage support #3

guidorice opened this issue Nov 6, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@guidorice
Copy link
Owner

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.

@guidorice guidorice added the enhancement New feature or request label Nov 6, 2023
@guidorice guidorice self-assigned this Nov 6, 2023
@guidorice
Copy link
Owner Author

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

@guidorice
Copy link
Owner Author

Need to re-evaluate if this is feasible, after #17 .

@guidorice
Copy link
Owner Author

Closing this until such time as mojo test produces code coverage info in it's diagnostic output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant