Merge pull request #31 from alexcrichton/hotfix-windows2

Work around \-characters on Windows for now
This commit is contained in:
Yehuda Katz 2014-06-23 22:49:11 -07:00
commit d9a6af02a0
4 changed files with 14 additions and 5 deletions

@ -1 +1 @@
Subproject commit ed88ef0b8151277cc6a876f2daaeb1c63420717b
Subproject commit b663d6ae99294a0825f4e1b11c5b3110d56bc65f

View file

@ -87,7 +87,12 @@ impl SourceId {
// Pass absolute path
pub fn for_path(path: &Path) -> SourceId {
// TODO: use proper path -> URL
let url = format!("file://{}", path.display());
let url = if cfg!(windows) {
let path = path.display().to_str();
format!("file://{}", path.as_slice().replace("\\", "/"))
} else {
format!("file://{}", path.display())
};
SourceId::new(PathKind, url::from_str(url.as_slice()).unwrap())
}
@ -119,7 +124,11 @@ impl SourceId {
match self.kind {
GitKind(..) => box GitSource::new(self, config) as Box<Source>,
PathKind => {
let path = Path::new(self.url.path.as_slice());
let mut path = self.url.path.clone();
if cfg!(windows) {
path = path.replace("/", "\\");
}
let path = Path::new(path);
box PathSource::new(&path, self) as Box<Source>
},
RegistryKind => unimplemented!()

View file

@ -37,7 +37,7 @@ pub fn parse(toml: &str, file: &str) -> CargoResult<toml::Table> {
for error in parser.errors.iter() {
let (loline, locol) = parser.to_linecol(error.lo);
let (hiline, hicol) = parser.to_linecol(error.hi);
error_str.push_str(format!("{}:{}:{}{} {}",
error_str.push_str(format!("{}:{}:{}{} {}\n",
file,
loline + 1, locol + 1,
if loline != hiline || locol != hicol {

View file

@ -62,7 +62,7 @@ test!(cargo_compile_with_invalid_manifest2 {
execs()
.with_status(101)
.with_stderr("could not parse input TOML\n\
Cargo.toml:3:19-3:20 expected a value\n"))
Cargo.toml:3:19-3:20 expected a value\n\n"))
})
test!(cargo_compile_without_manifest {