Integration tests and use

#1

Following https://doc.rust-lang.org/book/ch11-03-test-organization.html . My library is called dvbv5-sys, so in my tests/sanity_check.rs file I have a:

use dvbv5_sys

However this is reported as an error by cargo:

|> cargo test
   Compiling libc v0.2.46                                                                                                                                                                                                                                                                      
   Compiling dvbv5-sys v1.0.0-snapshot (/home/users/russel/Repositories/Git/Masters/Public/Rust_Libdvbv5_Sys)                                                                                                                                                                                  
warning: #[derive] can't be used on a #[repr(packed)] struct that does not derive Copy (error E0133)                                                                                                                                                                                           
    --> src/ffi.rs:6797:10                                                                                                                                                                                                                                                                     
     |                                                                                                                                                                                                                                                                                         
6797 | #[derive(Debug)]                                                                                                                                                                                                                                                                        
     |          ^^^^^                                                                                                                                                                                                                                                                          
     |                                                                                                                                                                                                                                                                                         
     = note: #[warn(safe_packed_borrows)] on by default                                                                                                                                                                                                                                        
     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!                                                                                                                                                         
     = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                               
error[E0432]: unresolved import `dvbv5_sys`                                                                                                                                                                                                                                                    
  --> tests/sanity_check.rs:20:5                                                                                                                                                                                                                                                               
   |                                                                                                                                                                                                                                                                                           
20 | use dvbv5_sys;                                                                                                                                                                                                                                                                            
   |     ^^^^^^^^^ no `dvbv5_sys` in the root                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

As you can possibly imagine, I am a bit confused.

0 Likes

#2

It must be put in extern crate, not in use, just as when importing it into user code.

1 Like

#3

So the use adder; on https://doc.rust-lang.org/book/ch11-03-test-organization.html is actually wrong and it should be extern crate adder;?

I change from using use to using extern crate in my project and it works fine. Thank you @Cerberuser for putting me on the right track, much appreciated. And stress lowering. :slight_smile:

0 Likes