Skip to content

Commit

Permalink
testsuite: Add a test for listing the root directory...
Browse files Browse the repository at this point in the history
...and don't treat Path("/") like Path("").
  • Loading branch information
catamorphism committed May 26, 2013
1 parent 196851c commit a243ea3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ pub fn mkdir_recursive(p: &Path, mode: c_int) -> bool {
/// Lists the contents of a directory
#[allow(non_implicitly_copyable_typarams)]
pub fn list_dir(p: &Path) -> ~[~str] {
if p.components.is_empty() {
if p.components.is_empty() && !p.is_absolute() {
// Not sure what the right behavior is here, but this
// prevents a bounds check failure later
return ~[];
Expand Down Expand Up @@ -1607,6 +1607,20 @@ mod tests {
assert!(dirs.is_empty());
}

#[test]
#[cfg(not(windows))]
fn list_dir_root() {
let dirs = os::list_dir(&Path("/"));
assert!(dirs.len() > 1);
}
#[test]
#[cfg(windows)]
fn list_dir_root() {
let dirs = os::list_dir(&Path("C:\\"));
assert!(dirs.len() > 1);
}


#[test]
fn path_is_dir() {
assert!((os::path_is_dir(&Path("."))));
Expand Down

5 comments on commit a243ea3

@bors
Copy link
Contributor

@bors bors commented on a243ea3 May 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from catamorphism
at catamorphism@a243ea3

@bors
Copy link
Contributor

@bors bors commented on a243ea3 May 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging catamorphism/rust/list_dir_empty = a243ea3 into auto

@bors
Copy link
Contributor

@bors bors commented on a243ea3 May 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catamorphism/rust/list_dir_empty = a243ea3 merged ok, testing candidate = 510d0f2

@bors
Copy link
Contributor

@bors bors commented on a243ea3 May 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a243ea3 May 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 510d0f2

Please sign in to comment.