diff --git a/simulator/generation/property.rs b/simulator/generation/property.rs index b00d36c57..cc02e6233 100644 --- a/simulator/generation/property.rs +++ b/simulator/generation/property.rs @@ -7,7 +7,7 @@ use crate::{ }; use super::{ - frequency, pick, + frequency, pick, pick_index, plan::{Assertion, Interaction, InteractionStats, ResultSet}, ArbitraryFrom, }; @@ -34,6 +34,8 @@ pub(crate) enum Property { InsertSelect { /// The insert query insert: Insert, + /// Selected row index + row_index: usize, /// Additional interactions in the middle of the property queries: Vec, /// The select query @@ -73,6 +75,7 @@ impl Property { match self { Property::InsertSelect { insert, + row_index, queries, select, } => { @@ -83,7 +86,7 @@ impl Property { ); // Pick a random row within the insert values - let row = pick(&insert.values, &mut rand::thread_rng()).clone(); + let row = insert.values[*row_index].clone(); // Assume that the table exists let assumption = Interaction::Assumption(Assertion { @@ -202,7 +205,8 @@ fn property_insert_select( .collect::>(); // Pick a random row to select - let row = pick(&rows, rng).clone(); + let row_index = pick_index(rows.len(), rng).clone(); + let row = rows[row_index].clone(); // Insert the rows let insert_query = Insert { @@ -248,6 +252,7 @@ fn property_insert_select( Property::InsertSelect { insert: insert_query, + row_index, queries, select: select_query, } diff --git a/simulator/main.rs b/simulator/main.rs index db4c7955b..39a6096c5 100644 --- a/simulator/main.rs +++ b/simulator/main.rs @@ -218,7 +218,7 @@ fn main() -> Result<(), String> { last_execution, ); - match (shrunk, &result) { + match (&shrunk, &result) { ( SandboxedResult::Panicked { error: e1, .. }, SandboxedResult::Panicked { error: e2, .. }, @@ -227,7 +227,7 @@ fn main() -> Result<(), String> { SandboxedResult::FoundBug { error: e1, .. }, SandboxedResult::FoundBug { error: e2, .. }, ) => { - if &e1 != e2 { + if e1 != e2 { log::error!( "shrinking failed, the error was not properly reproduced" ); @@ -291,6 +291,7 @@ fn revert_db_and_plan_files(output_dir: &Path) { std::fs::rename(&new_plan_path, &old_plan_path).unwrap(); } +#[derive(Debug)] enum SandboxedResult { Panicked { error: String, diff --git a/simulator/runner/execution.rs b/simulator/runner/execution.rs index 064542805..3ac44e894 100644 --- a/simulator/runner/execution.rs +++ b/simulator/runner/execution.rs @@ -9,7 +9,7 @@ use crate::generation::{ use super::env::{SimConnection, SimulatorEnv}; -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub(crate) struct Execution { pub(crate) connection_index: usize, pub(crate) interaction_index: usize, @@ -30,6 +30,7 @@ impl Execution { } } +#[derive(Debug)] pub(crate) struct ExecutionHistory { pub(crate) history: Vec, }