15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- use abi_stable:: library:: development_utils:: compute_library_path;
19
18
use abi_stable:: library:: RootModule ;
20
19
use datafusion:: error:: { DataFusionError , Result } ;
21
20
use datafusion:: prelude:: SessionContext ;
@@ -26,6 +25,39 @@ use datafusion_ffi_test::TableProviderModuleRef;
26
25
use std:: path:: Path ;
27
26
use std:: sync:: Arc ;
28
27
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
+
29
61
/// It is important that this test is in the `tests` directory and not in the
30
62
/// library directory so we can verify we are building a dynamic library and
31
63
/// testing it via a different executable.
0 commit comments