Skip to content

Conversation

@folkertdev
Copy link
Member

@folkertdev folkertdev commented Nov 11, 2024

moves the tests around, and adds some additional coverage.

Codecov is not happy, but actuall if you look at it it's fine (the "uncovered lines" are comments...)

@folkertdev folkertdev force-pushed the bzip2-test-coverage branch 7 times, most recently from 8ad5cc5 to 77f0f9c Compare November 11, 2024 20:16
@codecov
Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bzip2.rs 50.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
bzip2.rs 78.96% <50.00%> (ø)

... and 1 file with indirect coverage changes

tests/quick.rs Outdated
Comment on lines 76 to 125
#[cfg(unix)]
unsafe fn custom_tty() -> (
std::sync::MutexGuard<'static, ()>,
std::process::Stdio,
std::process::Stdio,
) {
use std::{os::fd::FromRawFd, sync::Mutex};

// only one thread should be doing this at a time
static X: Mutex<()> = Mutex::new(());

let guard = X.lock().unwrap();

// Open the master PTY using libc
let cstring = std::ffi::CString::new("/dev/ptmx").unwrap();
let master_fd = unsafe { libc::open(cstring.as_ptr(), libc::O_RDWR) };
if master_fd < 0 {
panic!("{}", std::io::Error::last_os_error());
}

// Grant access to the slave PTY
if unsafe { libc::grantpt(master_fd) } < 0 {
panic!("{}", std::io::Error::last_os_error());
}

// Unlock the slave PTY
if unsafe { libc::unlockpt(master_fd) } < 0 {
panic!("{}", std::io::Error::last_os_error());
}

// Get the path to the slave PTY
let slave_path_ptr = unsafe { libc::ptsname(master_fd) };
if slave_path_ptr.is_null() {
panic!("{}", std::io::Error::last_os_error());
}

// Open the slave PTY
let slave_fd = unsafe { libc::open(slave_path_ptr, libc::O_RDWR) };
if slave_fd < 0 {
panic!("{}", std::io::Error::last_os_error());
}

unsafe {
(
guard,
Stdio::from_raw_fd(master_fd),
Stdio::from_raw_fd(slave_fd),
)
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the internet told me this is how to set up a TTY. it appears to work well as a stdout device, but not for stdin. It does work locally but that might be because of my shell? anyway on CI it does not work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the TTY stuff for now, the other changes are more important

@folkertdev folkertdev requested a review from bjorn3 November 12, 2024 09:01
Base automatically changed from cleanup-test to main November 12, 2024 09:07
Co-authored-by: bjorn3 <[email protected]>
@folkertdev folkertdev merged commit a192378 into main Nov 12, 2024
@folkertdev folkertdev deleted the bzip2-test-coverage branch November 12, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants