You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build.rs generates per-case test .rs into tests/generated for local builds (compiled via mod generated) and into OUT_DIR/generated for CI (CI=true) and publish verify (target/package), switched via cargo:rustc-cfg=use_out_dir. Cargo.toml excludes tests/ from the published package; build.rs early-returns when tests/cases is absent (published crate or dependent build), so it never writes outside OUT_DIR and never pollutes the registry source dir. cargo package verify passes.
letmut all_rs = String::from("// AUTO-GENERATED by build.rs. Do not edit.\n\n");
95
-
letmut top_mod = String::from("// AUTO-GENERATED by build.rs. Do not edit.\n\n");
96
99
for(topic, cases)in by_topic {
97
100
let topic_dir = gen_dir.join(topic);
98
101
fs::create_dir_all(&topic_dir).unwrap();
99
102
let topic_ident = topic.replace('-',"_");
100
-
letmut topic_mod = String::from("// AUTO-GENERATED. Do not edit.\n\n");
101
103
for(name, name_ident, body, ignore)in cases {
102
104
let fn_name = format!("html_{}_{}", topic_ident, name_ident);
103
105
let ignore_attr = if*ignore {"#[ignore]\n"}else{""};
104
106
let case_rs = format!(
105
107
"// AUTO-GENERATED from tests/cases/{topic}/{name}.html. Do not edit.\n\n{ignore_attr}#[rustfmt::skip]\n#[test]\nfn {fn_name}() {{\n use crate::TestCtx;\n{body}}}\n"
letmut top_mod = String::from("// AUTO-GENERATED by build.rs. Do not edit.\n\n");
126
+
for(topic, cases)in by_topic {
127
+
let topic_dir = gen_dir.join(topic);
128
+
fs::create_dir_all(&topic_dir).unwrap();
129
+
let topic_ident = topic.replace('-',"_");
130
+
letmut topic_mod = String::from("// AUTO-GENERATED. Do not edit.\n\n");
131
+
for(name, name_ident, body, ignore)in cases {
132
+
let fn_name = format!("html_{}_{}", topic_ident, name_ident);
133
+
let ignore_attr = if*ignore {"#[ignore]\n"}else{""};
134
+
let case_rs = format!(
135
+
"// AUTO-GENERATED from tests/cases/{topic}/{name}.html. Do not edit.\nuse crate::TestCtx;\n\n{ignore_attr}#[rustfmt::skip]\n#[test]\nfn {fn_name}() {{\n{body}}}\n"
0 commit comments