We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Potential (hacky) way to do so:
xd009642/tarpaulin#13 (comment)
I was able to run kcov on doctests in the past. My quick and dirty solution was to use LD_PRELOAD and inject a execvp function. Here is the code that I used to create a .so file: #[macro_use] extern crate redhook; extern crate libc; use libc::c_char; use std::ffi::CString; use std::slice; use std::env; hook! { unsafe fn execvp(filename: *const c_char, argv: *const *const c_char) => my_execvp { let file = slice::from_raw_parts(filename as *const u8, libc::strlen(filename)); if let Ok(run) = env::var("TEST_WRAPPER") { if let Ok(cmd) = run.split_whitespace() .map(|s| CString::new(s)) .collect::<Result<Vec<_>, _>>() { if !cmd.is_empty() && file.starts_with(b"/tmp/rustdoctest") && file.ends_with(b"rust_out") { let mut args: Vec<_> = cmd.iter().map(|s| s.as_ptr()).collect(); let mut x = argv; while !(*x).is_null() { args.push(*x); x = x.offset(1); } args.push(*x); real!(execvp)(cmd[0].as_ptr(), args.as_ptr()); return; } } } real!(execvp)(filename, argv); } } To run doctests with kcov, execute LD_PRELOAD=path-to-lib.so TEST_WRAPPER=kcov cargo test --doc
I was able to run kcov on doctests in the past. My quick and dirty solution was to use LD_PRELOAD and inject a execvp function.
Here is the code that I used to create a .so file:
#[macro_use] extern crate redhook; extern crate libc; use libc::c_char; use std::ffi::CString; use std::slice; use std::env; hook! { unsafe fn execvp(filename: *const c_char, argv: *const *const c_char) => my_execvp { let file = slice::from_raw_parts(filename as *const u8, libc::strlen(filename)); if let Ok(run) = env::var("TEST_WRAPPER") { if let Ok(cmd) = run.split_whitespace() .map(|s| CString::new(s)) .collect::<Result<Vec<_>, _>>() { if !cmd.is_empty() && file.starts_with(b"/tmp/rustdoctest") && file.ends_with(b"rust_out") { let mut args: Vec<_> = cmd.iter().map(|s| s.as_ptr()).collect(); let mut x = argv; while !(*x).is_null() { args.push(*x); x = x.offset(1); } args.push(*x); real!(execvp)(cmd[0].as_ptr(), args.as_ptr()); return; } } } real!(execvp)(filename, argv); } }
To run doctests with kcov, execute LD_PRELOAD=path-to-lib.so TEST_WRAPPER=kcov cargo test --doc
LD_PRELOAD=path-to-lib.so TEST_WRAPPER=kcov cargo test --doc
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Potential (hacky) way to do so:
xd009642/tarpaulin#13 (comment)
The text was updated successfully, but these errors were encountered: