2020-01-26 16:52:39 +00:00
|
|
|
use std::collections::HashMap;
|
2020-01-31 16:05:14 +00:00
|
|
|
use std::path::PathBuf;
|
2020-02-02 07:27:35 +00:00
|
|
|
use verilog_filelist_parser;
|
2020-01-26 16:52:39 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn simple_test() {
|
|
|
|
let mut defines = HashMap::new();
|
2020-01-30 16:14:45 +00:00
|
|
|
defines.insert("a".to_string(), Some("bad".to_string()));
|
|
|
|
defines.insert("e".to_string(), Some("f".to_string()));
|
|
|
|
defines.insert("c".to_string(), Some("d".to_string()));
|
|
|
|
defines.insert("ENV_VAR1".to_string(), Some("var1".to_string()));
|
|
|
|
defines.insert("ENV_VAR2".to_string(), Some("var2".to_string()));
|
2022-05-12 16:03:27 +00:00
|
|
|
defines.insert("ENV_VAR3".to_string(), Some("var3".to_string()));
|
2020-01-30 16:14:45 +00:00
|
|
|
defines.insert("RTL".to_string(), None);
|
2020-01-26 16:52:39 +00:00
|
|
|
|
2020-02-02 07:27:35 +00:00
|
|
|
let filelist_exp = verilog_filelist_parser::Filelist {
|
2020-01-31 16:09:17 +00:00
|
|
|
files: vec![
|
2020-01-31 16:05:14 +00:00
|
|
|
PathBuf::from("testcase/file1.sv"),
|
|
|
|
PathBuf::from("testcase/file2.sv"),
|
|
|
|
PathBuf::from("testcase/file3.sv"),
|
|
|
|
PathBuf::from("testcase/file4.sv"),
|
2020-01-31 16:09:17 +00:00
|
|
|
],
|
|
|
|
incdirs: vec![PathBuf::from("testcase/")],
|
|
|
|
defines: defines,
|
|
|
|
comments_present: true,
|
2020-02-02 06:19:05 +00:00
|
|
|
unknowns_present: false,
|
2020-01-26 16:52:39 +00:00
|
|
|
};
|
2020-01-28 17:07:55 +00:00
|
|
|
|
|
|
|
// Add env vars
|
|
|
|
std::env::set_var("VAR1", "ENV_VAR1");
|
|
|
|
std::env::set_var("VAR2", "ENV_VAR2");
|
2022-05-12 16:03:27 +00:00
|
|
|
std::env::set_var("VAR3", "ENV_VAR3");
|
2020-01-28 17:07:55 +00:00
|
|
|
|
2020-02-02 07:27:35 +00:00
|
|
|
let filelist = verilog_filelist_parser::parse_file("testcase/files.f").expect("Error parsing");
|
2020-01-26 16:52:39 +00:00
|
|
|
assert_eq!(filelist_exp, filelist);
|
2020-01-31 16:09:17 +00:00
|
|
|
}
|