]> git.proxmox.com Git - cargo.git/commitdiff
Add a test for tests in benchmarks
authorAlex Crichton <alex@alexcrichton.com>
Tue, 24 Mar 2015 01:01:27 +0000 (18:01 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 24 Mar 2015 22:13:00 +0000 (15:13 -0700)
Closes #727

tests/test_cargo_bench.rs
tests/test_cargo_freshness.rs

index e5009e3f3cf6ed0a25b7a15a9a2fd2dce23d661f..6ebf0e31f5ffe4efb677c4f2e7e63d67c95d8783 100644 (file)
@@ -855,3 +855,40 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
                        dir = p.root().display(),
                        url = p.url()).as_slice()));
 });
+
+test!(test_a_bench {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            authors = []
+            version = "0.1.0"
+
+            [lib]
+            name = "foo"
+            test = false
+            doctest = false
+
+            [[bench]]
+            name = "b"
+            test = true
+        "#)
+        .file("src/lib.rs", "")
+        .file("benches/b.rs", r#"
+            #[test]
+            fn foo() {}
+        "#);
+
+    assert_that(p.cargo_process("test"),
+                execs().with_status(0)
+                       .with_stdout(format!("\
+{compiling} foo v0.1.0 ([..])
+{running} target[..]debug[..]b-[..]
+
+running 1 test
+test foo ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+
+", compiling = COMPILING, running = RUNNING)));
+});
index 24fce3aa4d40633fe364f27dc2754cb4105caacb..68c94c6257241857c79b846cdfffabf4a501b66b 100644 (file)
@@ -77,6 +77,8 @@ test!(modify_only_some_files {
     p.root().move_into_the_past().unwrap();
 
     File::create(&bin).unwrap().write_all(b"fn foo() {}").unwrap();
+    // p.root().move_into_the_past().unwrap();
+    // p.root().join("target").move_into_the_past().unwrap();
 
     // Make sure the binary is rebuilt, not the lib
     assert_that(p.cargo("build")
@@ -195,6 +197,8 @@ test!(rebuild_tests_if_lib_changes {
                 execs().with_status(0));
 
     File::create(&p.root().join("src/lib.rs")).unwrap();
+    p.root().move_into_the_past().unwrap();
+    p.root().join("target").move_into_the_past().unwrap();
 
     assert_that(p.cargo("build"),
                 execs().with_status(0));