cargo fmt and cargo clippy fixes

This commit is contained in:
alpaylan
2025-07-11 02:12:56 -04:00
parent 65fe60ba57
commit b98542d112
13 changed files with 41 additions and 43 deletions

View File

@@ -737,7 +737,10 @@ fn random_create<R: rand::Rng>(rng: &mut R, _env: &SimulatorEnv) -> Interactions
}
fn random_read<R: rand::Rng>(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<R: rand::Rng>(rng: &mut R, env: &SimulatorEnv) -> Interactions {

View File

@@ -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<ResultSet>, _| {
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<ResultSet>, _| {
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<Item = Interactio
)));
let assertion = Interaction::Assertion(Assertion {
message: format!("table {} should contain all of its values", table),
message: format!("table {table} should contain all of its values"),
func: Box::new({
let table = table.clone();
move |stack: &Vec<ResultSet>, 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();

View File

@@ -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() {

View File

@@ -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)]

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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,
};

View File

@@ -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<JoinTable>;
fn shadow(&self, env: &mut SimulatorTables) -> Self::Result {
let tables = &mut env.tables;
let first_table = tables
.iter()
.find(|t| t.name == self.table)

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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<SimulatorCommand>,

View File

@@ -28,7 +28,6 @@ pub(crate) enum SimulationPhase {
Shrink,
}
#[derive(Debug, Clone)]
pub(crate) struct SimulatorTables {
pub(crate) tables: Vec<Table>,