about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-12 14:31:54 -0700
committerbors <bors@rust-lang.org>2016-05-12 14:31:54 -0700
commit4ec5ce5e44823c29d4f641f764e53d57e8b28a6a (patch)
tree140b6c4e9f7a05a813227174e754d3f92dee74fd /src/libstd
parente88defe71806ad190588e168e513bc1098f7c9fb (diff)
parentbb9062a2967a5b772788aa14f742d8927ac040ba (diff)
downloadrust-4ec5ce5e44823c29d4f641f764e53d57e8b28a6a.tar.gz
rust-4ec5ce5e44823c29d4f641f764e53d57e8b28a6a.zip
Auto merge of #33282 - alexcrichton:rustbuild-crate-tests, r=brson
rustbuild: Add support for crate tests + doctests

This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc #31590
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/Cargo.toml1
-rw-r--r--src/libstd/build.rs16
2 files changed, 13 insertions, 4 deletions
diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml
index 6d33fb311cf..eded6e24f3e 100644
--- a/src/libstd/Cargo.toml
+++ b/src/libstd/Cargo.toml
@@ -8,7 +8,6 @@ build = "build.rs"
 name = "std"
 path = "lib.rs"
 crate-type = ["dylib", "rlib"]
-test = false
 
 [dependencies]
 alloc = { path = "../liballoc" }
diff --git a/src/libstd/build.rs b/src/libstd/build.rs
index e879d440643..ff9dacbb679 100644
--- a/src/libstd/build.rs
+++ b/src/libstd/build.rs
@@ -8,11 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![deny(warnings)]
+
 extern crate gcc;
 extern crate build_helper;
 
 use std::env;
-use std::fs;
 use std::path::PathBuf;
 use std::process::Command;
 
@@ -20,6 +21,7 @@ use build_helper::run;
 
 fn main() {
     println!("cargo:rustc-cfg=cargobuild");
+    println!("cargo:rerun-if-changed=build.rs");
 
     let target = env::var("TARGET").unwrap();
     let host = env::var("HOST").unwrap();
@@ -65,8 +67,16 @@ fn build_libbacktrace(host: &str, target: &str) {
     println!("cargo:rustc-link-lib=static=backtrace");
     println!("cargo:rustc-link-search=native={}/.libs", build_dir.display());
 
-    if fs::metadata(&build_dir.join(".libs/libbacktrace.a")).is_ok() {
-        return
+    let mut stack = src_dir.read_dir().unwrap()
+                           .map(|e| e.unwrap())
+                           .collect::<Vec<_>>();
+    while let Some(entry) = stack.pop() {
+        let path = entry.path();
+        if entry.file_type().unwrap().is_dir() {
+            stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
+        } else {
+            println!("cargo:rerun-if-changed={}", path.display());
+        }
     }
 
     let compiler = gcc::Config::new().get_compiler();