Skip to content

Commit a255f22

Browse files
committed
bug fix on analyze without --sqlite and --runid flags
1 parent 0ba90bc commit a255f22

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/analyze.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ pub async fn analyze_folder(
155155
}
156156
num_killed += 1
157157
}
158-
update_command_to_test_mutant(&test_command, &file_path, db_path.clone(), run_id.clone().unwrap())?;
158+
if let Some(db_path) = db_path.clone() {
159+
update_command_to_test_mutant(&test_command, &file_path, db_path, run_id.clone().unwrap_or_default())?;
160+
}
159161
}
160162

161163
// Generate report

src/main.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ async fn main() -> Result<()> {
210210
runid,
211211
} => {
212212

213-
let db_path = match sqlite {
213+
let db_path = match sqlite.clone() {
214214
Some(Some(path)) => {
215215
let mut full_path = PathBuf::from("db");
216216
full_path.push(path);
@@ -220,16 +220,18 @@ async fn main() -> Result<()> {
220220
None => None,
221221
};
222222

223-
if runid.is_none() {
224-
return Err(MutationError::InvalidInput(
225-
"--sqlite requires --runid".to_string(),
226-
));
227-
}
223+
if sqlite.is_some() {
224+
if runid.is_none() {
225+
return Err(MutationError::InvalidInput(
226+
"--sqlite requires --runid".to_string(),
227+
));
228+
}
228229

229-
if runid.is_some() && db_path.is_none() {
230-
return Err(MutationError::InvalidInput(
231-
"--runid requires --sqlite".to_string(),
232-
));
230+
if runid.is_some() && db_path.is_none() {
231+
return Err(MutationError::InvalidInput(
232+
"--runid requires --sqlite".to_string(),
233+
));
234+
}
233235
}
234236

235237
analyze::run_analysis(folder, command, jobs, timeout, survival_threshold, db_path, runid).await?;

src/sqlite.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ where
2222
pub fn update_command_to_test_mutant(
2323
command: &str,
2424
fullpath: &PathBuf,
25-
db_path: Option<PathBuf>,
25+
db_path: PathBuf,
2626
run_id: i64,
2727
) -> Result<(), MutationError>{
2828

29-
let db_path = db_path.ok_or(MutationError::MissingDbPath)?;
3029
let connection = Connection::open(db_path.clone())?;
3130
let fullpath = fullpath.strip_prefix("./").unwrap_or(fullpath);
3231

@@ -563,7 +562,7 @@ mod tests {
563562
println!("count: {:?}", count);
564563
assert_eq!(count, 1, "Must exist exactly 1 mutant");
565564

566-
let result = update_command_to_test_mutant("command", file_path, Some(db_path.to_path_buf()), run_id);
565+
let result = update_command_to_test_mutant("command", file_path, db_path.to_path_buf(), run_id);
567566
assert!(result.is_ok());
568567

569568
let proj_query_row: (i32, String, String) = connection.query_row(

0 commit comments

Comments
 (0)