jspg progress
This commit is contained in:
54
build.rs
54
build.rs
@ -19,21 +19,21 @@ fn main() {
|
||||
writeln!(std_file, "use jspg::util;").unwrap();
|
||||
|
||||
// Helper for snake_case conversion
|
||||
let to_snake_case = |s: &str| -> String {
|
||||
s.chars().fold(String::new(), |mut acc, c| {
|
||||
if c.is_uppercase() {
|
||||
if !acc.is_empty() {
|
||||
acc.push('_');
|
||||
}
|
||||
acc.push(c.to_ascii_lowercase());
|
||||
} else if c == '-' || c == ' ' || c == '.' || c == '/' || c == ':' {
|
||||
acc.push('_');
|
||||
} else if c.is_alphanumeric() {
|
||||
acc.push(c);
|
||||
}
|
||||
acc
|
||||
})
|
||||
};
|
||||
// let _to_snake_case = |s: &str| -> String {
|
||||
// s.chars().fold(String::new(), |mut acc, c| {
|
||||
// if c.is_uppercase() {
|
||||
// if !acc.is_empty() {
|
||||
// acc.push('_');
|
||||
// }
|
||||
// acc.push(c.to_ascii_lowercase());
|
||||
// } else if c == '-' || c == ' ' || c == '.' || c == '/' || c == ':' {
|
||||
// acc.push('_');
|
||||
// } else if c.is_alphanumeric() {
|
||||
// acc.push(c);
|
||||
// }
|
||||
// acc
|
||||
// })
|
||||
// };
|
||||
|
||||
// Walk tests/fixtures directly
|
||||
let fixtures_path = "tests/fixtures";
|
||||
@ -50,11 +50,29 @@ fn main() {
|
||||
|
||||
if let Some(arr) = val.as_array() {
|
||||
for (i, _item) in arr.iter().enumerate() {
|
||||
// Use short, deterministic names to avoid Postgres 63-byte limit
|
||||
// e.g. test_dynamic_ref_case_0
|
||||
let fn_name = format!("test_{}_case_{}", to_snake_case(file_name), i);
|
||||
// Use deterministic names: test_{filename}_{index}
|
||||
// We sanitize the filename to be a valid identifier
|
||||
// Use manual snake_case logic since we don't want to add a build-dependency just yet if not needed,
|
||||
// but `dynamicRef` -> `dynamic_ref` requires parsing.
|
||||
// Let's implement a simple camelToSnake helper.
|
||||
let mut safe_filename = String::new();
|
||||
for (i, c) in file_name.chars().enumerate() {
|
||||
if c.is_uppercase() {
|
||||
if i > 0 {
|
||||
safe_filename.push('_');
|
||||
}
|
||||
safe_filename.push(c.to_ascii_lowercase());
|
||||
} else if c == '-' || c == '.' {
|
||||
safe_filename.push('_');
|
||||
} else {
|
||||
safe_filename.push(c);
|
||||
}
|
||||
}
|
||||
|
||||
let fn_name = format!("test_{}_{}", safe_filename, i);
|
||||
|
||||
// Write to src/tests.rs (PG Test)
|
||||
// CARGO_MANIFEST_DIR is used to find the absolute path to fixtures at runtime
|
||||
write!(
|
||||
pg_file,
|
||||
r#"
|
||||
|
||||
Reference in New Issue
Block a user