From 470c7d1ee762fd2639f2cfba61e14cf70fdb08c0 Mon Sep 17 00:00:00 2001 From: Brent Westbrook Date: Thu, 13 Feb 2025 21:00:40 -0500 Subject: [PATCH 1/2] remove libc dependency --- Cargo.lock | 3 +-- Cargo.toml | 1 - src/main.rs | 12 ++---------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7f6f33e..220d3ff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -683,7 +683,6 @@ dependencies = [ "git2", "insta", "intder", - "libc", "log", "nalgebra", "psqs", diff --git a/Cargo.toml b/Cargo.toml index 68e69ec7..73b7bb8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] intder = { git = "https://github.com/ntBre/intder" } -libc = "0.2.169" nalgebra = "0.33.2" psqs = { git = "https://github.com/ntBre/psqs" } rust-anpass = { git = "https://github.com/ntBre/rust-anpass" } diff --git a/src/main.rs b/src/main.rs index 39a1f963..24e1a21d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{fs::File, os::unix::prelude::AsRawFd, path::Path}; +use std::path::Path; use pbqff::{ cleanup, @@ -75,15 +75,7 @@ fn main() -> Result<(), std::io::Error> { if path.exists() && !args.overwrite { die!("existing pbqff output. overwrite with -o/--overwrite"); } - let outfile = File::create(path).expect("failed to create outfile"); - let logfile = File::create("pbqff.log").expect("failed to create log file"); - let out_fd = outfile.as_raw_fd(); - let log_fd = logfile.as_raw_fd(); - // redirect stdout to outfile and stderr to logfile - unsafe { - libc::dup2(out_fd, 1); - libc::dup2(log_fd, 2); - } + let config = Config::load(&args.infile); println!("PID: {}", std::process::id()); println!("version: {}", version()); From e0831f6cc808b7159406165edf2a33404e416d57 Mon Sep 17 00:00:00 2001 From: Brent Westbrook Date: Thu, 13 Feb 2025 21:22:29 -0500 Subject: [PATCH 2/2] save snapshots from stdout --- tests/run.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/run.rs b/tests/run.rs index dacc2066..db24957d 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -1,4 +1,4 @@ -use std::{fs::read_to_string, path::Path}; +use std::path::Path; use assert_cmd::Command; use insta::{assert_snapshot, with_settings}; @@ -21,11 +21,11 @@ fn run(path: &str, other_files: &[&str]) -> std::io::Result<()> { let assert = cmd.arg("pbqff.toml").current_dir(&dir).assert(); let output = assert.get_output(); + let stderr = String::from_utf8_lossy(&output.stderr); + let stdout = String::from_utf8_lossy(&output.stdout); assert!( output.status.success(), - "stderr: {}\nlog: {}", - String::from_utf8_lossy(&output.stderr), - read_to_string(dir.path().join("pbqff.log"))?, + "stderr: {stderr}\nstdout: {stdout}" ); // filter out essentially all of the numerical results just to check that @@ -49,7 +49,7 @@ fn run(path: &str, other_files: &[&str]) -> std::io::Result<()> { snapshot_suffix => path }, { - assert_snapshot!(read_to_string(dir.path().join("pbqff.out")).unwrap()); + assert_snapshot!(stdout); }); Ok(())