From: Gabriel Féron Date: Mon, 28 May 2018 10:05:46 +0000 (+0200) Subject: Add test to check that publish fails when src directory was changed. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2^2~14^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8896fddef80eb276ba98fd772d11bdbcf1a2f8e4;p=cargo.git Add test to check that publish fails when src directory was changed. Co-authored-by: boxdot --- diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index 0eba5a8dd..ac7e5c7e4 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -872,3 +872,36 @@ fn block_publish_no_registry() { ), ); } + +#[test] +fn do_not_publish_if_src_was_modified() { + publish::setup(); + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/main.rs", r#" + fn main() { println!("hello"); } + "#) + .file("build.rs", r#" + use std::fs::File; + use std::io::Write; + + fn main() { + let mut file = File::create("src/generated.txt").expect("failed to create file"); + file.write_all(b"Hello, world of generated files.").expect("failed to write"); + } + "#) + .build(); + + assert_that( + p.cargo("publish") + .arg("--index") + .arg(publish::registry().to_string()), + execs().with_status(101), + ); +} \ No newline at end of file