Skip to content

Commit

Permalink
Auto merge of #7063 - matthiaskrgr:travis_fmt, r=alexcrichton
Browse files Browse the repository at this point in the history
travis: enforce formatting of subcrates as well
  • Loading branch information
bors committed Jun 23, 2019
2 parents ecc41f4 + 51a56a4 commit 1d8ac3c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ matrix:
- rustup component add rustfmt
script:
- cargo fmt --all -- --check
- cd crates/cargo-test-macro
- cargo fmt --all -- --check
- cd ../crates-io
- cargo fmt --all -- --check
- cd ../resolver-tests
- cargo fmt --all -- --check
- cd ../../

- env: TARGET=x86_64-unknown-linux-gnu
ALT=i686-unknown-linux-gnu
Expand Down
6 changes: 4 additions & 2 deletions crates/cargo-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate proc_macro;

use quote::{quote, ToTokens};
use syn::{*, parse::Parser};
use syn::{parse::Parser, *};

#[proc_macro_attribute]
pub fn cargo_test(
Expand All @@ -13,7 +13,9 @@ pub fn cargo_test(
let attr = quote! {
#[test]
};
fn_def.attrs.extend(Attribute::parse_outer.parse2(attr).unwrap());
fn_def
.attrs
.extend(Attribute::parse_outer.parse2(attr).unwrap());

let stmt = quote! {
let _test_guard = crate::support::paths::init_root();
Expand Down
32 changes: 18 additions & 14 deletions crates/crates-io/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ impl Registry {
(json.len() >> 8) as u8,
(json.len() >> 16) as u8,
(json.len() >> 24) as u8,
].iter().cloned(),
]
.iter()
.cloned(),
);
w.extend(json.as_bytes().iter().cloned());
w.extend(
Expand All @@ -194,7 +196,9 @@ impl Registry {
(stat.len() >> 8) as u8,
(stat.len() >> 16) as u8,
(stat.len() >> 24) as u8,
].iter().cloned(),
]
.iter()
.cloned(),
);
w
};
Expand Down Expand Up @@ -337,17 +341,17 @@ impl Registry {
Ok(body) => body,
Err(..) => bail!("response body was not valid utf-8"),
};
let errors = serde_json::from_str::<ApiErrorList>(&body).ok().map(|s| {
s.errors.into_iter().map(|s| s.detail).collect::<Vec<_>>()
});
let errors = serde_json::from_str::<ApiErrorList>(&body)
.ok()
.map(|s| s.errors.into_iter().map(|s| s.detail).collect::<Vec<_>>());

match (self.handle.response_code()?, errors) {
(0, None) | (200, None) => {},
(503, None) if started.elapsed().as_secs() >= 29 && self.host_is_crates_io() => {
bail!("Request timed out after 30 seconds. If you're trying to \
upload a crate it may be too large. If the crate is under \
10MB in size, you can email [email protected] for assistance.")
}
(0, None) | (200, None) => {}
(503, None) if started.elapsed().as_secs() >= 29 && self.host_is_crates_io() => bail!(
"Request timed out after 30 seconds. If you're trying to \
upload a crate it may be too large. If the crate is under \
10MB in size, you can email [email protected] for assistance."
),
(code, Some(errors)) => {
let code = StatusCode::from_u16(code as _)?;
bail!("api errors (status {}): {}", code, errors.join(", "))
Expand All @@ -358,9 +362,9 @@ impl Registry {
\t{}\n\
body:\n\
{}",
code,
headers.join("\n\t"),
body,
code,
headers.join("\n\t"),
body,
),
}

Expand Down

0 comments on commit 1d8ac3c

Please sign in to comment.