Skip to content

Commit ef5e8b6

Browse files
committed
Fix unit test to find deps in ci profile
1 parent 883ec48 commit ef5e8b6

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

datafusion/ffitest/tests/table_provider.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use abi_stable::library::development_utils::compute_library_path;
1918
use abi_stable::library::RootModule;
2019
use datafusion::error::{DataFusionError, Result};
2120
use datafusion::prelude::SessionContext;
@@ -26,6 +25,39 @@ use datafusion_ffi_test::TableProviderModuleRef;
2625
use std::path::Path;
2726
use std::sync::Arc;
2827

28+
/// Compute the path to the library. It would be preferable to simply use
29+
/// abi_stable::library::development_utils::compute_library_path however
30+
/// our current CI pipeline has a `ci` profile that we need to use to
31+
/// find the library.
32+
pub fn compute_library_path<M: RootModule>(
33+
target_path: &Path,
34+
) -> std::io::Result<std::path::PathBuf> {
35+
let debug_dir = target_path.join("debug");
36+
let release_dir = target_path.join("release");
37+
let ci_dir = target_path.join("ci");
38+
39+
let debug_path = M::get_library_path(&debug_dir.join("deps"));
40+
let release_path = M::get_library_path(&release_dir.join("deps"));
41+
let ci_path = M::get_library_path(&ci_dir.join("deps"));
42+
43+
let all_paths = vec![
44+
(debug_dir.clone(), debug_path),
45+
(release_dir, release_path),
46+
(ci_dir, ci_path),
47+
];
48+
49+
let best_path = all_paths
50+
.into_iter()
51+
.filter(|(_, path)| path.exists())
52+
.filter_map(|(dir, path)| path.metadata().map(|m| (dir, m)).ok())
53+
.filter_map(|(dir, meta)| meta.modified().map(|m| (dir, m)).ok())
54+
.max_by_key(|(_, date)| *date)
55+
.map(|(dir, _)| dir)
56+
.unwrap_or(debug_dir);
57+
58+
Ok(best_path)
59+
}
60+
2961
/// It is important that this test is in the `tests` directory and not in the
3062
/// library directory so we can verify we are building a dynamic library and
3163
/// testing it via a different executable.

0 commit comments

Comments
 (0)