Parse and validate all tests first in iced_test::run
This commit is contained in:
parent
d8dbb7568a
commit
ed873514e5
1 changed files with 39 additions and 36 deletions
|
|
@ -118,53 +118,56 @@ pub fn run(
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
let tests = fs::read_dir(tests_dir)?;
|
let files = fs::read_dir(tests_dir)?;
|
||||||
|
let mut tests = Vec::new();
|
||||||
|
|
||||||
// TODO: Concurrent runtimes
|
for file in files {
|
||||||
for file in tests {
|
|
||||||
let file = file?;
|
let file = file?;
|
||||||
|
|
||||||
if file.path().extension().and_then(OsStr::to_str) != Some("ice") {
|
if file.path().extension().and_then(OsStr::to_str) != Some("ice") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ice = {
|
let content = fs::read_to_string(file.path())?;
|
||||||
let content = fs::read_to_string(file.path())?;
|
|
||||||
|
|
||||||
match Ice::parse(&content) {
|
match Ice::parse(&content) {
|
||||||
Ok(ice) => ice,
|
Ok(ice) => {
|
||||||
Err(error) => {
|
let preset = if let Some(preset) = &ice.preset {
|
||||||
return Err(Error::IceParsingFailed {
|
let Some(preset) = program
|
||||||
file: file.path().to_path_buf(),
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let (sender, mut receiver) = mpsc::channel(1);
|
|
||||||
|
|
||||||
let preset = if let Some(preset) = ice.preset {
|
|
||||||
let Some(preset) = program
|
|
||||||
.presets()
|
|
||||||
.iter()
|
|
||||||
.find(|candidate| candidate.name() == preset)
|
|
||||||
else {
|
|
||||||
return Err(Error::PresetNotFound {
|
|
||||||
name: preset.to_owned(),
|
|
||||||
available: program
|
|
||||||
.presets()
|
.presets()
|
||||||
.iter()
|
.iter()
|
||||||
.map(program::Preset::name)
|
.find(|candidate| candidate.name() == preset)
|
||||||
.map(str::to_owned)
|
else {
|
||||||
.collect(),
|
return Err(Error::PresetNotFound {
|
||||||
});
|
name: preset.to_owned(),
|
||||||
};
|
available: program
|
||||||
|
.presets()
|
||||||
|
.iter()
|
||||||
|
.map(program::Preset::name)
|
||||||
|
.map(str::to_owned)
|
||||||
|
.collect(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Some(preset)
|
Some(preset)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tests.push((file, ice, preset));
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
return Err(Error::IceParsingFailed {
|
||||||
|
file: file.path().to_path_buf(),
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Concurrent runtimes
|
||||||
|
for (file, ice, preset) in tests {
|
||||||
|
let (sender, mut receiver) = mpsc::channel(1);
|
||||||
|
|
||||||
let mut emulator = Emulator::with_preset(
|
let mut emulator = Emulator::with_preset(
|
||||||
sender,
|
sender,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue