mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
parent
f624095e1c
commit
c262f100ec
@ -4,8 +4,8 @@ use crate::util::errors::CargoResult;
|
|||||||
use crate::util::{Config, Filesystem};
|
use crate::util::{Config, Filesystem};
|
||||||
use cargo_util::{paths, Sha256};
|
use cargo_util::{paths, Sha256};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::io::SeekFrom;
|
use std::io::SeekFrom;
|
||||||
|
use std::io::{self, prelude::*};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
|
|
||||||
@ -54,8 +54,17 @@ impl<'cfg> RegistryData for LocalRegistry<'cfg> {
|
|||||||
_index_version: Option<&str>,
|
_index_version: Option<&str>,
|
||||||
) -> Poll<CargoResult<LoadResponse>> {
|
) -> Poll<CargoResult<LoadResponse>> {
|
||||||
if self.updated {
|
if self.updated {
|
||||||
|
let raw_data = match paths::read_bytes(&root.join(path)) {
|
||||||
|
Err(e)
|
||||||
|
if e.downcast_ref::<io::Error>()
|
||||||
|
.map_or(false, |ioe| ioe.kind() == io::ErrorKind::NotFound) =>
|
||||||
|
{
|
||||||
|
return Poll::Ready(Ok(LoadResponse::NotFound));
|
||||||
|
}
|
||||||
|
r => r,
|
||||||
|
}?;
|
||||||
Poll::Ready(Ok(LoadResponse::Data {
|
Poll::Ready(Ok(LoadResponse::Data {
|
||||||
raw_data: paths::read_bytes(&root.join(path))?,
|
raw_data,
|
||||||
index_version: None,
|
index_version: None,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,6 +62,44 @@ fn simple() {
|
|||||||
p.cargo("test").run();
|
p.cargo("test").run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn not_found() {
|
||||||
|
setup();
|
||||||
|
// Publish a package so that the directory hierarchy is created.
|
||||||
|
// Note, however, that we declare a dependency on baZ.
|
||||||
|
Package::new("bar", "0.0.1").local(true).publish();
|
||||||
|
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[project]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
baz = "0.0.1"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file(
|
||||||
|
"src/lib.rs",
|
||||||
|
"extern crate baz; pub fn foo() { baz::bar(); }",
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
[ERROR] no matching package named `baz` found
|
||||||
|
location searched: registry `crates-io`
|
||||||
|
required by package `foo v0.0.1 ([..]/foo)`
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn depend_on_yanked() {
|
fn depend_on_yanked() {
|
||||||
setup();
|
setup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user