Add test to check that publish fails when src directory was changed.
authorGabriel Féron <feron.gabriel@gmail.com>
Mon, 28 May 2018 10:05:46 +0000 (12:05 +0200)
committerGabriel Féron <feron.gabriel@gmail.com>
Mon, 28 May 2018 10:11:45 +0000 (12:11 +0200)
Co-authored-by: boxdot <d@zerovolt.org>
tests/testsuite/publish.rs

index 0eba5a8ddac881906a4820cdc53322649fbacea5..ac7e5c7e47e219c4d1eb1b4f6f39cbe34b65aca5 100644 (file)
@@ -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