1 //! ``` 2 //! let contents = include_str!(concat!(env!("OUT_DIR"), "/test_content.txt")); 3 //! assert_eq!("Test content", contents); 4 //! ``` 5 6 #[cfg(test)] 7 mod tests { 8 use std::env; 9 10 #[test] can_find_the_out_dir_file()11 fn can_find_the_out_dir_file() { 12 // The file contents must be included via a macro. 13 let contents = include_str!(concat!(env!("OUT_DIR"), "/test_content.txt")); 14 assert_eq!("Test content", contents); 15 } 16 17 #[test] no_out_dir_at_runtime()18 fn no_out_dir_at_runtime() { 19 // Cargo seems to set this at runtime as well, although the documentation 20 // says it's only available at compile time. 21 assert!(env::var("OUT_DIR").is_err()); 22 } 23 } 24