Skip to content

Commit e5c18b3

Browse files
committed
fix: gate sqlcipher testing behind cfg to make development less annoying
1 parent dfb6014 commit e5c18b3

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.github/workflows/sqlx.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ jobs:
167167
matrix:
168168
runtime: [async-std, tokio]
169169
needs: check
170+
env:
171+
# Enable tests with SQLCipher
172+
RUSTFLAGS: --cfg sqlite_test_sqlcipher
170173
steps:
171174
- uses: actions/checkout@v2
172175

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ hex = "0.4.3"
177177
tempfile = "3.9.0"
178178
criterion = { version = "0.5.1", features = ["async_tokio"] }
179179

180-
# Needed to test SQLCipher
180+
# If this is an unconditional dev-dependency then Cargo will *always* try to build `libsqlite3-sys`,
181+
# even when SQLite isn't the intended test target, and fail if the build environment is not set up for compiling C code.
182+
[target.'cfg(sqlite_test_sqlcipher)'.dev-dependencies]
183+
# Enable testing with SQLCipher if specifically requested.
181184
libsqlite3-sys = { version = "0.27", features = ["bundled-sqlcipher"] }
182185

183186
#

tests/sqlite/sqlcipher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async fn it_fails_if_password_is_incorrect() -> anyhow::Result<()> {
125125
Ok(())
126126
}
127127

128+
#[cfg(sqlite_test_sqlcipher)]
128129
#[sqlx_macros::test]
129130
async fn it_honors_order_of_encryption_pragmas() -> anyhow::Result<()> {
130131
let (url, _dir) = new_db_url().await?;

0 commit comments

Comments
 (0)