path2: Adjust the API to remove all the _str mutation methods
Add a new trait BytesContainer that is implemented for both byte vectors and strings. Convert Path::from_vec and ::from_str to one function, Path::new(). Remove all the _str-suffixed mutation methods (push, join, with_*, set_*) and modify the non-suffixed versions to use BytesContainer.
This commit is contained in:
parent
ed539e1471
commit
d6d9b92683
53 changed files with 1373 additions and 1474 deletions
|
|
@ -41,7 +41,7 @@ use util::datestamp;
|
|||
|
||||
fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext {
|
||||
let context = workcache::Context::new(
|
||||
RWArc::new(Database::new(workspace.join_str("rustpkg_db.json"))),
|
||||
RWArc::new(Database::new(workspace.join("rustpkg_db.json"))),
|
||||
RWArc::new(Logger::new()),
|
||||
Arc::new(TreeMap::new()));
|
||||
BuildContext {
|
||||
|
|
@ -59,7 +59,7 @@ fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext {
|
|||
fn fake_pkg() -> PkgId {
|
||||
let sn = ~"bogus";
|
||||
PkgId {
|
||||
path: Path::from_str(sn),
|
||||
path: Path::new(sn.as_slice()),
|
||||
short_name: sn,
|
||||
version: NoVersion
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ fn fake_pkg() -> PkgId {
|
|||
|
||||
fn git_repo_pkg() -> PkgId {
|
||||
PkgId {
|
||||
path: Path::from_str("mockgithub.com/catamorphism/test-pkg"),
|
||||
path: Path::new("mockgithub.com/catamorphism/test-pkg"),
|
||||
short_name: ~"test-pkg",
|
||||
version: NoVersion
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ fn git_repo_pkg() -> PkgId {
|
|||
|
||||
fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId {
|
||||
PkgId {
|
||||
path: Path::from_str("mockgithub.com/catamorphism/test-pkg"),
|
||||
path: Path::new("mockgithub.com/catamorphism/test-pkg"),
|
||||
short_name: ~"test-pkg",
|
||||
version: Tagged(a_tag)
|
||||
}
|
||||
|
|
@ -102,18 +102,18 @@ fn mk_empty_workspace(short_name: &Path, version: &Version, tag: &str) -> TempDi
|
|||
fn mk_workspace(workspace: &Path, short_name: &Path, version: &Version) -> Path {
|
||||
// include version number in directory name
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let package_dir = workspace.join_many_str([~"src", format!("{}-{}",
|
||||
short_name.as_str().unwrap(), version.to_str())]);
|
||||
let package_dir = workspace.join_many([~"src", format!("{}-{}",
|
||||
short_name.as_str().unwrap(), version.to_str())]);
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
package_dir
|
||||
}
|
||||
|
||||
fn mk_temp_workspace(short_name: &Path, version: &Version) -> (TempDir, Path) {
|
||||
let workspace_dir = mk_empty_workspace(short_name, version, "temp_workspace");
|
||||
let package_dir = workspace_dir.path().join_many_str([~"src",
|
||||
format!("{}-{}",
|
||||
short_name.to_str(),
|
||||
version.to_str())]);
|
||||
let package_dir = workspace_dir.path().join_many([~"src",
|
||||
format!("{}-{}",
|
||||
short_name.to_str(),
|
||||
version.to_str())]);
|
||||
|
||||
debug2!("Created {} and does it exist? {:?}", package_dir.display(),
|
||||
os::path_is_dir(&package_dir));
|
||||
|
|
@ -124,13 +124,13 @@ fn mk_temp_workspace(short_name: &Path, version: &Version) -> (TempDir, Path) {
|
|||
os::path_is_dir(&package_dir));
|
||||
// Create main, lib, test, and bench files
|
||||
|
||||
writeFile(&package_dir.join_str("main.rs"),
|
||||
writeFile(&package_dir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&package_dir.join_str("lib.rs"),
|
||||
writeFile(&package_dir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
writeFile(&package_dir.join_str("test.rs"),
|
||||
writeFile(&package_dir.join("test.rs"),
|
||||
"#[test] pub fn f() { (); }");
|
||||
writeFile(&package_dir.join_str("bench.rs"),
|
||||
writeFile(&package_dir.join("bench.rs"),
|
||||
"#[bench] pub fn f() { (); }");
|
||||
(workspace_dir, package_dir)
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ fn init_git_repo(p: &Path) -> TempDir {
|
|||
run_git([~"init"], None, &work_dir_for_opts,
|
||||
format!("Couldn't initialize git repository in {}", work_dir.display()));
|
||||
// Add stuff to the dir so that git tag succeeds
|
||||
writeFile(&work_dir.join_str("README"), "");
|
||||
writeFile(&work_dir.join("README"), "");
|
||||
run_git([~"add", ~"README"], None, &work_dir_for_opts, format!("Couldn't add in {}",
|
||||
work_dir.display()));
|
||||
git_commit(&work_dir_for_opts, ~"whatever");
|
||||
|
|
@ -232,13 +232,13 @@ fn test_sysroot() -> Path {
|
|||
// Returns the path to rustpkg
|
||||
fn rustpkg_exec() -> Path {
|
||||
// Ugh
|
||||
let first_try = test_sysroot().join_many_str(
|
||||
let first_try = test_sysroot().join_many(
|
||||
[~"lib", ~"rustc", host_triple(), ~"bin", ~"rustpkg"]);
|
||||
if is_executable(&first_try) {
|
||||
first_try
|
||||
}
|
||||
else {
|
||||
let second_try = test_sysroot().join_many_str(["bin", "rustpkg"]);
|
||||
let second_try = test_sysroot().join_many(["bin", "rustpkg"]);
|
||||
if is_executable(&second_try) {
|
||||
second_try
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ fn create_local_package(pkgid: &PkgId) -> TempDir {
|
|||
|
||||
fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
|
||||
|
||||
let package_dir = pkgdir.join_many_str([~"src", pkgid.to_str()]);
|
||||
let package_dir = pkgdir.join_many([~"src", pkgid.to_str()]);
|
||||
|
||||
// Create main, lib, test, and bench files
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
|
|
@ -336,13 +336,13 @@ fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
|
|||
os::path_is_dir(&package_dir));
|
||||
// Create main, lib, test, and bench files
|
||||
|
||||
writeFile(&package_dir.join_str("main.rs"),
|
||||
writeFile(&package_dir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&package_dir.join_str("lib.rs"),
|
||||
writeFile(&package_dir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
writeFile(&package_dir.join_str("test.rs"),
|
||||
writeFile(&package_dir.join("test.rs"),
|
||||
"#[test] pub fn f() { (); }");
|
||||
writeFile(&package_dir.join_str("bench.rs"),
|
||||
writeFile(&package_dir.join("bench.rs"),
|
||||
"#[bench] pub fn f() { (); }");
|
||||
package_dir
|
||||
}
|
||||
|
|
@ -356,11 +356,11 @@ fn create_local_package_with_dep(pkgid: &PkgId, subord_pkgid: &PkgId) -> TempDir
|
|||
let package_dir = create_local_package(pkgid);
|
||||
create_local_package_in(subord_pkgid, package_dir.path());
|
||||
// Write a main.rs file into pkgid that references subord_pkgid
|
||||
writeFile(&package_dir.path().join_many_str([~"src", pkgid.to_str(), ~"main.rs"]),
|
||||
writeFile(&package_dir.path().join_many([~"src", pkgid.to_str(), ~"main.rs"]),
|
||||
format!("extern mod {};\nfn main() \\{\\}",
|
||||
subord_pkgid.short_name));
|
||||
// Write a lib.rs file into subord_pkgid that has something in it
|
||||
writeFile(&package_dir.path().join_many_str([~"src", subord_pkgid.to_str(), ~"lib.rs"]),
|
||||
writeFile(&package_dir.path().join_many([~"src", subord_pkgid.to_str(), ~"lib.rs"]),
|
||||
"pub fn f() {}");
|
||||
package_dir
|
||||
}
|
||||
|
|
@ -452,7 +452,7 @@ fn llvm_bitcode_file_exists(repo: &Path, short_name: &str) -> bool {
|
|||
}
|
||||
|
||||
fn file_exists(repo: &Path, short_name: &str, extension: &str) -> bool {
|
||||
os::path_exists(&target_build_dir(repo).join_many_str([short_name.to_owned(),
|
||||
os::path_exists(&target_build_dir(repo).join_many([short_name.to_owned(),
|
||||
format!("{}.{}", short_name, extension)]))
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ fn command_line_test_output_with_env(args: &[~str], env: ~[(~str, ~str)]) -> ~[~
|
|||
fn lib_output_file_name(workspace: &Path, short_name: &str) -> Path {
|
||||
debug2!("lib_output_file_name: given {} and short name {}",
|
||||
workspace.display(), short_name);
|
||||
library_in_workspace(&Path::from_str(short_name),
|
||||
library_in_workspace(&Path::new(short_name),
|
||||
short_name,
|
||||
Build,
|
||||
workspace,
|
||||
|
|
@ -506,13 +506,13 @@ fn lib_output_file_name(workspace: &Path, short_name: &str) -> Path {
|
|||
}
|
||||
|
||||
fn output_file_name(workspace: &Path, short_name: ~str) -> Path {
|
||||
target_build_dir(workspace).join_str(short_name).join_str(format!("{}{}", short_name,
|
||||
os::EXE_SUFFIX))
|
||||
target_build_dir(workspace).join(short_name.as_slice()).join(format!("{}{}", short_name,
|
||||
os::EXE_SUFFIX))
|
||||
}
|
||||
|
||||
fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
|
||||
use conditions::bad_path::cond;
|
||||
let pkg_src_dir = workspace.join_many_str([~"src", pkgid.to_str()]);
|
||||
let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
|
||||
let contents = os::list_dir_path(&pkg_src_dir);
|
||||
for p in contents.iter() {
|
||||
if p.extension_str() == Some("rs") {
|
||||
|
|
@ -528,9 +528,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
|
|||
/// Add a comment at the end
|
||||
fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
|
||||
use conditions::bad_path::cond;
|
||||
let pkg_src_dir = workspace.join_many_str([~"src", pkgid.to_str()]);
|
||||
let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
|
||||
let mut maybe_p = None;
|
||||
let maybe_file = pkg_src_dir.join_str(filename);
|
||||
let maybe_file = pkg_src_dir.join(filename);
|
||||
debug2!("Trying to frob {} -- {}", pkg_src_dir.display(), filename);
|
||||
if os::path_exists(&maybe_file) {
|
||||
maybe_p = Some(maybe_file);
|
||||
|
|
@ -552,7 +552,7 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
|
|||
#[test]
|
||||
fn test_make_dir_rwx() {
|
||||
let temp = &os::tmpdir();
|
||||
let dir = temp.join_str("quux");
|
||||
let dir = temp.join("quux");
|
||||
assert!(!os::path_exists(&dir) ||
|
||||
os::remove_dir_recursive(&dir));
|
||||
debug2!("Trying to make {}", dir.display());
|
||||
|
|
@ -630,16 +630,16 @@ fn test_install_git() {
|
|||
let repo = init_git_repo(&temp_pkg_id.path);
|
||||
let repo = repo.path();
|
||||
debug2!("repo = {}", repo.display());
|
||||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
debug2!("repo_subdir = {}", repo_subdir.display());
|
||||
|
||||
writeFile(&repo_subdir.join_str("main.rs"),
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("lib.rs"),
|
||||
writeFile(&repo_subdir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("test.rs"),
|
||||
writeFile(&repo_subdir.join("test.rs"),
|
||||
"#[test] pub fn f() { (); }");
|
||||
writeFile(&repo_subdir.join_str("bench.rs"),
|
||||
writeFile(&repo_subdir.join("bench.rs"),
|
||||
"#[bench] pub fn f() { (); }");
|
||||
add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files
|
||||
|
||||
|
|
@ -648,7 +648,7 @@ fn test_install_git() {
|
|||
// should have test, bench, lib, and main
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
command_line_test([~"install", temp_pkg_id.path.as_str().unwrap().to_owned()], repo);
|
||||
let ws = repo.join_str(".rust");
|
||||
let ws = repo.join(".rust");
|
||||
// Check that all files exist
|
||||
debug2!("Checking for files in {}", ws.display());
|
||||
let exec = target_executable_in_workspace(&temp_pkg_id, &ws);
|
||||
|
|
@ -705,12 +705,12 @@ fn test_package_ids_must_be_relative_path_like() {
|
|||
}
|
||||
|
||||
do cond.trap(|(p, e)| {
|
||||
let abs = os::make_absolute(&Path::from_str("foo/bar/quux"));
|
||||
let abs = os::make_absolute(&Path::new("foo/bar/quux"));
|
||||
assert_eq!(p, abs);
|
||||
assert!("absolute pkgid" == e);
|
||||
whatever.clone()
|
||||
}).inside {
|
||||
let zp = os::make_absolute(&Path::from_str("foo/bar/quux"));
|
||||
let zp = os::make_absolute(&Path::new("foo/bar/quux"));
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let z = PkgId::new(zp.as_str().unwrap());
|
||||
assert_eq!(~"foo-0.1", z.to_str());
|
||||
|
|
@ -721,17 +721,17 @@ fn test_package_ids_must_be_relative_path_like() {
|
|||
#[test]
|
||||
fn test_package_version() {
|
||||
let local_path = "mockgithub.com/catamorphism/test_pkg_version";
|
||||
let repo = init_git_repo(&Path::from_str(local_path));
|
||||
let repo = init_git_repo(&Path::new(local_path));
|
||||
let repo = repo.path();
|
||||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test_pkg_version"]);
|
||||
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test_pkg_version"]);
|
||||
debug2!("Writing files in: {}", repo_subdir.display());
|
||||
writeFile(&repo_subdir.join_str("main.rs"),
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("lib.rs"),
|
||||
writeFile(&repo_subdir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("test.rs"),
|
||||
writeFile(&repo_subdir.join("test.rs"),
|
||||
"#[test] pub fn f() { (); }");
|
||||
writeFile(&repo_subdir.join_str("bench.rs"),
|
||||
writeFile(&repo_subdir.join("bench.rs"),
|
||||
"#[bench] pub fn f() { (); }");
|
||||
add_git_tag(&repo_subdir, ~"0.4");
|
||||
|
||||
|
|
@ -740,7 +740,7 @@ fn test_package_version() {
|
|||
// This should look at the prefix, clone into a workspace, then build.
|
||||
command_line_test([~"install", ~"mockgithub.com/catamorphism/test_pkg_version"],
|
||||
repo);
|
||||
let ws = repo.join_str(".rust");
|
||||
let ws = repo.join(".rust");
|
||||
// we can still match on the filename to make sure it contains the 0.4 version
|
||||
assert!(match built_library_in_workspace(&temp_pkg_id,
|
||||
&ws) {
|
||||
|
|
@ -751,36 +751,36 @@ fn test_package_version() {
|
|||
None => false
|
||||
});
|
||||
assert!(built_executable_in_workspace(&temp_pkg_id, &ws)
|
||||
== Some(target_build_dir(&ws).join_many_str(["mockgithub.com",
|
||||
"catamorphism",
|
||||
"test_pkg_version",
|
||||
"test_pkg_version"])));
|
||||
== Some(target_build_dir(&ws).join_many(["mockgithub.com",
|
||||
"catamorphism",
|
||||
"test_pkg_version",
|
||||
"test_pkg_version"])));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_package_request_version() {
|
||||
let local_path = "mockgithub.com/catamorphism/test_pkg_version";
|
||||
let repo = init_git_repo(&Path::from_str(local_path));
|
||||
let repo = init_git_repo(&Path::new(local_path));
|
||||
let repo = repo.path();
|
||||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test_pkg_version"]);
|
||||
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test_pkg_version"]);
|
||||
debug2!("Writing files in: {}", repo_subdir.display());
|
||||
writeFile(&repo_subdir.join_str("main.rs"),
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("lib.rs"),
|
||||
writeFile(&repo_subdir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("test.rs"),
|
||||
writeFile(&repo_subdir.join("test.rs"),
|
||||
"#[test] pub fn f() { (); }");
|
||||
writeFile(&repo_subdir.join_str("bench.rs"),
|
||||
writeFile(&repo_subdir.join("bench.rs"),
|
||||
"#[bench] pub fn f() { (); }");
|
||||
writeFile(&repo_subdir.join_str("version-0.3-file.txt"), "hi");
|
||||
writeFile(&repo_subdir.join("version-0.3-file.txt"), "hi");
|
||||
add_git_tag(&repo_subdir, ~"0.3");
|
||||
writeFile(&repo_subdir.join_str("version-0.4-file.txt"), "hello");
|
||||
writeFile(&repo_subdir.join("version-0.4-file.txt"), "hello");
|
||||
add_git_tag(&repo_subdir, ~"0.4");
|
||||
|
||||
command_line_test([~"install", format!("{}\\#0.3", local_path)], repo);
|
||||
|
||||
assert!(match installed_library_in_workspace(&Path::from_str("test_pkg_version"),
|
||||
&repo.join_str(".rust")) {
|
||||
assert!(match installed_library_in_workspace(&Path::new("test_pkg_version"),
|
||||
&repo.join(".rust")) {
|
||||
Some(p) => {
|
||||
debug2!("installed: {}", p.display());
|
||||
let suffix = format!("0.3{}", os::consts::DLL_SUFFIX);
|
||||
|
|
@ -789,15 +789,15 @@ fn test_package_request_version() {
|
|||
None => false
|
||||
});
|
||||
let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version#0.3");
|
||||
assert!(target_executable_in_workspace(&temp_pkg_id, &repo.join_str(".rust"))
|
||||
== repo.join_many_str([".rust", "bin", "test_pkg_version"]));
|
||||
assert!(target_executable_in_workspace(&temp_pkg_id, &repo.join(".rust"))
|
||||
== repo.join_many([".rust", "bin", "test_pkg_version"]));
|
||||
|
||||
let mut dir = target_build_dir(&repo.join_str(".rust"));
|
||||
dir.push_path(&Path::from_str("src/mockgithub.com/catamorphism/test_pkg_version-0.3"));
|
||||
let mut dir = target_build_dir(&repo.join(".rust"));
|
||||
dir.push_path(&Path::new("src/mockgithub.com/catamorphism/test_pkg_version-0.3"));
|
||||
debug2!("dir = {}", dir.display());
|
||||
assert!(os::path_is_dir(&dir));
|
||||
assert!(os::path_exists(&dir.join_str("version-0.3-file.txt")));
|
||||
assert!(!os::path_exists(&dir.join_str("version-0.4-file.txt")));
|
||||
assert!(os::path_exists(&dir.join("version-0.3-file.txt")));
|
||||
assert!(!os::path_exists(&dir.join("version-0.4-file.txt")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -810,23 +810,23 @@ fn rustpkg_install_url_2() {
|
|||
|
||||
#[test]
|
||||
fn rustpkg_library_target() {
|
||||
let foo_repo = init_git_repo(&Path::from_str("foo"));
|
||||
let foo_repo = init_git_repo(&Path::new("foo"));
|
||||
let foo_repo = foo_repo.path();
|
||||
let package_dir = foo_repo.join_str("foo");
|
||||
let package_dir = foo_repo.join("foo");
|
||||
|
||||
debug2!("Writing files in: {}", package_dir.display());
|
||||
writeFile(&package_dir.join_str("main.rs"),
|
||||
writeFile(&package_dir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&package_dir.join_str("lib.rs"),
|
||||
writeFile(&package_dir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
writeFile(&package_dir.join_str("test.rs"),
|
||||
writeFile(&package_dir.join("test.rs"),
|
||||
"#[test] pub fn f() { (); }");
|
||||
writeFile(&package_dir.join_str("bench.rs"),
|
||||
writeFile(&package_dir.join("bench.rs"),
|
||||
"#[bench] pub fn f() { (); }");
|
||||
|
||||
add_git_tag(&package_dir, ~"1.0");
|
||||
command_line_test([~"install", ~"foo"], foo_repo);
|
||||
assert_lib_exists(&foo_repo.join_str(".rust"), &Path::from_str("foo"), ExactRevision(~"1.0"));
|
||||
assert_lib_exists(&foo_repo.join(".rust"), &Path::new("foo"), ExactRevision(~"1.0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -844,26 +844,25 @@ fn package_script_with_default_build() {
|
|||
debug2!("dir = {}", dir.display());
|
||||
let mut source = test_sysroot().dir_path();
|
||||
source.pop(); source.pop();
|
||||
source.push_many_str(
|
||||
["src", "librustpkg", "testsuite", "pass", "src", "fancy-lib", "pkg.rs"]);
|
||||
source.push_many(["src", "librustpkg", "testsuite", "pass", "src", "fancy-lib", "pkg.rs"]);
|
||||
debug2!("package_script_with_default_build: {}", source.display());
|
||||
if !os::copy_file(&source,
|
||||
&dir.join_many_str(["src", "fancy-lib-0.1", "pkg.rs"])) {
|
||||
&dir.join_many(["src", "fancy-lib-0.1", "pkg.rs"])) {
|
||||
fail2!("Couldn't copy file");
|
||||
}
|
||||
command_line_test([~"install", ~"fancy-lib"], dir);
|
||||
assert_lib_exists(dir, &Path::from_str("fancy-lib"), NoVersion);
|
||||
assert!(os::path_exists(&target_build_dir(dir).join_many_str(["fancy-lib", "generated.rs"])));
|
||||
assert_lib_exists(dir, &Path::new("fancy-lib"), NoVersion);
|
||||
assert!(os::path_exists(&target_build_dir(dir).join_many(["fancy-lib", "generated.rs"])));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rustpkg_build_no_arg() {
|
||||
let tmp = TempDir::new("rustpkg_build_no_arg").expect("rustpkg_build_no_arg failed");
|
||||
let tmp = tmp.path().join_str(".rust");
|
||||
let package_dir = tmp.join_many_str(["src", "foo"]);
|
||||
let tmp = tmp.path().join(".rust");
|
||||
let package_dir = tmp.join_many(["src", "foo"]);
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
|
||||
writeFile(&package_dir.join_str("main.rs"),
|
||||
writeFile(&package_dir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
debug2!("build_no_arg: dir = {}", package_dir.display());
|
||||
command_line_test([~"build"], &package_dir);
|
||||
|
|
@ -873,24 +872,24 @@ fn rustpkg_build_no_arg() {
|
|||
#[test]
|
||||
fn rustpkg_install_no_arg() {
|
||||
let tmp = TempDir::new("rustpkg_install_no_arg").expect("rustpkg_install_no_arg failed");
|
||||
let tmp = tmp.path().join_str(".rust");
|
||||
let package_dir = tmp.join_many_str(["src", "foo"]);
|
||||
let tmp = tmp.path().join(".rust");
|
||||
let package_dir = tmp.join_many(["src", "foo"]);
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
writeFile(&package_dir.join_str("lib.rs"),
|
||||
writeFile(&package_dir.join("lib.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
debug2!("install_no_arg: dir = {}", package_dir.display());
|
||||
command_line_test([~"install"], &package_dir);
|
||||
assert_lib_exists(&tmp, &Path::from_str("foo"), NoVersion);
|
||||
assert_lib_exists(&tmp, &Path::new("foo"), NoVersion);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rustpkg_clean_no_arg() {
|
||||
let tmp = TempDir::new("rustpkg_clean_no_arg").expect("rustpkg_clean_no_arg failed");
|
||||
let tmp = tmp.path().join_str(".rust");
|
||||
let package_dir = tmp.join_many_str(["src", "foo"]);
|
||||
let tmp = tmp.path().join(".rust");
|
||||
let package_dir = tmp.join_many(["src", "foo"]);
|
||||
assert!(os::mkdir_recursive(&package_dir, U_RWX));
|
||||
|
||||
writeFile(&package_dir.join_str("main.rs"),
|
||||
writeFile(&package_dir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
debug2!("clean_no_arg: dir = {}", package_dir.display());
|
||||
command_line_test([~"build"], &package_dir);
|
||||
|
|
@ -903,9 +902,9 @@ fn rustpkg_clean_no_arg() {
|
|||
#[test]
|
||||
fn rust_path_test() {
|
||||
let dir_for_path = TempDir::new("more_rust").expect("rust_path_test failed");
|
||||
let dir = mk_workspace(dir_for_path.path(), &Path::from_str("foo"), &NoVersion);
|
||||
let dir = mk_workspace(dir_for_path.path(), &Path::new("foo"), &NoVersion);
|
||||
debug2!("dir = {}", dir.display());
|
||||
writeFile(&dir.join_str("main.rs"), "fn main() { let _x = (); }");
|
||||
writeFile(&dir.join("main.rs"), "fn main() { let _x = (); }");
|
||||
|
||||
let cwd = os::getcwd();
|
||||
debug2!("cwd = {}", cwd.display());
|
||||
|
|
@ -921,16 +920,16 @@ fn rust_path_test() {
|
|||
#[ignore] // FIXME(#9184) tests can't change the cwd (other tests are sad then)
|
||||
fn rust_path_contents() {
|
||||
let dir = TempDir::new("rust_path").expect("rust_path_contents failed");
|
||||
let abc = &dir.path().join_many_str(["A", "B", "C"]);
|
||||
assert!(os::mkdir_recursive(&abc.join_str(".rust"), U_RWX));
|
||||
let abc = &dir.path().join_many(["A", "B", "C"]);
|
||||
assert!(os::mkdir_recursive(&abc.join(".rust"), U_RWX));
|
||||
assert!(os::mkdir_recursive(&abc.with_filename(".rust"), U_RWX));
|
||||
assert!(os::mkdir_recursive(&abc.dir_path().with_filename(".rust"), U_RWX));
|
||||
assert!(os::change_dir(abc));
|
||||
|
||||
let p = rust_path();
|
||||
let cwd = os::getcwd().join_str(".rust");
|
||||
let parent = cwd.dir_path().with_filename_str(".rust");
|
||||
let grandparent = cwd.dir_path().dir_path().with_filename_str(".rust");
|
||||
let cwd = os::getcwd().join(".rust");
|
||||
let parent = cwd.dir_path().with_filename(".rust");
|
||||
let grandparent = cwd.dir_path().dir_path().with_filename(".rust");
|
||||
assert!(p.contains(&cwd));
|
||||
assert!(p.contains(&parent));
|
||||
assert!(p.contains(&grandparent));
|
||||
|
|
@ -943,9 +942,9 @@ fn rust_path_contents() {
|
|||
fn rust_path_parse() {
|
||||
os::setenv("RUST_PATH", "/a/b/c:/d/e/f:/g/h/i");
|
||||
let paths = rust_path();
|
||||
assert!(paths.contains(&Path::from_str("/g/h/i")));
|
||||
assert!(paths.contains(&Path::from_str("/d/e/f")));
|
||||
assert!(paths.contains(&Path::from_str("/a/b/c")));
|
||||
assert!(paths.contains(&Path::new("/g/h/i")));
|
||||
assert!(paths.contains(&Path::new("/d/e/f")));
|
||||
assert!(paths.contains(&Path::new("/a/b/c")));
|
||||
os::unsetenv("RUST_PATH");
|
||||
}
|
||||
|
||||
|
|
@ -1144,23 +1143,21 @@ fn test_non_numeric_tag() {
|
|||
let temp_pkg_id = git_repo_pkg();
|
||||
let repo = init_git_repo(&temp_pkg_id.path);
|
||||
let repo = repo.path();
|
||||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
writeFile(&repo_subdir.join_str("foo"), "foo");
|
||||
writeFile(&repo_subdir.join_str("lib.rs"),
|
||||
let repo_subdir = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
writeFile(&repo_subdir.join("foo"), "foo");
|
||||
writeFile(&repo_subdir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
add_git_tag(&repo_subdir, ~"testbranch");
|
||||
writeFile(&repo_subdir.join_str("testbranch_only"), "hello");
|
||||
writeFile(&repo_subdir.join("testbranch_only"), "hello");
|
||||
add_git_tag(&repo_subdir, ~"another_tag");
|
||||
writeFile(&repo_subdir.join_str("not_on_testbranch_only"), "bye bye");
|
||||
writeFile(&repo_subdir.join("not_on_testbranch_only"), "bye bye");
|
||||
add_all_and_commit(&repo_subdir);
|
||||
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
command_line_test([~"install", format!("{}\\#testbranch",
|
||||
temp_pkg_id.path.as_str().unwrap())], repo);
|
||||
let file1 = repo.join_many_str(["mockgithub.com", "catamorphism",
|
||||
"test-pkg", "testbranch_only"]);
|
||||
let file2 = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg",
|
||||
"master_only"]);
|
||||
let file1 = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg", "testbranch_only"]);
|
||||
let file2 = repo.join_many(["mockgithub.com", "catamorphism", "test-pkg", "master_only"]);
|
||||
assert!(os::path_exists(&file1));
|
||||
assert!(!os::path_exists(&file2));
|
||||
}
|
||||
|
|
@ -1169,13 +1166,12 @@ fn test_non_numeric_tag() {
|
|||
fn test_extern_mod() {
|
||||
let dir = TempDir::new("test_extern_mod").expect("test_extern_mod");
|
||||
let dir = dir.path();
|
||||
let main_file = dir.join_str("main.rs");
|
||||
let main_file = dir.join("main.rs");
|
||||
let lib_depend_dir = TempDir::new("foo").expect("test_extern_mod");
|
||||
let lib_depend_dir = lib_depend_dir.path();
|
||||
let aux_dir = lib_depend_dir.join_many_str(["src", "mockgithub.com", "catamorphism",
|
||||
"test_pkg"]);
|
||||
let aux_dir = lib_depend_dir.join_many(["src", "mockgithub.com", "catamorphism", "test_pkg"]);
|
||||
assert!(os::mkdir_recursive(&aux_dir, U_RWX));
|
||||
let aux_pkg_file = aux_dir.join_str("lib.rs");
|
||||
let aux_pkg_file = aux_dir.join("lib.rs");
|
||||
|
||||
writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n");
|
||||
assert!(os::path_exists(&aux_pkg_file));
|
||||
|
|
@ -1186,12 +1182,12 @@ fn test_extern_mod() {
|
|||
|
||||
command_line_test([~"install", ~"mockgithub.com/catamorphism/test_pkg"], lib_depend_dir);
|
||||
|
||||
let exec_file = dir.join_str("out");
|
||||
let exec_file = dir.join("out");
|
||||
// Be sure to extend the existing environment
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let env = Some([(~"RUST_PATH", lib_depend_dir.as_str().unwrap().to_owned())] + os::env());
|
||||
let rustpkg_exec = rustpkg_exec();
|
||||
let rustc = rustpkg_exec.with_filename_str("rustc");
|
||||
let rustc = rustpkg_exec.with_filename("rustc");
|
||||
|
||||
let test_sys = test_sysroot();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
|
|
@ -1219,12 +1215,12 @@ fn test_extern_mod() {
|
|||
fn test_extern_mod_simpler() {
|
||||
let dir = TempDir::new("test_extern_mod_simpler").expect("test_extern_mod_simpler");
|
||||
let dir = dir.path();
|
||||
let main_file = dir.join_str("main.rs");
|
||||
let main_file = dir.join("main.rs");
|
||||
let lib_depend_dir = TempDir::new("foo").expect("test_extern_mod_simpler");
|
||||
let lib_depend_dir = lib_depend_dir.path();
|
||||
let aux_dir = lib_depend_dir.join_many_str(["src", "rust-awesomeness"]);
|
||||
let aux_dir = lib_depend_dir.join_many(["src", "rust-awesomeness"]);
|
||||
assert!(os::mkdir_recursive(&aux_dir, U_RWX));
|
||||
let aux_pkg_file = aux_dir.join_str("lib.rs");
|
||||
let aux_pkg_file = aux_dir.join("lib.rs");
|
||||
|
||||
writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n");
|
||||
assert!(os::path_exists(&aux_pkg_file));
|
||||
|
|
@ -1235,12 +1231,12 @@ fn test_extern_mod_simpler() {
|
|||
|
||||
command_line_test([~"install", ~"rust-awesomeness"], lib_depend_dir);
|
||||
|
||||
let exec_file = dir.join_str("out");
|
||||
let exec_file = dir.join("out");
|
||||
// Be sure to extend the existing environment
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let env = Some([(~"RUST_PATH", lib_depend_dir.as_str().unwrap().to_owned())] + os::env());
|
||||
let rustpkg_exec = rustpkg_exec();
|
||||
let rustc = rustpkg_exec.with_filename_str("rustc");
|
||||
let rustc = rustpkg_exec.with_filename("rustc");
|
||||
let test_sys = test_sysroot();
|
||||
debug2!("RUST_PATH={} {} {} \n --sysroot {} -o {}",
|
||||
lib_depend_dir.display(),
|
||||
|
|
@ -1275,11 +1271,11 @@ fn test_import_rustpkg() {
|
|||
let p_id = PkgId::new("foo");
|
||||
let workspace = create_local_package(&p_id);
|
||||
let workspace = workspace.path();
|
||||
writeFile(&workspace.join_many_str(["src", "foo-0.1", "pkg.rs"]),
|
||||
writeFile(&workspace.join_many(["src", "foo-0.1", "pkg.rs"]),
|
||||
"extern mod rustpkg; fn main() {}");
|
||||
command_line_test([~"build", ~"foo"], workspace);
|
||||
debug2!("workspace = {}", workspace.display());
|
||||
assert!(os::path_exists(&target_build_dir(workspace).join_str("foo").join_str(format!("pkg{}",
|
||||
assert!(os::path_exists(&target_build_dir(workspace).join("foo").join(format!("pkg{}",
|
||||
os::EXE_SUFFIX))));
|
||||
}
|
||||
|
||||
|
|
@ -1288,11 +1284,11 @@ fn test_macro_pkg_script() {
|
|||
let p_id = PkgId::new("foo");
|
||||
let workspace = create_local_package(&p_id);
|
||||
let workspace = workspace.path();
|
||||
writeFile(&workspace.join_many_str(["src", "foo-0.1", "pkg.rs"]),
|
||||
writeFile(&workspace.join_many(["src", "foo-0.1", "pkg.rs"]),
|
||||
"extern mod rustpkg; fn main() { debug2!(\"Hi\"); }");
|
||||
command_line_test([~"build", ~"foo"], workspace);
|
||||
debug2!("workspace = {}", workspace.display());
|
||||
assert!(os::path_exists(&target_build_dir(workspace).join_str("foo").join_str(format!("pkg{}",
|
||||
assert!(os::path_exists(&target_build_dir(workspace).join("foo").join(format!("pkg{}",
|
||||
os::EXE_SUFFIX))));
|
||||
}
|
||||
|
||||
|
|
@ -1302,8 +1298,8 @@ fn multiple_workspaces() {
|
|||
// Copy the exact same package into directory B and install it
|
||||
// Set the RUST_PATH to A:B
|
||||
// Make a third package that uses foo, make sure we can build/install it
|
||||
let (a_loc, _pkg_dir) = mk_temp_workspace(&Path::from_str("foo"), &NoVersion);
|
||||
let (b_loc, _pkg_dir) = mk_temp_workspace(&Path::from_str("foo"), &NoVersion);
|
||||
let (a_loc, _pkg_dir) = mk_temp_workspace(&Path::new("foo"), &NoVersion);
|
||||
let (b_loc, _pkg_dir) = mk_temp_workspace(&Path::new("foo"), &NoVersion);
|
||||
let (a_loc, b_loc) = (a_loc.path(), b_loc.path());
|
||||
debug2!("Trying to install foo in {}", a_loc.display());
|
||||
command_line_test([~"install", ~"foo"], a_loc);
|
||||
|
|
@ -1328,7 +1324,7 @@ fn rust_path_hack_test(hack_flag: bool) {
|
|||
let p_id = PkgId::new("foo");
|
||||
let workspace = create_local_package(&p_id);
|
||||
let workspace = workspace.path();
|
||||
let dest_workspace = mk_empty_workspace(&Path::from_str("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
let rust_path = Some(~[(~"RUST_PATH",
|
||||
format!("{}:{}",
|
||||
|
|
@ -1336,11 +1332,11 @@ fn rust_path_hack_test(hack_flag: bool) {
|
|||
foo_path.as_str().unwrap()))]);
|
||||
command_line_test_with_env(~[~"install"] + if hack_flag { ~[~"--rust-path-hack"] } else { ~[] } +
|
||||
~[~"foo"], dest_workspace, rust_path);
|
||||
assert_lib_exists(dest_workspace, &Path::from_str("foo"), NoVersion);
|
||||
assert_lib_exists(dest_workspace, &Path::new("foo"), NoVersion);
|
||||
assert_executable_exists(dest_workspace, "foo");
|
||||
assert_built_library_exists(dest_workspace, "foo");
|
||||
assert_built_executable_exists(dest_workspace, "foo");
|
||||
assert!(!lib_exists(workspace, &Path::from_str("foo"), NoVersion));
|
||||
assert!(!lib_exists(workspace, &Path::new("foo"), NoVersion));
|
||||
assert!(!executable_exists(workspace, "foo"));
|
||||
assert!(!built_library_exists(workspace, "foo"));
|
||||
assert!(!built_executable_exists(workspace, "foo"));
|
||||
|
|
@ -1369,19 +1365,19 @@ fn test_rust_path_can_contain_package_dirs_without_flag() {
|
|||
fn rust_path_hack_cwd() {
|
||||
// Same as rust_path_hack_test, but the CWD is the dir to build out of
|
||||
let cwd = TempDir::new("foo").expect("rust_path_hack_cwd");
|
||||
let cwd = cwd.path().join_str("foo");
|
||||
let cwd = cwd.path().join("foo");
|
||||
assert!(os::mkdir_recursive(&cwd, U_RWX));
|
||||
writeFile(&cwd.join_str("lib.rs"), "pub fn f() { }");
|
||||
writeFile(&cwd.join("lib.rs"), "pub fn f() { }");
|
||||
|
||||
let dest_workspace = mk_empty_workspace(&Path::from_str("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let rust_path = Some(~[(~"RUST_PATH", dest_workspace.as_str().unwrap().to_owned())]);
|
||||
command_line_test_with_env([~"install", ~"--rust-path-hack", ~"foo"], &cwd, rust_path);
|
||||
debug2!("Checking that foo exists in {}", dest_workspace.display());
|
||||
assert_lib_exists(dest_workspace, &Path::from_str("foo"), NoVersion);
|
||||
assert_lib_exists(dest_workspace, &Path::new("foo"), NoVersion);
|
||||
assert_built_library_exists(dest_workspace, "foo");
|
||||
assert!(!lib_exists(&cwd, &Path::from_str("foo"), NoVersion));
|
||||
assert!(!lib_exists(&cwd, &Path::new("foo"), NoVersion));
|
||||
assert!(!built_library_exists(&cwd, "foo"));
|
||||
}
|
||||
|
||||
|
|
@ -1389,20 +1385,20 @@ fn rust_path_hack_cwd() {
|
|||
fn rust_path_hack_multi_path() {
|
||||
// Same as rust_path_hack_test, but with a more complex package ID
|
||||
let cwd = TempDir::new("pkg_files").expect("rust_path_hack_cwd");
|
||||
let subdir = cwd.path().join_many_str(["foo", "bar", "quux"]);
|
||||
let subdir = cwd.path().join_many(["foo", "bar", "quux"]);
|
||||
assert!(os::mkdir_recursive(&subdir, U_RWX));
|
||||
writeFile(&subdir.join_str("lib.rs"), "pub fn f() { }");
|
||||
writeFile(&subdir.join("lib.rs"), "pub fn f() { }");
|
||||
let name = ~"foo/bar/quux";
|
||||
|
||||
let dest_workspace = mk_empty_workspace(&Path::from_str("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let rust_path = Some(~[(~"RUST_PATH", dest_workspace.as_str().unwrap().to_owned())]);
|
||||
command_line_test_with_env([~"install", ~"--rust-path-hack", name.clone()], &subdir, rust_path);
|
||||
debug2!("Checking that {} exists in {}", name, dest_workspace.display());
|
||||
assert_lib_exists(dest_workspace, &Path::from_str("quux"), NoVersion);
|
||||
assert_lib_exists(dest_workspace, &Path::new("quux"), NoVersion);
|
||||
assert_built_library_exists(dest_workspace, name);
|
||||
assert!(!lib_exists(&subdir, &Path::from_str("quux"), NoVersion));
|
||||
assert!(!lib_exists(&subdir, &Path::new("quux"), NoVersion));
|
||||
assert!(!built_library_exists(&subdir, name));
|
||||
}
|
||||
|
||||
|
|
@ -1411,19 +1407,19 @@ fn rust_path_hack_install_no_arg() {
|
|||
// Same as rust_path_hack_cwd, but making rustpkg infer the pkg id
|
||||
let cwd = TempDir::new("pkg_files").expect("rust_path_hack_install_no_arg");
|
||||
let cwd = cwd.path();
|
||||
let source_dir = cwd.join_str("foo");
|
||||
let source_dir = cwd.join("foo");
|
||||
assert!(make_dir_rwx(&source_dir));
|
||||
writeFile(&source_dir.join_str("lib.rs"), "pub fn f() { }");
|
||||
writeFile(&source_dir.join("lib.rs"), "pub fn f() { }");
|
||||
|
||||
let dest_workspace = mk_empty_workspace(&Path::from_str("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let rust_path = Some(~[(~"RUST_PATH", dest_workspace.as_str().unwrap().to_owned())]);
|
||||
command_line_test_with_env([~"install", ~"--rust-path-hack"], &source_dir, rust_path);
|
||||
debug2!("Checking that foo exists in {}", dest_workspace.display());
|
||||
assert_lib_exists(dest_workspace, &Path::from_str("foo"), NoVersion);
|
||||
assert_lib_exists(dest_workspace, &Path::new("foo"), NoVersion);
|
||||
assert_built_library_exists(dest_workspace, "foo");
|
||||
assert!(!lib_exists(&source_dir, &Path::from_str("foo"), NoVersion));
|
||||
assert!(!lib_exists(&source_dir, &Path::new("foo"), NoVersion));
|
||||
assert!(!built_library_exists(cwd, "foo"));
|
||||
}
|
||||
|
||||
|
|
@ -1431,11 +1427,11 @@ fn rust_path_hack_install_no_arg() {
|
|||
fn rust_path_hack_build_no_arg() {
|
||||
// Same as rust_path_hack_install_no_arg, but building instead of installing
|
||||
let cwd = TempDir::new("pkg_files").expect("rust_path_hack_build_no_arg");
|
||||
let source_dir = cwd.path().join_str("foo");
|
||||
let source_dir = cwd.path().join("foo");
|
||||
assert!(make_dir_rwx(&source_dir));
|
||||
writeFile(&source_dir.join_str("lib.rs"), "pub fn f() { }");
|
||||
writeFile(&source_dir.join("lib.rs"), "pub fn f() { }");
|
||||
|
||||
let dest_workspace = mk_empty_workspace(&Path::from_str("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let rust_path = Some(~[(~"RUST_PATH", dest_workspace.as_str().unwrap().to_owned())]);
|
||||
|
|
@ -1449,9 +1445,9 @@ fn rust_path_hack_build_no_arg() {
|
|||
fn rust_path_install_target() {
|
||||
let dir_for_path = TempDir::new(
|
||||
"source_workspace").expect("rust_path_install_target failed");
|
||||
let mut dir = mk_workspace(dir_for_path.path(), &Path::from_str("foo"), &NoVersion);
|
||||
let mut dir = mk_workspace(dir_for_path.path(), &Path::new("foo"), &NoVersion);
|
||||
debug2!("dir = {}", dir.display());
|
||||
writeFile(&dir.join_str("main.rs"), "fn main() { let _x = (); }");
|
||||
writeFile(&dir.join("main.rs"), "fn main() { let _x = (); }");
|
||||
let dir_to_install_to = TempDir::new(
|
||||
"dest_workspace").expect("rust_path_install_target failed");
|
||||
let dir_to_install_to = dir_to_install_to.path();
|
||||
|
|
@ -1561,7 +1557,7 @@ fn notrans_flag_fail() {
|
|||
workspace, None, BAD_FLAG_CODE);
|
||||
assert!(!built_executable_exists(workspace, "foo"));
|
||||
assert!(!object_file_exists(workspace, "foo"));
|
||||
assert!(!lib_exists(workspace, &Path::from_str("foo"), NoVersion));
|
||||
assert!(!lib_exists(workspace, &Path::new("foo"), NoVersion));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1605,7 +1601,7 @@ fn test_cfg_build() {
|
|||
let workspace = create_local_package(&p_id);
|
||||
let workspace = workspace.path();
|
||||
// If the cfg flag gets messed up, this won't compile
|
||||
writeFile(&workspace.join_many_str(["src", "foo-0.1", "main.rs"]),
|
||||
writeFile(&workspace.join_many(["src", "foo-0.1", "main.rs"]),
|
||||
"#[cfg(quux)] fn main() {}");
|
||||
let test_sys = test_sysroot();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
|
|
@ -1623,7 +1619,7 @@ fn test_cfg_fail() {
|
|||
let p_id = PkgId::new("foo");
|
||||
let workspace = create_local_package(&p_id);
|
||||
let workspace = workspace.path();
|
||||
writeFile(&workspace.join_many_str(["src", "foo-0.1", "main.rs"]),
|
||||
writeFile(&workspace.join_many(["src", "foo-0.1", "main.rs"]),
|
||||
"#[cfg(quux)] fn main() {}");
|
||||
let test_sys = test_sysroot();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
|
|
@ -1780,23 +1776,23 @@ fn pkgid_pointing_to_subdir() {
|
|||
// rustpkg should recognize that and treat the part after some_repo/ as a subdir
|
||||
let workspace = TempDir::new("parent_repo").expect("Couldn't create temp dir");
|
||||
let workspace = workspace.path();
|
||||
assert!(os::mkdir_recursive(&workspace.join_many_str(["src", "mockgithub.com",
|
||||
"mozilla", "some_repo"]), U_RWX));
|
||||
assert!(os::mkdir_recursive(&workspace.join_many(["src", "mockgithub.com",
|
||||
"mozilla", "some_repo"]), U_RWX));
|
||||
|
||||
let foo_dir = workspace.join_many_str(["src", "mockgithub.com", "mozilla", "some_repo",
|
||||
"extras", "foo"]);
|
||||
let bar_dir = workspace.join_many_str(["src", "mockgithub.com", "mozilla", "some_repo",
|
||||
"extras", "bar"]);
|
||||
let foo_dir = workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo",
|
||||
"extras", "foo"]);
|
||||
let bar_dir = workspace.join_many(["src", "mockgithub.com", "mozilla", "some_repo",
|
||||
"extras", "bar"]);
|
||||
assert!(os::mkdir_recursive(&foo_dir, U_RWX));
|
||||
assert!(os::mkdir_recursive(&bar_dir, U_RWX));
|
||||
writeFile(&foo_dir.join_str("lib.rs"), "pub fn f() {}");
|
||||
writeFile(&bar_dir.join_str("lib.rs"), "pub fn g() {}");
|
||||
writeFile(&foo_dir.join("lib.rs"), "pub fn f() {}");
|
||||
writeFile(&bar_dir.join("lib.rs"), "pub fn g() {}");
|
||||
|
||||
debug2!("Creating a file in {}", workspace.display());
|
||||
let testpkg_dir = workspace.join_many_str(["src", "testpkg-0.1"]);
|
||||
let testpkg_dir = workspace.join_many(["src", "testpkg-0.1"]);
|
||||
assert!(os::mkdir_recursive(&testpkg_dir, U_RWX));
|
||||
|
||||
writeFile(&testpkg_dir.join_str("main.rs"),
|
||||
writeFile(&testpkg_dir.join("main.rs"),
|
||||
"extern mod foo = \"mockgithub.com/mozilla/some_repo/extras/foo\";\n
|
||||
extern mod bar = \"mockgithub.com/mozilla/some_repo/extras/bar\";\n
|
||||
use foo::f; use bar::g; \n
|
||||
|
|
@ -1813,13 +1809,13 @@ fn test_recursive_deps() {
|
|||
let c_id = PkgId::new("c");
|
||||
let b_workspace = create_local_package_with_dep(&b_id, &c_id);
|
||||
let b_workspace = b_workspace.path();
|
||||
writeFile(&b_workspace.join_many_str(["src", "c-0.1", "lib.rs"])),
|
||||
writeFile(&b_workspace.join_many(["src", "c-0.1", "lib.rs"])),
|
||||
"pub fn g() {}");
|
||||
let a_workspace = create_local_package(&a_id);
|
||||
let a_workspace = a_workspace.path();
|
||||
writeFile(&a_workspace.join_many_str(["src", "a-0.1", "main.rs"]),
|
||||
writeFile(&a_workspace.join_many(["src", "a-0.1", "main.rs"]),
|
||||
"extern mod b; use b::f; fn main() { f(); }");
|
||||
writeFile(&b_workspace.join_many_str(["src", "b-0.1", "lib.rs"]),
|
||||
writeFile(&b_workspace.join_many(["src", "b-0.1", "lib.rs"]),
|
||||
"extern mod c; use c::g; pub fn f() { g(); }");
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let environment = Some(~[(~"RUST_PATH", b_workspace.as_str().unwrap().to_owned())]);
|
||||
|
|
@ -1827,9 +1823,9 @@ fn test_recursive_deps() {
|
|||
command_line_test_with_env([~"install", ~"a"],
|
||||
a_workspace,
|
||||
environment);
|
||||
assert_lib_exists(a_workspace, &Path::from_str("a"), NoVersion);
|
||||
assert_lib_exists(b_workspace, &Path::from_str("b"), NoVersion);
|
||||
assert_lib_exists(b_workspace, &Path::from_str("c"), NoVersion);
|
||||
assert_lib_exists(a_workspace, &Path::new("a"), NoVersion);
|
||||
assert_lib_exists(b_workspace, &Path::new("b"), NoVersion);
|
||||
assert_lib_exists(b_workspace, &Path::new("c"), NoVersion);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1837,7 +1833,7 @@ fn test_install_to_rust_path() {
|
|||
let p_id = PkgId::new("foo");
|
||||
let second_workspace = create_local_package(&p_id);
|
||||
let second_workspace = second_workspace.path();
|
||||
let first_workspace = mk_empty_workspace(&Path::from_str("p"), &NoVersion, "dest");
|
||||
let first_workspace = mk_empty_workspace(&Path::new("p"), &NoVersion, "dest");
|
||||
let first_workspace = first_workspace.path();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let rust_path = Some(~[(~"RUST_PATH",
|
||||
|
|
@ -1869,7 +1865,7 @@ fn test_target_specific_build_dir() {
|
|||
workspace);
|
||||
assert!(os::path_is_dir(&target_build_dir(workspace)));
|
||||
assert!(built_executable_exists(workspace, "foo"));
|
||||
assert!(os::list_dir(&workspace.join_str("build")).len() == 1);
|
||||
assert!(os::list_dir(&workspace.join("build")).len() == 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1883,10 +1879,10 @@ fn test_target_specific_install_dir() {
|
|||
~"install",
|
||||
~"foo"],
|
||||
workspace);
|
||||
assert!(os::path_is_dir(&workspace.join_many_str(["lib", host_triple()])));
|
||||
assert_lib_exists(workspace, &Path::from_str("foo"), NoVersion);
|
||||
assert!(os::list_dir(&workspace.join_str("lib")).len() == 1);
|
||||
assert!(os::path_is_dir(&workspace.join_str("bin")));
|
||||
assert!(os::path_is_dir(&workspace.join_many(["lib", host_triple()])));
|
||||
assert_lib_exists(workspace, &Path::new("foo"), NoVersion);
|
||||
assert!(os::list_dir(&workspace.join("lib")).len() == 1);
|
||||
assert!(os::path_is_dir(&workspace.join("bin")));
|
||||
assert_executable_exists(workspace, "foo");
|
||||
}
|
||||
|
||||
|
|
@ -1896,10 +1892,10 @@ fn test_dependencies_terminate() {
|
|||
let b_id = PkgId::new("b");
|
||||
let workspace = create_local_package(&b_id);
|
||||
let workspace = workspace.path();
|
||||
let b_dir = workspace.join_many_str(["src", "b-0.1"]);
|
||||
let b_subdir = b_dir.join_str("test");
|
||||
let b_dir = workspace.join_many(["src", "b-0.1"]);
|
||||
let b_subdir = b_dir.join("test");
|
||||
assert!(os::mkdir_recursive(&b_subdir, U_RWX));
|
||||
writeFile(&b_subdir.join_str("test.rs"),
|
||||
writeFile(&b_subdir.join("test.rs"),
|
||||
"extern mod b; use b::f; #[test] fn g() { f() }");
|
||||
command_line_test([~"install", ~"b"], workspace);
|
||||
}
|
||||
|
|
@ -1960,13 +1956,13 @@ fn correct_package_name_with_rust_path_hack() {
|
|||
let bar_id = PkgId::new("bar");
|
||||
let foo_workspace = create_local_package(&foo_id);
|
||||
let foo_workspace = foo_workspace.path();
|
||||
let dest_workspace = mk_empty_workspace(&Path::from_str("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||
let dest_workspace = dest_workspace.path();
|
||||
|
||||
writeFile(&dest_workspace.join_many_str(["src", "bar-0.1", "main.rs"]),
|
||||
writeFile(&dest_workspace.join_many(["src", "bar-0.1", "main.rs"]),
|
||||
"extern mod blat; fn main() { let _x = (); }");
|
||||
|
||||
let foo_path = foo_workspace.join_many_str(["src", "foo-0.1"]);
|
||||
let foo_path = foo_workspace.join_many(["src", "foo-0.1"]);
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let rust_path = Some(~[(~"RUST_PATH", format!("{}:{}", dest_workspace.as_str().unwrap(),
|
||||
foo_path.as_str().unwrap()))]);
|
||||
|
|
@ -1989,7 +1985,7 @@ fn test_rustpkg_test_creates_exec() {
|
|||
let foo_id = PkgId::new("foo");
|
||||
let foo_workspace = create_local_package(&foo_id);
|
||||
let foo_workspace = foo_workspace.path();
|
||||
writeFile(&foo_workspace.join_many_str(["src", "foo-0.1", "test.rs"]),
|
||||
writeFile(&foo_workspace.join_many(["src", "foo-0.1", "test.rs"]),
|
||||
"#[test] fn f() { assert!('a' == 'a'); }");
|
||||
command_line_test([~"test", ~"foo"], foo_workspace);
|
||||
assert!(test_executable_exists(foo_workspace, "foo"));
|
||||
|
|
@ -2013,7 +2009,7 @@ fn test_rebuild_when_needed() {
|
|||
let foo_id = PkgId::new("foo");
|
||||
let foo_workspace = create_local_package(&foo_id);
|
||||
let foo_workspace = foo_workspace.path();
|
||||
let test_crate = foo_workspace.join_many_str(["src", "foo-0.1", "test.rs"]);
|
||||
let test_crate = foo_workspace.join_many(["src", "foo-0.1", "test.rs"]);
|
||||
writeFile(&test_crate, "#[test] fn f() { assert!('a' == 'a'); }");
|
||||
command_line_test([~"test", ~"foo"], foo_workspace);
|
||||
assert!(test_executable_exists(foo_workspace, "foo"));
|
||||
|
|
@ -2033,7 +2029,7 @@ fn test_no_rebuilding() {
|
|||
let foo_id = PkgId::new("foo");
|
||||
let foo_workspace = create_local_package(&foo_id);
|
||||
let foo_workspace = foo_workspace.path();
|
||||
let test_crate = foo_workspace.join_many_str(["src", "foo-0.1", "test.rs"]);
|
||||
let test_crate = foo_workspace.join_many(["src", "foo-0.1", "test.rs"]);
|
||||
writeFile(&test_crate, "#[test] fn f() { assert!('a' == 'a'); }");
|
||||
command_line_test([~"test", ~"foo"], foo_workspace);
|
||||
assert!(test_executable_exists(foo_workspace, "foo"));
|
||||
|
|
@ -2058,16 +2054,16 @@ fn test_installed_read_only() {
|
|||
let repo_subdir = repo.join_many_str(["mockgithub.com", "catamorphism", "test-pkg"]);
|
||||
debug2!("repo_subdir = {}", repo_subdir.display());
|
||||
|
||||
writeFile(&repo_subdir.join_str("main.rs"),
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("lib.rs"),
|
||||
writeFile(&repo_subdir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files
|
||||
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
command_line_test([~"install", temp_pkg_id.path.as_str().unwrap().to_owned()], repo);
|
||||
|
||||
let ws = repo.join_str(".rust");
|
||||
let ws = repo.join(".rust");
|
||||
// Check that all files exist
|
||||
debug2!("Checking for files in {}", ws.display());
|
||||
let exec = target_executable_in_workspace(&temp_pkg_id, &ws);
|
||||
|
|
@ -2099,9 +2095,9 @@ fn test_installed_local_changes() {
|
|||
debug2!("repo_subdir = {}", repo_subdir.display());
|
||||
assert!(os::mkdir_recursive(&repo.join_many_str([".rust", "src"]), U_RWX));
|
||||
|
||||
writeFile(&repo_subdir.join_str("main.rs"),
|
||||
writeFile(&repo_subdir.join("main.rs"),
|
||||
"fn main() { let _x = (); }");
|
||||
writeFile(&repo_subdir.join_str("lib.rs"),
|
||||
writeFile(&repo_subdir.join("lib.rs"),
|
||||
"pub fn f() { let _x = (); }");
|
||||
add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files
|
||||
|
||||
|
|
@ -2127,13 +2123,13 @@ fn test_installed_local_changes() {
|
|||
};
|
||||
|
||||
// Make a local change to it
|
||||
writeFile(&target_dir.join_str("lib.rs"),
|
||||
writeFile(&target_dir.join("lib.rs"),
|
||||
"pub fn g() { let _x = (); }");
|
||||
|
||||
// Finally, make *another* package that uses it
|
||||
let importer_pkg_id = fake_pkg();
|
||||
let main_subdir = create_local_package_in(&importer_pkg_id, hacking_workspace);
|
||||
writeFile(&main_subdir.join_str("main.rs"),
|
||||
writeFile(&main_subdir.join("main.rs"),
|
||||
"extern mod test = \"mockgithub.com/catamorphism/test-pkg\"; \
|
||||
use test::g;
|
||||
fn main() { g(); }");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue