From 6173f975d194fa7d2fc27aa68cde1ac11bda2307 Mon Sep 17 00:00:00 2001 From: Benjamin Winger Date: Mon, 26 Jun 2023 17:19:45 -0400 Subject: [PATCH] Rust packaging improvements: - Make building the shell and python API optional - Switch rust test dependency tempdir to tempfile tempdir is an archived package which was merged into tempfile - Only include necessary files in rust crate - un-bundle rust build - Build kuzu out of source when doing rust build - Use shorter paths in windows CI to work around path length limits --- .github/workflows/ci-workflow.yml | 1 + CMakeLists.txt | 2 + Makefile | 2 +- examples/rust/Cargo.lock | 28 ++++ tools/CMakeLists.txt | 8 +- tools/rust_api/Cargo.toml | 18 ++- tools/rust_api/build.rs | 239 +++++++++++++++++------------ tools/rust_api/include/kuzu_rs.h | 6 +- tools/rust_api/src/connection.rs | 22 +-- tools/rust_api/src/database.rs | 2 +- tools/rust_api/src/lib.rs | 13 +- tools/rust_api/src/query_result.rs | 4 +- tools/rust_api/src/value.rs | 10 +- 13 files changed, 229 insertions(+), 126 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 217cc908ad6..4c41bf5e19e 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -134,6 +134,7 @@ jobs: run: | call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" set OPENSSL_DIR=C:\Program Files\OpenSSL-Win64 + set CARGO_TARGET_DIR=%cd%/rustb make rusttest NUM_THREADS=18 - name: Java test diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f32f79e98b..39a708e27e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,8 @@ if(${ENABLE_UBSAN}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-common -fpermissive") endif() endif() +option(BUILD_PYTHON_API "Build Python API." TRUE) +option(BUILD_SHELL "Build Interactive Shell" TRUE) option(BUILD_TESTS "Build C++ and Python tests." FALSE) option(BUILD_BENCHMARK "Build benchmarks." FALSE) diff --git a/Makefile b/Makefile index d65bfb9106e..740495d14ce 100644 --- a/Makefile +++ b/Makefile @@ -145,7 +145,7 @@ ifeq ($(OS),Windows_NT) cargo test -- --test-threads=1 else cd $(ROOT_DIR)/tools/rust_api && \ - KUZU_TESTING=1 cargo test -- --test-threads=1 + CARGO_BUILD_JOBS=$(NUM_THREADS) KUZU_TESTING=1 cargo test -- --test-threads=1 endif clean-python-api: diff --git a/examples/rust/Cargo.lock b/examples/rust/Cargo.lock index c88f7cd3969..5463082560f 100644 --- a/examples/rust/Cargo.lock +++ b/examples/rust/Cargo.lock @@ -14,6 +14,15 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -68,6 +77,12 @@ dependencies = [ "syn 2.0.18", ] +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + [[package]] name = "hermit-abi" version = "0.2.6" @@ -81,12 +96,14 @@ dependencies = [ name = "kuzu" version = "0.0.4" dependencies = [ + "cmake", "cxx", "cxx-build", "num-derive", "num-traits", "num_cpus", "time", + "which", ] [[package]] @@ -236,6 +253,17 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 24bff91b113..39e39f8d115 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,11 +1,15 @@ -add_subdirectory(shell) +if(${BUILD_SHELL}) + add_subdirectory(shell) +endif() if(${BUILD_JAVA}) add_subdirectory(java_api) endif() if(${BUILD_NODEJS}) add_subdirectory(nodejs_api) endif() -add_subdirectory(python_api) +if(${BUILD_PYTHON_API}) + add_subdirectory(python_api) +endif() if(${BUILD_BENCHMARK}) add_subdirectory(benchmark) endif() diff --git a/tools/rust_api/Cargo.toml b/tools/rust_api/Cargo.toml index 924dd0241e0..761ae1463d1 100644 --- a/tools/rust_api/Cargo.toml +++ b/tools/rust_api/Cargo.toml @@ -4,11 +4,24 @@ version = "0.0.4" description = "An in-process property graph database management system built for query speed and scalability" # Note: 1.63 required for building tests rust-version = "1.51" -readme = "../../README.md" +readme = "kuzu-src/README.md" homepage = "http://kuzudb.com/" repository = "https://github.com/kuzudb/kuzu" license = "MIT" categories = ["database"] +# Only include files required to build to keep crate size small +include = [ + "build.rs", + "/src", + "/include", + "/kuzu-src/src", + "/kuzu-src/third_party", + "/kuzu-src/external/CMakeLists.txt", + "/kuzu-src/external/arrow", + "/kuzu-src/Makefile", + "/kuzu-src/CMakeLists.txt", + "/kuzu-src/tools/CMakeLists.txt", +] edition = "2018" links = "kuzu" @@ -22,10 +35,11 @@ time = "0.3" [build-dependencies] cxx-build = "1.0" num_cpus = "1.0" +cmake = "0.1" [target.'cfg(windows)'.build-dependencies] which = "4" [dev-dependencies] -tempdir = "0.3" +tempfile = "3" anyhow = "1" time = {version="0.3", features=["macros"]} diff --git a/tools/rust_api/build.rs b/tools/rust_api/build.rs index 6e675aa8c06..47f3def598a 100644 --- a/tools/rust_api/build.rs +++ b/tools/rust_api/build.rs @@ -1,5 +1,5 @@ use std::env; -use std::path::Path; +use std::path::{Path, PathBuf}; fn link_mode() -> &'static str { if env::var("KUZU_SHARED").is_ok() { @@ -9,83 +9,50 @@ fn link_mode() -> &'static str { } } -fn main() { - // There is a kuzu-src symlink pointing to the root of the repo since Cargo - // only looks at the files within the rust project when packaging crates. - // Using a symlink the library can both be built in-source and from a crate. - let kuzu_root = { - let root = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("kuzu-src"); - if root.is_dir() { - root +fn find_openssl_windows() { + // Find openssl library relative to the path of the openssl executable + // Or fall back to OPENSSL_DIR + #[cfg(windows)] + { + let openssl_dir = if let Ok(mut path) = which::which("openssl") { + path.pop(); + path.pop(); + path + } else if let Ok(path) = env::var("OPENSSL_CONF") { + Path::new(&path) + .parent() + .unwrap() + .parent() + .unwrap() + .to_path_buf() + } else if let Ok(path) = env::var("OPENSSL_DIR") { + Path::new(&path).to_path_buf() } else { - // If the path is not directory, this is probably an in-source build on windows where the - // symlink is unreadable. - Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("../..") - } - }; - // Windows fails to link on windows unless CFLAGS and CXXFLAGS are overridden - // If they are, assume the user knows what they are doing. Otherwise just link against the - // release version of kuzu even in debug mode. - let target = if cfg!(windows) && std::env::var("CXXFLAGS").is_err() { + panic!( + "OPENSSL_DIR must be set if the openssl library cannot be found \ + using the path of the openssl executable" + ) + }; + println!( + "cargo:rustc-link-search=native={}/lib", + openssl_dir.display() + ); + } +} + +fn get_target() -> String { + if cfg!(windows) && std::env::var("CXXFLAGS").is_err() { "release".to_string() } else { env::var("PROFILE").unwrap() - }; - let kuzu_cmake_root = kuzu_root.join(format!("build/{target}")); - let mut command = std::process::Command::new("make"); - let threads = env::var("NUM_THREADS") - .map(|x| x.parse::()) - .unwrap_or_else(|_| Ok(num_cpus::get())) - .unwrap(); - command - .args(&[&target, &format!("NUM_THREADS={}", threads)]) - .current_dir(&kuzu_root); - let make_status = command.status().unwrap_or_else(|_| { - panic!( - "Running make {} on {}/Makefile failed!", - &target, - &kuzu_root.display() - ) - }); - assert!(make_status.success()); - - let kuzu_lib_path = kuzu_cmake_root.join("src"); - - println!("cargo:rustc-link-search=native={}", kuzu_lib_path.display()); - - let include_paths = vec![ - Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("include"), - kuzu_root.join("src/include"), - kuzu_root.join("third_party/nlohmann_json"), - kuzu_root.join("third_party/spdlog"), - ]; - for dir in ["utf8proc", "antlr4_cypher", "antlr4_runtime", "re2"] { - let lib_path = kuzu_cmake_root - .join(format!("third_party/{dir}")) - .canonicalize() - .unwrap_or_else(|_| { - panic!( - "Could not find {}/third_party/{dir}", - kuzu_cmake_root.display() - ) - }); - println!("cargo:rustc-link-search=native={}", lib_path.display()); } +} - let arrow_install = kuzu_root.join("external/build/arrow/install"); - println!( - "cargo:rustc-link-search=native={}", - arrow_install.join("lib").display() - ); - println!( - "cargo:rustc-link-search=native={}", - arrow_install.join("lib64").display() - ); - +fn link_libraries() { println!("cargo:rustc-link-lib={}=kuzu", link_mode()); if link_mode() == "static" { if cfg!(windows) { - if target == "debug" { + if get_target() == "debug" { println!("cargo:rustc-link-lib=dylib=msvcrtd"); } else { println!("cargo:rustc-link-lib=dylib=msvcrt"); @@ -102,34 +69,7 @@ fn main() { // Only seems to be necessary when building tests. if env::var("KUZU_TESTING").is_ok() { if cfg!(windows) { - // Find openssl library relative to the path of the openssl executable - // Or fall back to OPENSSL_DIR - #[cfg(windows)] - { - let openssl_dir = if let Ok(mut path) = which::which("openssl") { - path.pop(); - path.pop(); - path - } else if let Ok(path) = env::var("OPENSSL_CONF") { - Path::new(&path) - .parent() - .unwrap() - .parent() - .unwrap() - .to_path_buf() - } else if let Ok(path) = env::var("OPENSSL_DIR") { - Path::new(&path).to_path_buf() - } else { - panic!( - "OPENSSL_DIR must be set if the openssl library cannot be found \ - using the path of the openssl executable" - ) - }; - println!( - "cargo:rustc-link-search=native={}/lib", - openssl_dir.display() - ); - } + find_openssl_windows(); println!("cargo:rustc-link-lib=dylib=libssl"); println!("cargo:rustc-link-lib=dylib=libcrypto"); } else { @@ -151,14 +91,113 @@ fn main() { println!("cargo:rustc-link-lib=static=antlr4_runtime"); println!("cargo:rustc-link-lib=static=re2"); } +} + +fn build_bundled_cmake() -> Result, Box> { + if let Ok(jobs) = std::env::var("NUM_THREADS") { + std::env::set_var("NUM_JOBS", jobs); + } + let kuzu_root = { + let root = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("kuzu-src"); + if root.is_symlink() || root.is_dir() { + root + } else { + // If the path is not directory, this is probably an in-source build on windows where the + // symlink is unreadable. + Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("../..") + } + }; + let mut arrow_build = cmake::Config::new(kuzu_root.join("external")); + arrow_build + .no_build_target(true) + // Needs separate out directory so they don't clobber each other + .out_dir(Path::new(&env::var("OUT_DIR").unwrap()).join("arrow")); + + if cfg!(windows) { + arrow_build.generator("Ninja"); + arrow_build.cxxflag("/EHsc"); + } + let arrow_build_dir = arrow_build.build(); + + let arrow_install = arrow_build_dir.join("build/arrow/install"); + println!( + "cargo:rustc-link-search=native={}", + arrow_install.join("lib").display() + ); + println!( + "cargo:rustc-link-search=native={}", + arrow_install.join("lib64").display() + ); + + let mut build = cmake::Config::new(&kuzu_root); + build + .no_build_target(true) + .define("BUILD_SHELL", "OFF") + .define("BUILD_PYTHON_API", "OFF") + .define("ARROW_INSTALL", &arrow_install); + if cfg!(windows) { + build.generator("Ninja"); + build.cxxflag("/EHsc"); + } + let build_dir = build.build(); + + let kuzu_lib_path = build_dir.join("build").join("src"); + println!("cargo:rustc-link-search=native={}", kuzu_lib_path.display()); + + for dir in ["utf8proc", "antlr4_cypher", "antlr4_runtime", "re2"] { + let lib_path = build_dir + .join("build") + .join("third_party") + .join(dir) + .canonicalize() + .unwrap_or_else(|_| { + panic!( + "Could not find {}/build/third_party/{}", + build_dir.display(), + dir + ) + }); + println!("cargo:rustc-link-search=native={}", lib_path.display()); + } + + Ok(vec![ + kuzu_root.join("src/include"), + kuzu_root.join("third_party/nlohmann_json"), + kuzu_root.join("third_party/spdlog"), + arrow_install.join("include"), + ]) +} + +fn main() { + let mut build = cxx_build::bridge("src/ffi.rs"); + build.file("src/kuzu_rs.cpp"); + + let mut include_paths = + vec![Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("include")]; + + if let (Ok(kuzu_lib_dir), Ok(kuzu_include)) = + (env::var("KUZU_LIBRARY_DIR"), env::var("KUZU_INCLUDE_DIR")) + { + println!("cargo:rustc-link-search=native={}", kuzu_lib_dir); + if cfg!(windows) && link_mode() == "dylib" { + println!("cargo:rustc-link-lib=dylib=kuzu_shared"); + } else { + println!("cargo:rustc-link-lib={}=kuzu", link_mode()); + } + include_paths.push(Path::new(&kuzu_include).to_path_buf()); + } else { + include_paths.extend(build_bundled_cmake().expect("Bundled build failed!")); + build.define("KUZU_BUNDLED", None); + } + build.includes(include_paths); + + link_libraries(); + println!("cargo:rerun-if-env-changed=KUZU_SHARED"); println!("cargo:rerun-if-changed=include/kuzu_rs.h"); println!("cargo:rerun-if-changed=include/kuzu_rs.cpp"); - let mut build = cxx_build::bridge("src/ffi.rs"); - build.file("src/kuzu_rs.cpp").includes(include_paths); - if cfg!(windows) { build.flag("/std:c++20"); } else { diff --git a/tools/rust_api/include/kuzu_rs.h b/tools/rust_api/include/kuzu_rs.h index 3185b064da8..32d6f81450f 100644 --- a/tools/rust_api/include/kuzu_rs.h +++ b/tools/rust_api/include/kuzu_rs.h @@ -1,8 +1,12 @@ #pragma once #include -#include "main/kuzu.h" #include "rust/cxx.h" +#ifdef KUZU_BUNDLED +#include "main/kuzu.h" +#else +#include +#endif namespace kuzu_rs { diff --git a/tools/rust_api/src/connection.rs b/tools/rust_api/src/connection.rs index 735f4d96e7a..e8d580bd3fb 100644 --- a/tools/rust_api/src/connection.rs +++ b/tools/rust_api/src/connection.rs @@ -32,7 +32,7 @@ pub struct PreparedStatement { /// ``` /// # use kuzu::{Connection, Database, Value, Error}; /// # fn main() -> anyhow::Result<()> { -/// # let temp_dir = tempdir::TempDir::new("example3")?; +/// # let temp_dir = tempfile::tempdir()?; /// # let db = Database::new(temp_dir.path(), 0)?; /// let conn = Connection::new(&db)?; /// conn.query("CREATE NODE TABLE Person(name STRING, age INT32, PRIMARY KEY(name));")?; @@ -82,7 +82,7 @@ pub struct PreparedStatement { /// use kuzu::{Database, Connection}; /// # use anyhow::Error; /// # fn main() -> Result<(), Error> { -/// # let temp_dir = tempdir::TempDir::new("example")?; +/// # let temp_dir = tempfile::tempdir()?; /// # let path = temp_dir.path(); /// let db = Database::new(path, 0)?; /// let conn = Connection::new(&db)?; @@ -105,7 +105,7 @@ pub struct PreparedStatement { /// use kuzu::{Database, Connection}; /// # use anyhow::Error; /// # fn main() -> Result<(), Error> { -/// # let temp_dir = tempdir::TempDir::new("example")?; +/// # let temp_dir = tempfile::tempdir()?; /// # let path = temp_dir.path(); /// let db = Database::new(path, 0)?; /// let conn = Connection::new(&db)?; @@ -300,7 +300,7 @@ mod tests { #[test] fn test_connection_threads() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example1")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let mut conn = Connection::new(&db)?; conn.set_max_num_threads_for_exec(5); @@ -311,7 +311,7 @@ mod tests { #[test] fn test_invalid_query() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example2")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query("CREATE NODE TABLE Person(name STRING, age INT64, PRIMARY KEY(name));")?; @@ -334,7 +334,7 @@ Invalid input : expected rule oC_SingleQuery (line: 1, o #[test] fn test_query_result() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example3")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query("CREATE NODE TABLE Person(name STRING, age INT16, PRIMARY KEY(name));")?; @@ -351,7 +351,7 @@ Invalid input : expected rule oC_SingleQuery (line: 1, o #[test] fn test_params() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example3")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query("CREATE NODE TABLE Person(name STRING, age INT16, PRIMARY KEY(name));")?; @@ -369,7 +369,7 @@ Invalid input : expected rule oC_SingleQuery (line: 1, o #[test] fn test_params_invalid_type() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example3")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query("CREATE NODE TABLE Person(name STRING, age INT16, PRIMARY KEY(name));")?; @@ -394,7 +394,7 @@ Invalid input : expected rule oC_SingleQuery (line: 1, o #[test] fn test_multithreaded_single_conn() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example3")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; @@ -426,7 +426,7 @@ Invalid input : expected rule oC_SingleQuery (line: 1, o #[test] fn test_multithreaded_multiple_conn() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example3")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; @@ -460,7 +460,7 @@ Invalid input : expected rule oC_SingleQuery (line: 1, o #[test] fn test_table_names() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example3")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query("CREATE NODE TABLE Person(name STRING, age INT16, PRIMARY KEY(name));")?; diff --git a/tools/rust_api/src/database.rs b/tools/rust_api/src/database.rs index f533ea88174..47b0c009b0b 100644 --- a/tools/rust_api/src/database.rs +++ b/tools/rust_api/src/database.rs @@ -67,7 +67,7 @@ mod tests { #[test] fn create_database() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let mut db = Database::new(temp_dir.path(), 0)?; db.set_logging_level(LoggingLevel::Debug); db.set_logging_level(LoggingLevel::Info); diff --git a/tools/rust_api/src/lib.rs b/tools/rust_api/src/lib.rs index a2304aca563..5200fdf6025 100644 --- a/tools/rust_api/src/lib.rs +++ b/tools/rust_api/src/lib.rs @@ -6,7 +6,7 @@ //! # use anyhow::Error; //! //! # fn main() -> Result<(), Error> { -//! # let temp_dir = tempdir::TempDir::new("example")?; +//! # let temp_dir = tempfile::tempdir()?; //! # let path = temp_dir.path(); //! let db = Database::new(path, 0)?; //! let conn = Connection::new(&db)?; @@ -26,6 +26,17 @@ //! Generally, use of of this API is safe, however creating multiple databases in the same //! scope is not safe. //! If you need to access multiple databases you will need to do so in separate processes. +//! +//! ## Building +//! +//! By default, the kuzu C++ library will be compiled from source and statically linked. +//! +//! If you want to instead link against a pre-built version of the library, the following environment +//! variables can be used to configure the build process: +//! +//! - `KUZU_SHARED`: If set, link dynamically instead of statically +//! - `KUZU_INCLUDE_DIR`: Directory of kuzu's headers +//! - `KUZU_LIBRARY_DIR`: Directory containing kuzu's pre-built libraries. mod connection; mod database; diff --git a/tools/rust_api/src/query_result.rs b/tools/rust_api/src/query_result.rs index 9ee92dc27f4..61cde7daf94 100644 --- a/tools/rust_api/src/query_result.rs +++ b/tools/rust_api/src/query_result.rs @@ -175,7 +175,7 @@ mod tests { use crate::query_result::CSVOptions; #[test] fn test_query_result_metadata() -> anyhow::Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let connection = Connection::new(&db)?; @@ -201,7 +201,7 @@ mod tests { #[test] fn test_csv() -> anyhow::Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let path = temp_dir.path(); let db = Database::new(path, 0)?; let conn = Connection::new(&db)?; diff --git a/tools/rust_api/src/value.rs b/tools/rust_api/src/value.rs index ad0bbff2557..3eccf4dbcd5 100644 --- a/tools/rust_api/src/value.rs +++ b/tools/rust_api/src/value.rs @@ -657,7 +657,7 @@ mod tests { #[test] /// Tests that passing the values through the database returns what we put in fn $name() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query(&format!( @@ -775,7 +775,7 @@ mod tests { #[test] /// Tests that the list value is correctly constructed fn test_var_list_get() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; for result in conn.query("RETURN [\"Alice\", \"Bob\"] AS l;")? { @@ -792,7 +792,7 @@ mod tests { #[test] /// Test that the timestamp round-trips through kuzu's internal timestamp fn test_timestamp() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query( @@ -839,7 +839,7 @@ mod tests { #[test] fn test_node() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; conn.query("CREATE NODE TABLE Person(name STRING, age INT64, PRIMARY KEY(name));")?; @@ -866,7 +866,7 @@ mod tests { #[test] /// Test that null values are read correctly by the API fn test_null() -> Result<()> { - let temp_dir = tempdir::TempDir::new("example")?; + let temp_dir = tempfile::tempdir()?; let db = Database::new(temp_dir.path(), 0)?; let conn = Connection::new(&db)?; let result = conn.query("RETURN null")?.next();