summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorElly Jones <elly@leptoquark.net>2012-01-18 22:24:07 -0500
committerElly Jones <elly@leptoquark.net>2012-01-18 22:36:57 -0500
commit4bd713bb8410d4711fe01377a687cd5a595e2dca (patch)
treead89ff4d5f7d159c8769b70aab538dae407aee70 /src
parent1ce288d5aa976428950cd76882a1ae5cee1ca245 (diff)
downloadrust-4bd713bb8410d4711fe01377a687cd5a595e2dca.tar.gz
rust-4bd713bb8410d4711fe01377a687cd5a595e2dca.zip
[cargo] refactor test_one_crate
Diffstat (limited to 'src')
-rw-r--r--src/cargo/cargo.rs38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs
index cdb3f315e40..c5cfca01b8a 100644
--- a/src/cargo/cargo.rs
+++ b/src/cargo/cargo.rs
@@ -357,23 +357,37 @@ fn for_each_package(c: cargo, b: block(source, package)) {
 
 // FIXME: deduplicate code with install_one_crate
 fn test_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
-    let name = fs::basename(cf);
-    let ri = str::index(name, '.' as u8);
-    if ri != -1 {
-        name = str::slice(name, 0u, ri as uint);
-    }
-    #debug("Installing: %s", name);
-    let old = fs::list_dir(".");
-    let p = run::program_output("rustc", ["--test", name + ".rc"]);
+    let buildpath = fs::connect(_path, "/test");
+    need_dir(buildpath);
+    #debug("Testing: %s -> %s", cf, buildpath);
+    let p = run::program_output("rustc", ["--out-dir", buildpath, "--test",
+                                          cf]);
+    if p.status != 0 {
+        error(#fmt["rustc failed: %d\n%s\n%s", p.status, p.err, p.out]);
+        ret;
+    }
+    let new = fs::list_dir(buildpath);
+    let exec_suffix = os::exec_suffix();
+    for ct: str in new {
+        if (exec_suffix != "" && str::ends_with(ct, exec_suffix)) ||
+            (exec_suffix == "" && !str::starts_with(ct, "./lib")) {
+            run::run_program(ct, []);
+        }
+    }
+}
+
+fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
+    let buildpath = fs::connect(_path, "/build");
+    need_dir(buildpath);
+    #debug("Installing: %s -> %s", cf, buildpath);
+    let p = run::program_output("rustc", ["--out-dir", buildpath, cf]);
     if p.status != 0 {
         error(#fmt["rustc failed: %d\n%s\n%s", p.status, p.err, p.out]);
         ret;
     }
-    let new = fs::list_dir(".");
-    let created =
-        vec::filter::<str>(new, { |n| !vec::member::<str>(n, old) });
+    let new = fs::list_dir(buildpath);
     let exec_suffix = os::exec_suffix();
-    for ct: str in created {
+    for ct: str in new {
         if (exec_suffix != "" && str::ends_with(ct, exec_suffix)) ||
             (exec_suffix == "" && !str::starts_with(ct, "./lib")) {
             // FIXME: need libstd fs::copy or something