Mercurial > python-compiler.rs
comparison build.rs @ 24:199ba034e4af
Generate tests dynamically based on tests/test_parse_files/ content.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Fri, 03 Jun 2016 22:18:15 +0200 |
parents | |
children | e0368bea06a6 |
comparison
equal
deleted
inserted
replaced
23:5a7c3393382b | 24:199ba034e4af |
---|---|
1 use std::env; | |
2 use std::path::Path; | |
3 use std::io::prelude::*; | |
4 use std::fs::{File, read_dir}; | |
5 | |
6 fn main() { | |
7 let out_dir = env::var("OUT_DIR").unwrap(); | |
8 let path = Path::new(&out_dir).join("generated_parse_tests.rs"); | |
9 let mut f = File::create(&path).unwrap(); | |
10 | |
11 for file in read_dir("tests/test_parse_files").unwrap() { | |
12 let path = file.unwrap().path(); | |
13 let test_name = path.file_stem().unwrap().to_str().unwrap(); | |
14 let _ = f.write_all(format!("#[test] | |
15 fn {}() {{ | |
16 test_parse_file(\"{}\"); | |
17 }}\n", test_name, path.to_str().unwrap()).as_bytes()).unwrap(); | |
18 } | |
19 } |