Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ShadowBuilder build shadow #195

Merged
merged 6 commits into from
Dec 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix cargo clippy check
baoyachi committed Dec 15, 2024
commit 07150f07eb00e60713377b01bba62dee374d0c10
2 changes: 1 addition & 1 deletion src/gen_const.rs
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ const CLAP_LONG_VERSION_TAG_CONST: (&str, &str) = (
tag:{}
commit_hash:{}
build_time:{}
build_env:{},{}"#,PKG_VERSION, TAG, SHORT_COMMIT, BUILD_TIME_2822, RUST_VERSION, RUST_CHANNEL
build_env:{},{}"#,PKG_VERSION, TAG, SHORT_COMMIT, BUILD_TIME, RUST_VERSION, RUST_CHANNEL
);"##,
);

16 changes: 11 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -686,7 +686,10 @@ mod tests {

#[test]
fn test_build() -> SdResult<()> {
Shadow::build_with("./".into(), "./".into(), Default::default())?;
ShadowBuilder::builder()
.src_path("./")
.out_path("./")
.build()?;
let shadow = fs::read_to_string("./shadow.rs")?;
assert!(!shadow.is_empty());
assert!(shadow.lines().count() > 0);
@@ -695,13 +698,16 @@ mod tests {

#[test]
fn test_build_deny() -> SdResult<()> {
let mut deny = BTreeSet::new();
deny.insert(CARGO_TREE);
Shadow::build_with("./".into(), "./".into(), deny)?;
ShadowBuilder::builder()
.src_path("./")
.out_path("./")
.deny_const(BTreeSet::from([CARGO_TREE]))
.build()?;

let shadow = fs::read_to_string("./shadow.rs")?;
assert!(!shadow.is_empty());
assert!(shadow.lines().count() > 0);
println!("{shadow}");
// println!("{shadow}");
let expect = "pub const CARGO_TREE :&str";
assert!(!shadow.contains(expect));
Ok(())