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

Release/v1.1.1 #9

Merged
merged 39 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
acf1118
Merge tag 'vfix-readme' into dev
nfurfaro Jan 24, 2024
724cc5b
refactor: simplify handling of output status codes
nfurfaro Jan 25, 2024
43a38f9
test: add if statement to test file
nfurfaro Jan 25, 2024
d2b575f
fix: better handling of excluded dirs & reporting
nfurfaro Jan 25, 2024
519a000
chore: cleanup
nfurfaro Jan 25, 2024
b15ae64
Merge branch 'feature/fix-processor-exit-codes' into dev
nfurfaro Jan 25, 2024
084e344
docs: update readme
nfurfaro Jan 26, 2024
c666973
fix: update handling of excluded dirs
nfurfaro Jan 26, 2024
a04ebb2
docs: update installation instructions
nfurfaro Jan 29, 2024
afef0e2
Merge remote-tracking branch 'refs/remotes/origin/dev'
nfurfaro Jan 29, 2024
92d89eb
wip: handle missing manifest file
nfurfaro Jan 29, 2024
28cce0d
fix: handle missing manifest file
nfurfaro Jan 29, 2024
4c1a005
fix: print "remove" under Mutation column
nfurfaro Jan 29, 2024
b3dd18e
fix: minor improvements
nfurfaro Jan 31, 2024
abc223e
chore: lceanup
nfurfaro Feb 1, 2024
6a147f0
fix: update regex to correctly mutate ! operator
nfurfaro Feb 2, 2024
ff06e95
fixup
nfurfaro Feb 2, 2024
61cb7e3
Merge branch 'feature/minor-bugfixes' into dev
nfurfaro Feb 2, 2024
cff9ca5
wip
nfurfaro Feb 4, 2024
d99a8db
chore: bump noir version to 0.23.0
nfurfaro Feb 12, 2024
f19e2f3
chore: cleanup
nfurfaro Feb 12, 2024
fdd3632
fix: use mutex to write to lib.nr
nfurfaro Feb 12, 2024
096f4a3
fixup
nfurfaro Feb 12, 2024
8b5bf21
temp logging
nfurfaro Feb 12, 2024
4fa0759
wip: try to fix shared access to stderr
nfurfaro Feb 13, 2024
6fc699e
cleanup
nfurfaro Feb 13, 2024
ff7de21
wip
nfurfaro Feb 14, 2024
5fc21d7
fixup
nfurfaro Feb 14, 2024
cd4361d
fix: solve race condition!
nfurfaro Feb 14, 2024
403cc2a
cleanup
nfurfaro Feb 14, 2024
37abe63
Merge branch 'feature/handle-build-output' into dev
nfurfaro Feb 14, 2024
318f153
chore: cleanup, fmt, clippy
nfurfaro Feb 14, 2024
9cb71eb
cleanup
nfurfaro Feb 14, 2024
b246532
trial: test out local functions
nfurfaro Feb 14, 2024
05c7601
chore: bump version for release
nfurfaro Feb 14, 2024
1cc0608
chore: cleanup
nfurfaro Feb 14, 2024
d0d40a7
fix: handle interrupt sig by deleting temp files
nfurfaro Feb 14, 2024
7662593
chore: cleanup unused deps
nfurfaro Feb 14, 2024
30420dd
Merge branch 'master' into release/v1.1.1
nfurfaro Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
nfurfaro committed Feb 14, 2024
commit ff7de21d2acb170946e0027afa3ab6d2047560b4
53 changes: 4 additions & 49 deletions src/languages/noir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ compiler_version = ">=0.22.0"
Ok((temp_dir, src_dir))
}

