From e5c18b354e50249a426cb83071fd713be90c83ed Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Tue, 5 Mar 2024 18:04:45 -0800 Subject: [PATCH] fix: gate `sqlcipher` testing behind `cfg` to make development less annoying --- .github/workflows/sqlx.yml | 3 +++ Cargo.toml | 5 ++++- tests/sqlite/sqlcipher.rs | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sqlx.yml b/.github/workflows/sqlx.yml index a7cf763cbe..037dd732fd 100644 --- a/.github/workflows/sqlx.yml +++ b/.github/workflows/sqlx.yml @@ -167,6 +167,9 @@ jobs: matrix: runtime: [async-std, tokio] needs: check + env: + # Enable tests with SQLCipher + RUSTFLAGS: --cfg sqlite_test_sqlcipher steps: - uses: actions/checkout@v2 diff --git a/Cargo.toml b/Cargo.toml index 9a4dfdf5fe..e765d06371 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -177,7 +177,10 @@ hex = "0.4.3" tempfile = "3.9.0" criterion = { version = "0.5.1", features = ["async_tokio"] } -# Needed to test SQLCipher +# If this is an unconditional dev-dependency then Cargo will *always* try to build `libsqlite3-sys`, +# even when SQLite isn't the intended test target, and fail if the build environment is not set up for compiling C code. +[target.'cfg(sqlite_test_sqlcipher)'.dev-dependencies] +# Enable testing with SQLCipher if specifically requested. libsqlite3-sys = { version = "0.27", features = ["bundled-sqlcipher"] } # diff --git a/tests/sqlite/sqlcipher.rs b/tests/sqlite/sqlcipher.rs index 5d228619b5..ddcc2397a0 100644 --- a/tests/sqlite/sqlcipher.rs +++ b/tests/sqlite/sqlcipher.rs @@ -125,6 +125,7 @@ async fn it_fails_if_password_is_incorrect() -> anyhow::Result<()> { Ok(()) } +#[cfg(sqlite_test_sqlcipher)] #[sqlx_macros::test] async fn it_honors_order_of_encryption_pragmas() -> anyhow::Result<()> { let (url, _dir) = new_db_url().await?;