mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-14 16:35:01 +01:00
72 lines
1.1 KiB
Rust
72 lines
1.1 KiB
Rust
mod helper;
|
|
|
|
use std::path::Path;
|
|
|
|
use anyhow::Result;
|
|
|
|
use helper::run_test;
|
|
|
|
#[test]
|
|
fn hello_world_no_verify() -> Result<()> {
|
|
run_test(
|
|
r##"
|
|
fn main() {
|
|
println!("Hello, world!");
|
|
}
|
|
"##,
|
|
r##"
|
|
fn main() {
|
|
loop {}
|
|
}
|
|
"##,
|
|
|opts| {
|
|
opts.no_verify = true;
|
|
},
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn unused() -> Result<()> {
|
|
// After everybody_loops, `unused` becomes dead and should be removed.
|
|
run_test(
|
|
r##"
|
|
fn unused() {}
|
|
|
|
fn main() {
|
|
unused();
|
|
}
|
|
"##,
|
|
r##"
|
|
fn main() {
|
|
loop {}
|
|
}
|
|
"##,
|
|
|opts| {
|
|
opts.no_verify = true;
|
|
},
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
#[cfg_attr(windows, ignore)]
|
|
fn custom_script_success() -> Result<()> {
|
|
let script_path = Path::new(file!())
|
|
.parent()
|
|
.unwrap()
|
|
.join("always_success.sh")
|
|
.canonicalize()?;
|
|
|
|
run_test(
|
|
r##"
|
|
fn main() {}
|
|
"##,
|
|
r##"
|
|
fn main() {
|
|
loop {}
|
|
}
|
|
"##,
|
|
|opts| {
|
|
opts.script_path = Some(script_path);
|
|
},
|
|
)
|
|
}
|