Merge pull request #120 from abagshaw/master
Start verification at most recently modified file
This commit is contained in:
commit
8f9d7ce3d8
|
@ -52,7 +52,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.subcommand_matches("verify").is_some() {
|
if matches.subcommand_matches("verify").is_some() {
|
||||||
match verify() {
|
match verify(None) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => std::process::exit(1),
|
Err(_) => std::process::exit(1),
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,15 @@ fn watch() -> notify::Result<()> {
|
||||||
let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2))?;
|
let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2))?;
|
||||||
watcher.watch("./exercises", RecursiveMode::Recursive)?;
|
watcher.watch("./exercises", RecursiveMode::Recursive)?;
|
||||||
|
|
||||||
let _ignored = verify();
|
let _ignored = verify(None);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match rx.recv() {
|
match rx.recv() {
|
||||||
Ok(event) => match event {
|
Ok(event) => match event {
|
||||||
DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
|
DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
|
||||||
if b.extension() == Some(OsStr::new("rs")) {
|
if b.extension() == Some(OsStr::new("rs")) {
|
||||||
let _ignored = verify();
|
println!("----------**********----------\n");
|
||||||
|
let _ignored = verify(Some(b.as_path().to_str().unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -5,13 +5,25 @@ use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
pub fn verify() -> Result<(), ()> {
|
pub fn verify(start_at: Option<&str>) -> Result<(), ()> {
|
||||||
let toml: Value = fs::read_to_string("info.toml").unwrap().parse().unwrap();
|
let toml: Value = fs::read_to_string("info.toml").unwrap().parse().unwrap();
|
||||||
let tomlvec: &Vec<Value> = toml.get("exercises").unwrap().as_array().unwrap();
|
let tomlvec: &Vec<Value> = toml.get("exercises").unwrap().as_array().unwrap();
|
||||||
|
let mut hit_start_at = false;
|
||||||
|
|
||||||
for i in tomlvec {
|
for i in tomlvec {
|
||||||
|
let path = i.get("path").unwrap().as_str().unwrap();
|
||||||
|
|
||||||
|
if let Some(start_at) = start_at {
|
||||||
|
if start_at.ends_with(path) {
|
||||||
|
hit_start_at = true;
|
||||||
|
} else if !hit_start_at {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match i.get("mode").unwrap().as_str().unwrap() {
|
match i.get("mode").unwrap().as_str().unwrap() {
|
||||||
"test" => test(i.get("path").unwrap().as_str().unwrap())?,
|
"test" => test(path)?,
|
||||||
"compile" => compile_only(i.get("path").unwrap().as_str().unwrap())?,
|
"compile" => compile_only(path)?,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue