diff --git a/simulator/generation/plan.rs b/simulator/generation/plan.rs index 2e608bc70..65c013024 100644 --- a/simulator/generation/plan.rs +++ b/simulator/generation/plan.rs @@ -737,7 +737,10 @@ fn random_create(rng: &mut R, _env: &SimulatorEnv) -> Interactions } fn random_read(rng: &mut R, env: &SimulatorEnv) -> Interactions { - Interactions::Query(Query::Select(Select::arbitrary_from(rng, &env.tables.tables))) + Interactions::Query(Query::Select(Select::arbitrary_from( + rng, + &env.tables.tables, + ))) } fn random_write(rng: &mut R, env: &SimulatorEnv) -> Interactions { diff --git a/simulator/generation/property.rs b/simulator/generation/property.rs index 78e999280..ff8582123 100644 --- a/simulator/generation/property.rs +++ b/simulator/generation/property.rs @@ -3,16 +3,22 @@ use turso_core::LimboError; use turso_sqlite3_parser::ast::{self}; use crate::{ - generation::Shadow as _, model::{ + generation::Shadow as _, + model::{ query::{ - predicate::Predicate, select::{ + predicate::Predicate, + select::{ CompoundOperator, CompoundSelect, Distinctness, ResultColumn, SelectBody, SelectInner, - }, transaction::{Begin, Commit, Rollback}, update::Update, Create, Delete, Drop, Insert, Query, Select + }, + transaction::{Begin, Commit, Rollback}, + update::Update, + Create, Delete, Drop, Insert, Query, Select, }, table::SimValue, FAULT_ERROR_MSG, - }, runner::env::SimulatorEnv + }, + runner::env::SimulatorEnv, }; use super::{ @@ -367,7 +373,7 @@ impl Property { ))); let assertion = Interaction::Assertion(Assertion { - message: format!("`{}` should return no values for table `{}`", select, table,), + message: format!("`{select}` should return no values for table `{table}`",), func: Box::new(move |stack: &Vec, _| { let rows = stack.last().unwrap(); match rows { @@ -405,8 +411,7 @@ impl Property { let assertion = Interaction::Assertion(Assertion { message: format!( - "select query should result in an error for table '{}'", - table + "select query should result in an error for table '{table}'" ), func: Box::new(move |stack: &Vec, _| { let last = stack.last().unwrap(); @@ -522,7 +527,7 @@ impl Property { Ok(true) } Err(err) => { - let msg = format!("{}", err); + let msg = format!("{err}"); if msg.contains(FAULT_ERROR_MSG) { Ok(true) } else { @@ -717,14 +722,13 @@ fn assert_all_table_values(tables: &[String]) -> impl Iterator, env: &mut SimulatorEnv| { let table = env.tables.iter().find(|t| t.name == table).ok_or_else(|| { LimboError::InternalError(format!( - "table {} should exist in simulator env", - table + "table {table} should exist in simulator env" )) })?; let last = stack.last().unwrap(); diff --git a/simulator/generation/query.rs b/simulator/generation/query.rs index 1f0f2578e..cfbaade44 100644 --- a/simulator/generation/query.rs +++ b/simulator/generation/query.rs @@ -186,7 +186,7 @@ impl ArbitraryFrom<&SimulatorEnv> for Insert { backtrack( vec![ (1, Box::new(gen_values)), - (1, Box::new(|rng| gen_select(rng))), + (1, Box::new(gen_select)), ], rng, ) @@ -266,15 +266,15 @@ impl ArbitraryFrom<&SimulatorEnv> for Update { #[cfg(test)] mod query_generation_tests { - use rand::RngCore; + use turso_core::Value; use turso_sqlite3_parser::to_sql_string::ToSqlString; use super::*; - use crate::model::query::predicate::Predicate; + use crate::model::query::EmptyContext; use crate::model::table::{Column, ColumnType}; - use crate::SimulatorEnv; + #[test] fn test_select_query_generation() { diff --git a/simulator/model/query/create.rs b/simulator/model/query/create.rs index fe8604d2c..ab0cd9789 100644 --- a/simulator/model/query/create.rs +++ b/simulator/model/query/create.rs @@ -4,7 +4,8 @@ use serde::{Deserialize, Serialize}; use crate::{ generation::Shadow, - model::table::{SimValue, Table}, runner::env::SimulatorTables, + model::table::{SimValue, Table}, + runner::env::SimulatorTables, }; #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/simulator/model/query/delete.rs b/simulator/model/query/delete.rs index 70e4c890b..265cdfe96 100644 --- a/simulator/model/query/delete.rs +++ b/simulator/model/query/delete.rs @@ -2,10 +2,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; -use crate::{ - generation::Shadow, - model::table::SimValue, runner::env::SimulatorTables, -}; +use crate::{generation::Shadow, model::table::SimValue, runner::env::SimulatorTables}; use super::predicate::Predicate; diff --git a/simulator/model/query/drop.rs b/simulator/model/query/drop.rs index d5979a9f4..2b4379ff9 100644 --- a/simulator/model/query/drop.rs +++ b/simulator/model/query/drop.rs @@ -2,10 +2,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; -use crate::{ - generation::Shadow, - model::table::SimValue, runner::env::SimulatorTables, -}; +use crate::{generation::Shadow, model::table::SimValue, runner::env::SimulatorTables}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub(crate) struct Drop { diff --git a/simulator/model/query/insert.rs b/simulator/model/query/insert.rs index ef7f68bb4..3dc8659df 100644 --- a/simulator/model/query/insert.rs +++ b/simulator/model/query/insert.rs @@ -2,10 +2,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; -use crate::{ - generation::Shadow, - model::table::SimValue, runner::env::SimulatorTables, -}; +use crate::{generation::Shadow, model::table::SimValue, runner::env::SimulatorTables}; use super::select::Select; diff --git a/simulator/model/query/mod.rs b/simulator/model/query/mod.rs index ee90a26a1..9950a93f1 100644 --- a/simulator/model/query/mod.rs +++ b/simulator/model/query/mod.rs @@ -12,7 +12,10 @@ use update::Update; use crate::{ generation::Shadow, - model::{query::transaction::{Begin, Commit, Rollback}, table::SimValue}, + model::{ + query::transaction::{Begin, Commit, Rollback}, + table::SimValue, + }, runner::env::SimulatorTables, }; diff --git a/simulator/model/query/select.rs b/simulator/model/query/select.rs index 18939370b..5b0da6cd3 100644 --- a/simulator/model/query/select.rs +++ b/simulator/model/query/select.rs @@ -11,7 +11,8 @@ use crate::{ model::{ query::EmptyContext, table::{SimValue, Table}, - }, runner::env::SimulatorTables, + }, + runner::env::SimulatorTables, }; use super::predicate::Predicate; @@ -255,7 +256,7 @@ impl Shadow for FromClause { type Result = anyhow::Result; fn shadow(&self, env: &mut SimulatorTables) -> Self::Result { let tables = &mut env.tables; - + let first_table = tables .iter() .find(|t| t.name == self.table) diff --git a/simulator/model/query/transaction.rs b/simulator/model/query/transaction.rs index 2d47280af..a73fb076e 100644 --- a/simulator/model/query/transaction.rs +++ b/simulator/model/query/transaction.rs @@ -2,11 +2,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; -use crate::{ - generation::Shadow, - model::table::SimValue, - runner::env::SimulatorTables, -}; +use crate::{generation::Shadow, model::table::SimValue, runner::env::SimulatorTables}; #[derive(Debug, Clone, Serialize, Deserialize)] pub(crate) struct Begin { diff --git a/simulator/model/query/update.rs b/simulator/model/query/update.rs index 09fce2370..175ef36f2 100644 --- a/simulator/model/query/update.rs +++ b/simulator/model/query/update.rs @@ -2,10 +2,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; -use crate::{ - generation::Shadow, - model::table::SimValue, runner::env::SimulatorTables, -}; +use crate::{generation::Shadow, model::table::SimValue, runner::env::SimulatorTables}; use super::predicate::Predicate; diff --git a/simulator/runner/cli.rs b/simulator/runner/cli.rs index 8f7e1efaf..534b7e5c1 100644 --- a/simulator/runner/cli.rs +++ b/simulator/runner/cli.rs @@ -44,7 +44,10 @@ pub struct SimulatorCLI { pub watch: bool, #[clap(long, help = "run differential testing between sqlite and Limbo")] pub differential: bool, - #[clap(long, help = "enable brute force shrink (warning: it might take a long time)")] + #[clap( + long, + help = "enable brute force shrink (warning: it might take a long time)" + )] pub enable_brute_force_shrinking: bool, #[clap(subcommand)] pub subcommand: Option, diff --git a/simulator/runner/env.rs b/simulator/runner/env.rs index 4629d3ffb..40f057f4b 100644 --- a/simulator/runner/env.rs +++ b/simulator/runner/env.rs @@ -28,7 +28,6 @@ pub(crate) enum SimulationPhase { Shrink, } - #[derive(Debug, Clone)] pub(crate) struct SimulatorTables { pub(crate) tables: Vec,