use std::fs;
use std::process::{Command, Stdio};
const IOC_FILE: &str = "tests/stm32f042.ioc";
#[test]
fn integration_test() {
fs::create_dir_all("../test_project/").expect("Failed to create test_project directory");
fs::copy(IOC_FILE, "../test_project/test_project.ioc").expect("Failed to copy ioc file");
Command::new("cargo")
.arg("run")
.arg("--color=always")
.arg("--")
.arg("../test_project")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.expect("Failed to execute cube2rust");
Command::new("cargo")
.arg("build")
.arg("--color=always")
.current_dir("../test_project")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.expect("Failed to execute cargo build");
}
#[test]
fn test_config() {
let filecontent = fs::read_to_string(IOC_FILE).expect("read failed");
let config = cube2rust::load_ioc(&filecontent);
dbg!(&config);
assert!(config.is_ok());
}
#[test]
fn test_params() {
let file_content = fs::read_to_string(IOC_FILE).expect("read failed");
let config_params = cube2rust::parse_ioc(&file_content);
dbg!(config_params);
}