Restructure hpack tests

This commit is contained in:
Carl Lerche
2017-06-29 23:11:35 -07:00
parent 63ffea61f5
commit a7b92d5ec2
8 changed files with 680 additions and 234 deletions

View File

@@ -0,0 +1,7 @@
[package]
name = "genfixture"
version = "0.1.0"
authors = ["Carl Lerche <me@carllerche.com>"]
[dependencies]
walkdir = "1.0.0"

View File

@@ -0,0 +1,64 @@
extern crate walkdir;
use self::walkdir::WalkDir;
use std::env;
use std::path::Path;
use std::collections::HashMap;
fn main() {
let args: Vec<_> = env::args().collect();
let path = args.get(1).expect("usage: genfixture [PATH]");
let path = Path::new(path);
let mut tests = HashMap::new();
for entry in WalkDir::new(path) {
let entry = entry.unwrap();
let path = entry.path().to_str().unwrap();
if !path.ends_with(".json") {
continue;
}
if path.contains("raw-data") {
continue;
}
// Get the relevant part
let fixture_path = path.split("fixtures/hpack/").last().unwrap();
// Now, split that into the group and the name
let module = fixture_path.split("/").next().unwrap();
tests.entry(module.to_string()).or_insert(vec![])
.push(fixture_path.to_string());
}
let mut one = false;
for (module, tests) in tests {
let module = module.replace("-", "_");
if one {
println!("");
}
one = true;
println!("fixture_mod!(");
println!(" {} => {{", module);
for test in tests {
let ident = test
.split("/").nth(1).unwrap()
.split(".").next().unwrap();
println!(" ({}, {:?});", ident, test);
}
println!(" }}");
println!(");");
}
}