From 465f14fcd5d5a3d33380c92066be498a53a1b5e7 Mon Sep 17 00:00:00 2001 From: sonhmai <> Date: Wed, 15 Jan 2025 15:06:44 +0700 Subject: [PATCH] add dev dependencies for testing wal_checkpoint --- Cargo.lock | 19 ----------- cli/Cargo.toml | 7 ++-- cli/tests/test_journal.rs | 67 +++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84845ced1..3c32f1aec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,15 +792,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "float-cmp" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" -dependencies = [ - "num-traits", -] - [[package]] name = "fragile" version = "2.0.0" @@ -1246,7 +1237,6 @@ dependencies = [ "env_logger 0.10.2", "limbo_core", "miette", - "predicates", "rexpect", "rustyline", ] @@ -1548,12 +1538,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "normalize-line-endings" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" - [[package]] name = "num-format" version = "0.4.4" @@ -1829,10 +1813,7 @@ checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "difflib", - "float-cmp", - "normalize-line-endings", "predicates-core", - "regex", ] [[package]] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 84fec7583..3a5ce67ef 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -33,10 +33,7 @@ miette = { version = "7.4.0", features = ["fancy"] } [features] io_uring = ["limbo_core/io_uring"] -[dev-dependencies] +# not testing the cli on windows as rexpect does not support it. +[target.'cfg(not(windows))'.dev-dependencies] assert_cmd = "^2" -predicates = "^3" - -# rexpect does not support windows https://github.com/rust-cli/rexpect/issues/11 -#[target.'cfg(not(windows))'.dev-dependencies] rexpect = "0.6.0" diff --git a/cli/tests/test_journal.rs b/cli/tests/test_journal.rs index ffcc7a163..cea1449c9 100644 --- a/cli/tests/test_journal.rs +++ b/cli/tests/test_journal.rs @@ -1,35 +1,40 @@ -use assert_cmd::cargo::cargo_bin; -use rexpect::error::*; -use rexpect::session::spawn_command; -use std::process; +/// rexpect does not work on Windows. +/// https://github.com/rust-cli/rexpect/issues/11 +#[cfg(not(target_os = "windows"))] +mod tests { + use assert_cmd::cargo::cargo_bin; + use rexpect::error::*; + use rexpect::session::spawn_command; + use std::process; -#[test] -fn test_pragma_journal_mode_wal() -> Result<(), Error> { - let mut child = spawn_command(run_cli(), Some(1000))?; - child.exp_regex("limbo>")?; // skip everything until limbo cursor appear - child.exp_regex(".?")?; - child.send_line("pragma journal_mode;")?; - child.exp_string("wal")?; - child.send_line(".quit")?; - child.exp_eof()?; - Ok(()) -} + #[test] + fn test_pragma_journal_mode_wal() -> Result<(), Error> { + let mut child = spawn_command(run_cli(), Some(1000))?; + child.exp_regex("limbo>")?; // skip everything until limbo cursor appear + child.exp_regex(".?")?; + child.send_line("pragma journal_mode;")?; + child.exp_string("wal")?; + child.send_line(".quit")?; + child.exp_eof()?; + Ok(()) + } -#[ignore = "wal checkpoint not yet implemented"] -#[test] -fn test_pragma_wal_checkpoint() -> Result<(), Error> { - let mut child = spawn_command(run_cli(), Some(1000))?; - child.exp_regex("limbo>")?; // skip everything until limbo cursor appear - child.exp_regex(".?")?; - child.send_line("pragma wal_checkpoint;")?; - child.exp_string("0|0|0")?; - child.send_line(".quit")?; - child.exp_eof()?; - Ok(()) -} + #[ignore = "wal checkpoint not yet implemented"] + #[test] + fn test_pragma_wal_checkpoint() -> Result<(), Error> { + let mut child = spawn_command(run_cli(), Some(1000))?; + child.exp_regex("limbo>")?; // skip everything until limbo cursor appear + child.exp_regex(".?")?; + child.send_line("pragma wal_checkpoint;")?; + child.exp_string("0|0|0")?; + child.send_line(".quit")?; + child.exp_eof()?; + Ok(()) + } -fn run_cli() -> process::Command { - let bin_path = cargo_bin("limbo"); - let mut cmd = process::Command::new(bin_path); - cmd + fn run_cli() -> process::Command { + let bin_path = cargo_bin("limbo"); + let mut cmd = process::Command::new(bin_path); + cmd + } }