From 8ddacbb27ca2df00b9ebd22d52fdc54e0e7753cd Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 8 Mar 2020 15:36:56 +0100 Subject: [PATCH 1/2] doctest README.md --- .github/workflows/main.yml | 5 +++-- Cargo.toml | 1 + README.md | 2 +- src/lib.rs | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85c2704..a50c4f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,8 +32,9 @@ jobs: profile: minimal toolchain: stable override: true - - run: cargo build --features bundled - - run: cargo test --features bundled + - run: cargo build --features bundled --workspace --all-targets + - run: cargo test --features bundled --workspace --all-targets + - run: cargo test --features bundled --workspace --doc - name: Static build if: matrix.platform.os == 'windows-latest' shell: cmd diff --git a/Cargo.toml b/Cargo.toml index 7661502..df9b2ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ memchr = "2.2.0" uuid = { version = "0.8", optional = true } [dev-dependencies] +doc-comment = "0.3" tempfile = "3.1.0" lazy_static = "1.0" regex = "1.0" diff --git a/README.md b/README.md index 2ae1a30..9cb89e0 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ You can adjust this behavior in a number of ways: link against that. This source is embedded in the `libsqlite3-sys` crate and is currently SQLite 3.30.1 (as of `rusqlite` 0.21.0 / `libsqlite3-sys` 0.17.0). This is probably the simplest solution to any build problems. You can enable this by adding the following in your `Cargo.toml` file: - ``` + ```toml [dependencies.rusqlite] version = "0.21.0" features = ["bundled"] diff --git a/src/lib.rs b/src/lib.rs index 3b05694..354a8ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -900,6 +900,9 @@ unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option { None } +#[cfg(doctest)] +doc_comment::doctest!("../README.md"); + #[cfg(test)] mod test { use super::*; From 0edc91e8efd5de5e78dd210d62549a7452130a4f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 8 Mar 2020 16:14:04 +0100 Subject: [PATCH 2/2] Disable benches by default --- Cargo.toml | 1 + benches/lib.rs | 38 +++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index df9b2ca..f157c16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ series = ["vtab"] # check for invalid query. extra_check = [] modern_sqlite = ["libsqlite3-sys/bundled_bindings"] +unstable = [] [dependencies] time = "0.1.0" diff --git a/benches/lib.rs b/benches/lib.rs index d1b6d79..ea80463 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -1,20 +1,24 @@ -#![feature(test)] -extern crate test; +#![cfg_attr(feature = "unstable", feature(test))] -use rusqlite::Connection; -use test::Bencher; +#[cfg(feature = "unstable")] +mod bench { + extern crate test; -#[bench] -fn bench_no_cache(b: &mut Bencher) { - let db = Connection::open_in_memory().unwrap(); - db.set_prepared_statement_cache_capacity(0); - let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; - b.iter(|| db.prepare(sql).unwrap()); -} + use rusqlite::Connection; + use test::Bencher; -#[bench] -fn bench_cache(b: &mut Bencher) { - let db = Connection::open_in_memory().unwrap(); - let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; - b.iter(|| db.prepare_cached(sql).unwrap()); -} + #[bench] + fn bench_no_cache(b: &mut Bencher) { + let db = Connection::open_in_memory().unwrap(); + db.set_prepared_statement_cache_capacity(0); + let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; + b.iter(|| db.prepare(sql).unwrap()); + } + + #[bench] + fn bench_cache(b: &mut Bencher) { + let db = Connection::open_in_memory().unwrap(); + let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; + b.iter(|| db.prepare_cached(sql).unwrap()); + } +} \ No newline at end of file