Skip to content

Commit 3c86711

Browse files
committed
Fix some tests in rustpkg to not pollute the build directory. Closes #7278.
1 parent 13e5f0e commit 3c86711

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/librustpkg/tests.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ fn output_file_name(workspace: &Path, short_name: &str) -> Path {
268268
workspace.push(fmt!("%s%s", short_name, os::EXE_SUFFIX))
269269
}
270270

271-
fn touch_source_file(workspace: &Path, short_name: &str) {
271+
fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
272272
use conditions::bad_path::cond;
273-
let pkg_src_dir = workspace.push("src").push(short_name);
274-
let contents = os::list_dir(&pkg_src_dir);
273+
let pkg_src_dir = workspace.push("src").push(pkgid.to_str());
274+
let contents = os::list_dir_path(&pkg_src_dir);
275275
for contents.iter().advance |p| {
276-
if Path(copy *p).filetype() == Some(~".rs") {
276+
if p.filetype() == Some(~".rs") {
277277
// should be able to do this w/o a process
278278
if run::process_output("touch", [p.to_str()]).status != 0 {
279279
let _ = cond.raise((copy pkg_src_dir, ~"Bad path"));
@@ -287,20 +287,19 @@ fn touch_source_file(workspace: &Path, short_name: &str) {
287287
fn frob_source_file(workspace: &Path, pkgid: &PkgId) {
288288
use conditions::bad_path::cond;
289289
let pkg_src_dir = workspace.push("src").push(pkgid.to_str());
290-
let contents = os::list_dir(&pkg_src_dir);
290+
let contents = os::list_dir_path(&pkg_src_dir);
291291
let mut maybe_p = None;
292292
for contents.iter().advance |p| {
293-
if Path(copy *p).filetype() == Some(~".rs") {
293+
if p.filetype() == Some(~".rs") {
294294
maybe_p = Some(p);
295295
break;
296296
}
297297
}
298298
match maybe_p {
299299
Some(p) => {
300-
let p = Path(copy *p);
301-
let w = io::buffered_file_writer(&p);
300+
let w = io::file_writer(*p, &[io::Append]);
302301
match w {
303-
Err(s) => { let _ = cond.raise((p, fmt!("Bad path: %s", s))); }
302+
Err(s) => { let _ = cond.raise((copy **p, fmt!("Bad path: %s", s))); }
304303
Ok(w) => w.write_line("")
305304
}
306305
}
@@ -615,7 +614,7 @@ fn do_rebuild_dep_dates_change() {
615614
let workspace = create_local_package_with_dep(&p_id, &dep_id);
616615
command_line_test([~"build", ~"foo"], &workspace);
617616
let bar_date = datestamp(&lib_output_file_name(&workspace, "build", "bar"));
618-
touch_source_file(&workspace, "bar");
617+
touch_source_file(&workspace, &dep_id);
619618
command_line_test([~"build", ~"foo"], &workspace);
620619
let new_bar_date = datestamp(&lib_output_file_name(&workspace, "build", "bar"));
621620
assert!(new_bar_date > bar_date);

0 commit comments

Comments
 (0)