Restructure hpack tests
This commit is contained in:
7
util/genfixture/Cargo.toml
Normal file
7
util/genfixture/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "genfixture"
|
||||
version = "0.1.0"
|
||||
authors = ["Carl Lerche <me@carllerche.com>"]
|
||||
|
||||
[dependencies]
|
||||
walkdir = "1.0.0"
|
||||
64
util/genfixture/src/main.rs
Normal file
64
util/genfixture/src/main.rs
Normal 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!(");");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user