// fn test_mutant_project(&self) -> Box<process::Output> {
// Box::new(
// Command::new(self.test_runner())
// .arg(self.test_command())
// .output()
// .expect("Failed to execute command"),
// )
// }
fn test_mutant_project(&self) -> Box<process::Output> {
let child = Command::new(self.test_runner())
.arg(self.test_command())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
// .stdout(Stdio::piped())
// .stderr(Stdio::piped())
.spawn()
.expect("Failed to execute command");

Expand All @@ -108,51 +100,14 @@ compiler_version = ">=0.22.0"
fn build_mutant_project(&self) -> Box<process::Output> {
let child = Command::new(self.test_runner())
.arg(self.build_command())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
// .stdout(Stdio::piped())
// .stderr(Stdio::piped())
.spawn()
.expect("Failed to execute build command");

// let output_str = String::from_utf8_lossy(&output.stderr);
// if output_str
// .to_lowercase()
// .contains("cannot find a nargo.toml")
// {
// dbg!("No nargo.toml found !!!");
// return Box::new(process::Output {
// status: process::ExitStatus::from_raw(444),
// stdout: vec![],
// stderr: vec![],
// });
// }

Box::new(child.wait_with_output().expect("Failed to wait on child"))
}

// fn build_mutant_project(&self) -> Box<process::Child> {
// let output = Command::new(self.test_runner())
// .arg(self.build_command())
// .stdout(Stdio::piped())
// .stderr(Stdio::piped())
// .spawn()
// .expect("Failed to execute build command");

// // let output_str = String::from_utf8_lossy(&output.stderr);
// // if output_str
// // .to_lowercase()
// // .contains("cannot find a nargo.toml")
// // {
// // dbg!("No nargo.toml found !!!");
// // return Box::new(process::Output {
// // status: process::ExitStatus::from_raw(444),
// // stdout: vec![],
// // stderr: vec![],
// // });
// // }

// Box::new(output)
// }

fn clone_box(&self) -> Box<dyn LanguageConfig + Send + Sync> {
Box::new(self.clone())
}
Expand Down
59 changes: 33 additions & 26 deletions src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::{
use colored::*;
use rayon::prelude::*;


pub fn process_mutants(
mutants: &mut Vec<Mutant>,
args: Args,
Expand Down Expand Up @@ -59,10 +60,14 @@ pub fn process_mutants(
std::process::exit(1);
}

// let build_output = Arc::new(Mutex::new(None));
// let test_output = Arc::new(Mutex::new(None));


mutants.par_iter_mut().for_each(|m| {
let build_status = Mutex::new(None);
let test_status = Mutex::new(None);
let error_flag_for_thread = Arc::clone(&error_printed_flag);
// let build_output = Arc::clone(&build_output);
// let test_output = Arc::clone(&test_output);
// let error_flag_for_thread = Arc::clone(&error_printed_flag);
let temp_src_dir = Arc::new(Mutex::new(temp_src_dir.clone()));

// Check if the source file exists
Expand All @@ -85,37 +90,35 @@ pub fn process_mutants(
eprintln!("Failed to change to the temporary directory: {}", e);
}

// Build the project
let build_output = config.build_mutant_project();
// run_test_suite
let test_output = config.test_mutant_project();
let build_status = build_output.status.code();
let test_status = test_output.status.code();
// dbg!(build_status.unwrap());
// dbg!(test_status.unwrap());
println!("test_output: {:#?}", test_output);



*build_status.lock().unwrap() = build_output.status.code();
// *build_status.lock().unwrap() = Some(1);
*test_status.lock().unwrap() = test_output.status.code();
// *test_status.lock().unwrap() = Some(1);

// dbg!(*build_status.lock().unwrap());
// dbg!(*test_status.lock().unwrap());
// *build_output.lock().unwrap() = Some(config.build_mutant_project());
// *test_output.lock().unwrap() = Some(config.test_mutant_project());
// let build_status = build_output.lock().unwrap().as_ref().unwrap().status.code();
// let test_status = test_output.lock().unwrap().as_ref().unwrap().status.code();

if m.token() == Token::Bang {
print!("mutant: {:#?}", m);
dbg!(*build_status.lock().unwrap());
dbg!(*test_status.lock().unwrap());
print!("Bang mutant: {:#?}", m);
dbg!(build_status.unwrap());
dbg!(test_status.unwrap());
}

if m.token() == Token::NotEqual {
print!("mutant: {:#?}", m);
dbg!(*build_status.lock().unwrap());
dbg!(*test_status.lock().unwrap());
print!("NE mutant: {:#?}", m);
dbg!(build_status.unwrap());
dbg!(test_status.unwrap());
}

match *build_status.lock().unwrap() {
match build_status {
Some(0) => {
println!("Build was successful");
match *test_status.lock().unwrap() {
match test_status {
Some(0) => {
println!("Test suite passed");
m.set_status(MutationStatus::Survived);
Expand Down Expand Up @@ -144,11 +147,11 @@ pub fn process_mutants(
m.set_status(MutationStatus::Killed);
}
None => {
if !error_flag_for_thread.load(Ordering::Relaxed) {
// if !error_flag_for_thread.load(Ordering::Relaxed) {
eprintln!("Build was killed by a signal or crashed");
eprint!("To see what the problem might be, try running the build command manually.i.e: `nargo build`");
error_flag_for_thread.store(true, Ordering::Relaxed);
}
// error_flag_for_thread.store(true, Ordering::Relaxed);
// }
process::exit(1);
}
}
Expand All @@ -163,8 +166,11 @@ pub fn process_mutants(
bar.inc(1);
if let Err(e) = std::env::set_current_dir(&original_dir) {
eprintln!("Failed to change back to the original directory: {}", e);
// write!(stderr, "Failed to change back to the original directory: {}\n", e).unwrap();
}
// print!("final mutant: {:#?}", m);
// let mut stderr = io::stderr();
// println!("Flushing stderr");
// stderr.flush().unwrap();
});

bar.finish_with_message("All mutants processed!");
Expand All @@ -182,6 +188,7 @@ pub fn process_mutants(
score,
);


// Note: cleanup is handled automatically when this function
// returns & the Defer object from the top of the function is dropped.
println!("{}", "Cleaning up temp files".cyan());
Expand Down