• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[test]
run()2 fn run() {
3     let path = env!("CARGO_BIN_EXE_hello-world");
4     let output = std::process::Command::new(path)
5         .output()
6         .expect("Failed to run process");
7     assert_eq!(&b"Hello world\n"[..], output.stdout.as_slice());
8 
9     // Test the `env` attribute of `rust_test` at run time
10     assert_eq!(
11         std::env::var("FERRIS_SAYS").unwrap(),
12         "Hello fellow Rustaceans!"
13     );
14 
15     // Test the behavior of `rootpath` and that a binary can be found relative to current_dir
16     let hello_world_bin =
17         std::path::PathBuf::from(std::env::var_os("HELLO_WORLD_BIN_ROOTPATH").unwrap());
18 
19     assert_eq!(
20         hello_world_bin.as_path(),
21         std::path::Path::new(if std::env::consts::OS == "windows" {
22             "test/test_env/hello-world.exe"
23         } else {
24             "test/test_env/hello-world"
25         })
26     );
27     assert!(!hello_world_bin.is_absolute());
28     assert!(hello_world_bin.exists());
29 }
30