comparison build.rs @ 94:e0368bea06a6

Refactor tests a little bit so it's easier to add more.
author Bastien Orivel <eijebong@bananium.fr>
date Tue, 14 Jun 2016 18:39:48 +0200
parents 199ba034e4af
children 6569eea3db23
comparison
equal deleted inserted replaced
93:c06d12a81637 94:e0368bea06a6
1 use std::env; 1 use std::env;
2 use std::path::Path; 2 use std::path::Path;
3 use std::io::prelude::*; 3 use std::io::prelude::*;
4 use std::fs::{File, read_dir}; 4 use std::fs::{File, read_dir};
5 5
6 fn main() { 6 fn gen_parse_file_tests(out_dir: String) {
7 let out_dir = env::var("OUT_DIR").unwrap();
8 let path = Path::new(&out_dir).join("generated_parse_tests.rs"); 7 let path = Path::new(&out_dir).join("generated_parse_tests.rs");
9 let mut f = File::create(&path).unwrap(); 8 let mut f = File::create(&path).unwrap();
10 9
11 for file in read_dir("tests/test_parse_files").unwrap() { 10 for file in read_dir("tests/test_parse_files").unwrap() {
12 let path = file.unwrap().path(); 11 let path = file.unwrap().path();
15 fn {}() {{ 14 fn {}() {{
16 test_parse_file(\"{}\"); 15 test_parse_file(\"{}\");
17 }}\n", test_name, path.to_str().unwrap()).as_bytes()).unwrap(); 16 }}\n", test_name, path.to_str().unwrap()).as_bytes()).unwrap();
18 } 17 }
19 } 18 }
19
20 fn main() {
21 let out_dir = env::var("OUT_DIR").unwrap();
22 gen_parse_file_tests(out_dir);
23 }