From d90db967bcc46ef4ae3d8d25755655da5b578073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Mon, 1 Mar 2021 19:57:59 +0100 Subject: reading all scripts into a variable --- build.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 build.rs (limited to 'build.rs') diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..92b63ab --- /dev/null +++ b/build.rs @@ -0,0 +1,28 @@ +use std::path::{Path, PathBuf}; + +fn find_tests(directory: &Path) -> Vec { + let mut tests = Vec::new(); + + for entry in std::fs::read_dir(directory).unwrap() { + let path = entry.unwrap().path(); + + if path.file_name().unwrap().to_str().unwrap().starts_with("_") { + continue; + } + + if path.is_dir() { + tests.append(&mut find_tests(&path)); + } else { + assert!(!path.to_str().unwrap().contains(","), "You should be ashamed."); + tests.push(path); + } + } + + tests +} + +fn main() { + let tests = find_tests(Path::new("progs/")); + let files = tests.iter().fold(String::new(), |a, b| format!("{},{}", a, b.display())); + println!("cargo:rustc-env=SCRIPTS={}", &files[1..]); +} -- cgit v1.2.1 From 653b797aa68f8ec3a065909cff693327574fce91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Fri, 5 Mar 2021 21:23:21 +0100 Subject: remove unused build.rs --- build.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 build.rs (limited to 'build.rs') diff --git a/build.rs b/build.rs deleted file mode 100644 index 92b63ab..0000000 --- a/build.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::path::{Path, PathBuf}; - -fn find_tests(directory: &Path) -> Vec { - let mut tests = Vec::new(); - - for entry in std::fs::read_dir(directory).unwrap() { - let path = entry.unwrap().path(); - - if path.file_name().unwrap().to_str().unwrap().starts_with("_") { - continue; - } - - if path.is_dir() { - tests.append(&mut find_tests(&path)); - } else { - assert!(!path.to_str().unwrap().contains(","), "You should be ashamed."); - tests.push(path); - } - } - - tests -} - -fn main() { - let tests = find_tests(Path::new("progs/")); - let files = tests.iter().fold(String::new(), |a, b| format!("{},{}", a, b.display())); - println!("cargo:rustc-env=SCRIPTS={}", &files[1..]); -} -- cgit v1.2.1 From 2a8f5574191a61d8ef39706a7ac92ba14ab457eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Sun, 7 Mar 2021 15:42:28 +0100 Subject: add buildscript to fix tests not being found --- build.rs | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 build.rs (limited to 'build.rs') diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..bcfc238 --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rerun-if-changed=progs/") +} -- cgit v1.2.1