Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chandrakananandi committed May 21, 2024
1 parent 078bf88 commit 9fa92c9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/compile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use itertools::join;
use crate::invoke_command;
use crate::SolAST;
use itertools::join;
use serde_json::Value;
use std::{
error,
Expand Down Expand Up @@ -302,7 +302,6 @@ impl Solc {
flags.push(ALLOWPATHS.into());
let comma_separated = join(allow_paths, ",");
flags.push(comma_separated);

}

if let Some(include_path) = &self.include_path {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn run_mutate(
let outdir = &params.outdir;
outdir_map
.entry(outdir.clone().unwrap_or(default_gambit_output_directory()))
.or_insert(vec![])
.or_default()
.push(params);
}

Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
params.solc_include_path = solc_include_path;
params.solc_base_path = solc_basepath;
params.solc_remappings = solc_remapping;

execute_mutation(vec![*params])?;
}
}
Expand All @@ -480,13 +480,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}


/// Execute mutation
fn execute_mutation(params: Vec<MutateParams>) -> Result<(), Box<dyn std::error::Error>> {
let start = std::time::Instant::now();
let result = run_mutate(params)?;
let t = start.elapsed().as_secs_f64();
let total_num_mutants = result.values().flat_map(|x|x).count();
let total_num_mutants = result.values().flatten().count();
println!(
"Generated {} mutants in {:.2} seconds",
total_num_mutants, t
Expand Down
8 changes: 4 additions & 4 deletions src/mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl Mutation for MutationType {
}
}
MutationType::SwapArgumentsOperatorMutation => {
let non_comm_ops = vec!["-", "/", "%", "**", ">", "<", ">=", "<=", "<<", ">>"];
let non_comm_ops = ["-", "/", "%", "**", ">", "<", ">=", "<=", "<<", ">>"];
if let Some(n) = node.node_type() {
return n == "BinaryOperation"
&& non_comm_ops.contains(
Expand Down Expand Up @@ -282,7 +282,7 @@ impl Mutation for MutationType {
let orig = node.operator().unwrap();
let orig = String::from(orig.trim());

let ops: Vec<&str> = vec!["+", "-", "*", "/", "%", "**"]
let ops: Vec<&str> = ["+", "-", "*", "/", "%", "**"]
.iter()
.filter(|v| !orig.eq(*v))
.copied()
Expand Down Expand Up @@ -333,7 +333,7 @@ impl Mutation for MutationType {
MutationType::IfStatementMutation => {
let cond = node.condition();
let orig = cond.get_text(source.contents());
let bs: Vec<&str> = vec!["true", "false"]
let bs: Vec<&str> = ["true", "false"]
.iter()
.filter(|v| !orig.eq(*v))
.copied()
Expand All @@ -349,7 +349,7 @@ impl Mutation for MutationType {
MutationType::RequireMutation => {
let arg = &node.arguments()[0];
let orig = arg.get_text(source.contents());
let bs: Vec<&str> = vec!["true", "false"]
let bs: Vec<&str> = ["true", "false"]
.iter()
.filter(|v| !orig.eq(*v))
.copied()
Expand Down
8 changes: 6 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ pub fn repair_remapping(remap_str: &str, resolve_against: Option<&str>) -> Strin
This is rare so we are not handling it for now but
this is something to revisit in the future.
*/
let left: Vec<&str> = parts[0].split("/").collect();
let lhs = left[0];
let lhs = if parts[0].ends_with('/') {
parts[0].rsplit_once('/').unwrap().0
} else {
parts[0]
};
let rhs = parts[1];
log::debug!("lhslololol: {lhs} and rhs: {rhs}");
let resolved_path = PathBuf::from(against_path_str)
.join(rhs)
.canonicalize()
Expand Down

0 comments on commit 9fa92c9

Please sign in to comment.