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

Configure Feed

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

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