summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-01-16 17:51:04 +0100
committerLaurenz <laurmaedje@gmail.com>2020-01-16 17:51:04 +0100
commit08b91a265fcda74f5463473938ec33873b49a7f7 (patch)
tree747ac6a0b385a14a4aa5adbc3f21ef7b9653bd78 /build.rs
parent15ad30555bdad8e7b192fdcf7d4543c0d3fb18ce (diff)
Powerful parser testing 🐱‍👤
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/build.rs b/build.rs
index 0c3f1da5..e1670755 100644
--- a/build.rs
+++ b/build.rs
@@ -1,19 +1,20 @@
use std::fs::{self, create_dir_all, read_dir, read_to_string};
use std::ffi::OsStr;
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
create_dir_all("tests/cache")?;
// Make sure the script reruns if this file changes or files are
// added/deleted in the parsing folder.
println!("cargo:rerun-if-changed=build.rs");
- println!("cargo:rerun-if-changed=tests/cache/parse");
- println!("cargo:rerun-if-changed=tests/parsing");
+ println!("cargo:rerun-if-changed=tests/cache/parser-tests.rs");
+ println!("cargo:rerun-if-changed=tests/parser");
// Compile all parser tests into a single giant vector.
let mut code = "vec![".to_string();
- for entry in read_dir("tests/parsing")? {
+ for entry in read_dir("tests/parser")? {
let path = entry?.path();
if path.extension() != Some(OsStr::new("rs")) {
continue;
@@ -25,7 +26,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Make sure this also reruns if the contents of a file in parsing
// change. This is not ensured by rerunning only on the folder.
- println!("cargo:rerun-if-changed=tests/parsing/{}.rs", name);
+ println!("cargo:rerun-if-changed=tests/parser/{}.rs", name);
code.push_str(&format!("(\"{}\", tokens!{{", name));
@@ -44,7 +45,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
code.push(']');
- fs::write("tests/cache/parse", code)?;
+ fs::write("tests/cache/parser-tests.rs", code)?;
Ok(())
}