Skip to content

Commit 7271f3c

Browse files
authored
test(rust): add regression tests for windows crates (#3695)
Adds regression tests for the Windows-only issue found in #3693. Changes: - Adds to basic regression tests to the `driver_manager` crate tests which ensure the Windows-only deps are pulled in at build/test time - Changes the Rust workflow (`rust.yml`) to now also run tests with default features, in addition to all features. We were previously only running the tests with all features enabled which was hiding the mistake originally caught in #3693. Now we run tests both ways. - Minor: Adds the Debug trait to the `DriverInfo` struct so the above tests pass
1 parent 16f83f3 commit 7271f3c

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

.github/workflows/rust.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ jobs:
171171
run: |
172172
rustup toolchain install nightly --component clippy
173173
cargo +nightly clippy --workspace --all-targets --all-features --locked -- -Dwarnings -Zcrate-attr='feature(non_exhaustive_omitted_patterns_lint)'
174-
- name: Test
174+
- name: Test (Default Features)
175+
working-directory: rust
176+
# TODO: enable snowflake tests on windows
177+
run: >
178+
cargo test --all-targets --workspace
179+
${{ matrix.minimal-versions && '--exclude adbc_datafusion' || '' }}
180+
${{ runner.os == 'Windows' && '--exclude adbc_snowflake' || '' }}
181+
- name: Test (All Features)
175182
working-directory: rust
176183
# TODO: enable snowflake tests on windows
177184
run: >

rust/driver_manager/src/lib.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct ManagedDriverInner {
160160
_library: Option<libloading::Library>,
161161
}
162162

163-
#[derive(Default)]
163+
#[derive(Debug, Default)]
164164
struct DriverInfo {
165165
lib_path: std::path::PathBuf,
166166
entrypoint: Option<Vec<u8>>,
@@ -2015,6 +2015,30 @@ mod tests {
20152015
}
20162016
}
20172017

2018+
/// Regression test for https://github.com/apache/arrow-adbc/pull/3693
2019+
/// Ensures driver manager tests for Windows pull in Windows crates. This
2020+
/// can be removed/replace when more complete tests are added.
2021+
#[test]
2022+
fn test_user_config_dir() {
2023+
let _ = user_config_dir().unwrap();
2024+
}
2025+
2026+
/// Regression test for https://github.com/apache/arrow-adbc/pull/3693
2027+
/// Ensures driver manager tests for Windows pull in Windows crates. This
2028+
/// can be removed/replace when more complete tests are added.
2029+
#[test]
2030+
#[cfg(target_os = "windows")]
2031+
fn test_load_driver_from_registry() {
2032+
use std::ffi::OsStr;
2033+
let result = load_driver_from_registry(
2034+
windows_registry::CURRENT_USER,
2035+
OsStr::new("nonexistent_test_driver"),
2036+
None,
2037+
);
2038+
assert!(result.is_err());
2039+
assert_eq!(result.unwrap_err().status, Status::NotFound);
2040+
}
2041+
20182042
#[test]
20192043
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
20202044
#[cfg_attr(target_os = "windows", ignore)] // TODO: remove this line after fixing

0 commit comments

Comments
 (0)