Skip to content

Commit 948b879

Browse files
authored
build loadable in test (#154)
* build loadable in test * test open_from_raw * windows don't support bindgen as the generated code type is not easy * remove bundled as required * fix clippy
1 parent 6b86026 commit 948b879

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

.github/workflows/rust.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
with:
6565
# Intentionally omit time feature until we're on time 0.3, at which
6666
# point it should be added to `bundled-full`.
67-
args: '--features "buildtime_bindgen modern-full vtab-full" --avoid-cfg-tarpaulin' # TODO restore to normal (https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320)
67+
args: '--features "buildtime_bindgen modern-full vtab-full vtab-loadable" --avoid-cfg-tarpaulin' # TODO restore to normal (https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320)
6868
version: 0.22.0
6969
env:
7070
DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb
@@ -90,12 +90,16 @@ jobs:
9090
value: $env:PATH;${{ github.workspace }}/libduckdb
9191
- name: Run cargo-test
9292
if: matrix.os == 'windows-latest'
93-
run: cargo test --features "modern-full vtab-full"
93+
run: cargo test --features "modern-full vtab-full vtab-loadable"
9494
env:
9595
DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb
9696
DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb
9797
- name: Build loadable extension
98-
run: cargo build --example hello-ext --features="vtab-loadable bundled"
98+
run: cargo build --example hello-ext --features="vtab-loadable"
99+
env:
100+
DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb
101+
DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb
102+
LD_LIBRARY_PATH: ${{ github.workspace }}/libduckdb
99103

100104
Windows:
101105
name: Windows build from source

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ all-features = false
9696
[[example]]
9797
name = "hello-ext"
9898
crate-type = ["cdylib"]
99-
required-features = ["vtab-loadable", "bundled"]
99+
required-features = ["vtab-loadable"]

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,16 @@ mod test {
668668
let _ = checked_memory_handle();
669669
}
670670

671+
#[test]
672+
fn test_open_from_raw() {
673+
let con = Connection::open_in_memory();
674+
assert!(con.is_ok());
675+
let inner_con: InnerConnection = con.unwrap().db.into_inner();
676+
unsafe {
677+
assert!(Connection::open_from_raw(inner_con.db).is_ok());
678+
}
679+
}
680+
671681
#[test]
672682
fn test_open_failure() -> Result<()> {
673683
let filename = "no_such_file.db";

src/vtab/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,17 @@ mod test {
250250
assert_eq!(val, ("Hello duckdb".to_string(),));
251251
Ok(())
252252
}
253+
254+
#[cfg(feature = "vtab-loadable")]
255+
use duckdb_loadable_macros::duckdb_entrypoint;
256+
257+
// this function is never called, but is still type checked
258+
// Exposes a extern C function named "libhello_ext_init" in the compiled dynamic library,
259+
// the "entrypoint" that duckdb will use to load the extension.
260+
#[cfg(feature = "vtab-loadable")]
261+
#[duckdb_entrypoint]
262+
fn libhello_ext_init(conn: Connection) -> Result<(), Box<dyn Error>> {
263+
conn.register_table_function::<HelloVTab>("hello")?;
264+
Ok(())
265+
}
253266
}

0 commit comments

Comments
 (0)