Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build loadable in test #154

Merged
merged 5 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
with:
# Intentionally omit time feature until we're on time 0.3, at which
# point it should be added to `bundled-full`.
args: '--features "buildtime_bindgen modern-full vtab-full" --avoid-cfg-tarpaulin' # TODO restore to normal (https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320)
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)
version: 0.22.0
env:
DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb
Expand All @@ -90,12 +90,16 @@ jobs:
value: $env:PATH;${{ github.workspace }}/libduckdb
- name: Run cargo-test
if: matrix.os == 'windows-latest'
run: cargo test --features "modern-full vtab-full"
run: cargo test --features "modern-full vtab-full vtab-loadable"
env:
DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb
DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb
- name: Build loadable extension
run: cargo build --example hello-ext --features="vtab-loadable bundled"
run: cargo build --example hello-ext --features="vtab-loadable"
env:
DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb
DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb
LD_LIBRARY_PATH: ${{ github.workspace }}/libduckdb

Windows:
name: Windows build from source
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ all-features = false
[[example]]
name = "hello-ext"
crate-type = ["cdylib"]
required-features = ["vtab-loadable", "bundled"]
required-features = ["vtab-loadable"]
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,16 @@ mod test {
let _ = checked_memory_handle();
}

#[test]
fn test_open_from_raw() {
let con = Connection::open_in_memory();
assert!(con.is_ok());
let inner_con: InnerConnection = con.unwrap().db.into_inner();
unsafe {
assert!(Connection::open_from_raw(inner_con.db).is_ok());
}
}

#[test]
fn test_open_failure() -> Result<()> {
let filename = "no_such_file.db";
Expand Down
13 changes: 13 additions & 0 deletions src/vtab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,17 @@ mod test {
assert_eq!(val, ("Hello duckdb".to_string(),));
Ok(())
}

#[cfg(feature = "vtab-loadable")]
use duckdb_loadable_macros::duckdb_entrypoint;

// this function is never called, but is still type checked
// Exposes a extern C function named "libhello_ext_init" in the compiled dynamic library,
// the "entrypoint" that duckdb will use to load the extension.
#[cfg(feature = "vtab-loadable")]
#[duckdb_entrypoint]
fn libhello_ext_init(conn: Connection) -> Result<(), Box<dyn Error>> {
conn.register_table_function::<HelloVTab>("hello")?;
Ok(())
}
}