12
12
13
13
use context:: Ctx ;
14
14
use core:: hashmap:: HashMap ;
15
- use core:: { io, libc, os, result, run, str} ;
15
+ use core:: { io, libc, os, result, run, str, vec } ;
16
16
use core:: prelude:: * ;
17
17
use extra:: tempfile:: mkdtemp;
18
18
use core:: run:: ProcessOutput ;
@@ -25,7 +25,7 @@ use path_util::{target_executable_in_workspace, target_library_in_workspace,
25
25
make_dir_rwx, u_rwx, library_in_workspace,
26
26
built_bench_in_workspace, built_test_in_workspace,
27
27
built_library_in_workspace, built_executable_in_workspace,
28
- installed_library_in_workspace} ;
28
+ installed_library_in_workspace, rust_path } ;
29
29
use target:: * ;
30
30
31
31
/// Returns the last-modified date as an Option
@@ -547,13 +547,55 @@ fn rustpkg_local_pkg() {
547
547
}
548
548
549
549
#[test]
550
- #[ignore (reason = " RUST_PATH not yet implemented -- # 5682 ")]
550
+ #[ignore (reason = " Un -ignore when # 7071 is fixed ")]
551
551
fn rust_path_test() {
552
- let dir = mk_workspace(&Path(" /home/more_rust"),
553
- &normalize(RemotePath(Path(" foo"))),
554
- &NoVersion);
555
- // command_line_test(" RUST_PATH =/home/rust: /home/more_rust rustpkg install foo");
556
- command_line_test([~" install", ~" foo"], &dir);
552
+ let dir_for_path = mkdtemp(&os::tmpdir(), " more_rust").expect(" rust_path_test failed");
553
+ let dir = mk_workspace(&dir_for_path, &normalize(RemotePath(Path(" foo"))), &NoVersion);
554
+ debug!(" dir = %s", dir.to_str());
555
+ writeFile(&Path(" /Users /tjc/more_rust/src/foo-0.1 /main. rs"),
556
+ " fn main( ) { let _x = ( ) ; } ");
557
+
558
+ let cwd = os::getcwd();
559
+ debug!(" cwd = %s", cwd.to_str());
560
+ let mut prog = run::Process::new(" rustpkg",
561
+ [~" install", ~" foo"],
562
+ run::ProcessOptions { env: Some(&[(~" RUST_PATH ",
563
+ dir_for_path.to_str())]),
564
+ dir: Some(&cwd),
565
+ in_fd: None,
566
+ out_fd: None,
567
+ err_fd: None
568
+ });
569
+ prog.finish_with_output();
570
+ assert_executable_exists(&dir_for_path, " foo");
571
+ }
572
+
573
+ #[test]
574
+ fn rust_path_contents() {
575
+ let dir = mkdtemp(&os::tmpdir(), " rust_path").expect(" rust_path_contents failed");
576
+ let abc = &dir.push(" A ").push(" B ").push(" C ");
577
+ assert!(os::mkdir_recursive(&abc.push(" . rust"), u_rwx));
578
+ assert!(os::mkdir_recursive(&abc.pop().push(" . rust"), u_rwx));
579
+ assert!(os::mkdir_recursive(&abc.pop().pop().push(" . rust"), u_rwx));
580
+ assert!(do os::change_dir_locked(&dir.push(" A ").push(" B ").push(" C ")) {
581
+ let p = rust_path();
582
+ let cwd = os::getcwd().push(" . rust");
583
+ let parent = cwd.pop().pop().push(" . rust");
584
+ let grandparent = cwd.pop().pop().pop().push(" . rust");
585
+ assert!(vec::contains(p, &cwd));
586
+ assert!(vec::contains(p, &parent));
587
+ assert!(vec::contains(p, &grandparent));
588
+ });
589
+ }
590
+
591
+ #[test]
592
+ fn rust_path_parse() {
593
+ os::setenv(" RUST_PATH ", " /a/b/c: /d/e/f: /g/h/i");
594
+ let paths = rust_path();
595
+ assert!(vec::contains(paths, &Path(" /g/h/i")));
596
+ assert!(vec::contains(paths, &Path(" /d/e/f")));
597
+ assert!(vec::contains(paths, &Path(" /a/b/c")));
598
+ os::unsetenv(" RUST_PATH ");
557
599
}
558
600
559
601
#[test]
0 commit comments