Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustpkg: tests, and doing inference properly #5920

Closed
wants to merge 9 commits into from
21 changes: 20 additions & 1 deletion src/librustpkg/path_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// rustpkg utilities having to do with paths and directories

use core::path::*;
use core::os;
use core::{os, str};
use core::option::*;
use util::PkgId;

/// Returns the output directory to use.
Expand Down Expand Up @@ -50,6 +51,24 @@ pub fn default_dest_dir(pkg_dir: &Path) -> Path {
}
}

/// Replace all occurrences of '-' in the stem part of path with '_'
/// This is because we treat rust-foo-bar-quux and rust_foo_bar_quux
/// as the same name
pub fn normalize(p: ~Path) -> ~Path {
match p.filestem() {
None => p,
Some(st) => {
let replaced = str::replace(st, "-", "_");
if replaced != st {
~p.with_filestem(replaced)
}
else {
p
}
}
}
}

#[cfg(test)]
mod test {
use core::{os, rand};
Expand Down
Loading