Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

1use std::path::PathBuf; 2 3pub fn main() { 4 println!("cargo:rerun-if-changed=cases"); 5 6 let mut module = "//! This file is generated by build.rs 7//! Do not edit it directly, instead add new test cases to ./cases 8 9use gleam_core::build::Mode; 10" 11 .to_string(); 12 13 let cases = PathBuf::from("./cases"); 14 15 let mut names: Vec<_> = std::fs::read_dir(&cases) 16 .unwrap() 17 .map(|entry| entry.unwrap().file_name().into_string().unwrap()) 18 .collect(); 19 names.sort(); 20 21 for name in names { 22 let path = cases.join(&name); 23 let path = path.to_str().unwrap().replace('\\', "/"); 24 module.push_str(&testcase(&name, &path, "Dev")); 25 module.push_str(&testcase(&name, &path, "Prod")); 26 module.push_str(&testcase(&name, &path, "Lsp")); 27 } 28 29 let out = PathBuf::from("./src/generated_tests.rs"); 30 std::fs::write(out, module).unwrap(); 31} 32 33fn testcase(name: &str, path: &str, mode: &str) -> String { 34 format!( 35 r#" 36#[rustfmt::skip] 37#[test] 38fn {name}() {{ 39 let output = crate::prepare("{path}", Mode::{mode}); 40 insta::assert_snapshot!( 41 "{name}", 42 output, 43 "{path}", 44 ); 45}} 46"#, 47 name = format!("{name}_{}", mode.to_lowercase()) 48 ) 49}