This commit is contained in:
Simon Hausmann 2020-06-05 14:11:29 +02:00
parent 9fc60e104f
commit 46d7aaa2cb
3 changed files with 24 additions and 24 deletions

View file

@ -17,7 +17,7 @@ impl Driver {
Ok(Self { native_library_dependencies: deps.split(" ").map(String::from).collect() })
}
pub fn test(&self, testcase: &super::TestCase) -> Result<(), Box<dyn Error>> {
pub fn test(&self, testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>> {
let (syntax_node, mut diag) = parser::parse(&testcase.source);
diag.current_path = testcase.path.clone();
let mut tr = typeregister::TypeRegister::builtin();

View file

@ -1,33 +1,11 @@
use std::error::Error;
pub struct TestCase {
pub source: String,
pub path: std::path::PathBuf,
}
pub fn collect_test_cases() -> std::io::Result<Vec<TestCase>> {
let mut results = vec![];
for entry in std::fs::read_dir(format!("{}/../cases", env!("CARGO_MANIFEST_DIR")))? {
let entry = entry?;
let path = entry.path();
if let Some(ext) = path.extension() {
if ext == "60" {
let source = std::fs::read_to_string(&path)?;
results.push(TestCase { source, path });
}
}
}
Ok(results)
}
mod cpp;
fn main() -> Result<(), Box<dyn Error>> {
let cpp_driver = cpp::Driver::new()?;
for testcase in collect_test_cases()? {
for testcase in test_driver_lib::collect_test_cases()? {
cpp_driver.test(&testcase)?;
}

View file

@ -57,3 +57,25 @@ pub fn native_library_dependencies(
Ok(native_library_dependencies.trim().into())
}
pub struct TestCase {
pub source: String,
pub path: std::path::PathBuf,
}
pub fn collect_test_cases() -> std::io::Result<Vec<TestCase>> {
let mut results = vec![];
for entry in std::fs::read_dir(format!("{}/../cases", env!("CARGO_MANIFEST_DIR")))? {
let entry = entry?;
let path = entry.path();
if let Some(ext) = path.extension() {
if ext == "60" {
let source = std::fs::read_to_string(&path)?;
results.push(TestCase { source, path });
}
}
}
Ok(results)
}