filter out glob members from workspace

This commit is contained in:
Sam Rijs 2018-02-11 18:53:26 +11:00
parent 4158889161
commit b0c77b4446
2 changed files with 26 additions and 7 deletions

View file

@ -42,16 +42,20 @@ impl ManifestCrawler {
},
CrateManifest::Workspace { members } => {
for mut member in members {
if !member.ends_with("*") {
output.paths_of_interest.push(path.clone().join(member));
}
}
},
CrateManifest::Mixed { name, deps, members } => {
self.leaf_crates.insert(name, deps);
for mut member in members {
if !member.ends_with("*") {
output.paths_of_interest.push(path.clone().join(member));
}
}
}
}
Ok(output)
}
@ -134,6 +138,21 @@ members = [
assert_eq!(step_output.paths_of_interest[2].to_str().unwrap(), "/contrib/");
}
#[test]
fn glob_workspace_manifest() {
let manifest = r#"
[workspace]
members = [
"lib/",
"tests/*",
]
"#;
let mut crawler = ManifestCrawler::new();
let step_output = crawler.step("/".into(), manifest.to_string()).unwrap();
assert_eq!(step_output.paths_of_interest.len(), 1);
assert_eq!(step_output.paths_of_interest[0].to_str().unwrap(), "/lib/");
}
#[test]
fn mixed_package_and_workspace_manifest() {
let futures_manifest = r#"

View file

@ -2,7 +2,7 @@ use std::path::Path;
use failure::Error;
use futures::{Future, IntoFuture, Stream, future};
use hyper::{Error as HyperError, Method, Request, Response};
use hyper::{Error as HyperError, Method, Request, Response, Uri};
use hyper::header::UserAgent;
use tokio_service::Service;
use serde_json;
@ -22,15 +22,15 @@ pub fn retrieve_file_at_path<S, P: AsRef<Path>>(service: S, repo_path: &RepoPath
repo_path.qual.as_ref(),
repo_path.name.as_ref(),
path_str
).parse().into_future().from_err();
).parse::<Uri>().into_future().from_err();
uri_future.and_then(move |uri| {
let request = Request::new(Method::Get, uri);
let request = Request::new(Method::Get, uri.clone());
service.call(request).from_err().and_then(|response| {
service.call(request).from_err().and_then(move |response| {
let status = response.status();
if !status.is_success() {
future::Either::A(future::err(format_err!("Status code: {}", status)))
future::Either::A(future::err(format_err!("Status code {} for URI {}", status, uri)))
} else {
let body_future = response.body().concat2().from_err();
let decode_future = body_future