xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/env_locations/main.rs (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan #[test]
test()2*d4726bddSHONG Yifan fn test() {
3*d4726bddSHONG Yifan     // our source file should be readable
4*d4726bddSHONG Yifan     let source_file = std::fs::read_to_string(env!("SOURCE_FILE")).unwrap();
5*d4726bddSHONG Yifan     assert_eq!(source_file, "source\n");
6*d4726bddSHONG Yifan     // our generated data file should be readable at run time and build time
7*d4726bddSHONG Yifan     let generated_data = std::fs::read_to_string(env!("GENERATED_DATA_ROOT")).unwrap();
8*d4726bddSHONG Yifan     let generated_data2 = include_str!(env!("GENERATED_DATA_ABS"));
9*d4726bddSHONG Yifan     assert_eq!(generated_data, generated_data2);
10*d4726bddSHONG Yifan     // and we should be able to read (and thus execute) our tool
11*d4726bddSHONG Yifan     assert!(!std::fs::read(env!("SOME_TOOL")).unwrap().is_empty());
12*d4726bddSHONG Yifan }
13