mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Auto merge of #7106 - lukaslueg:master, r=ehuss
Update dependencies This removes the `byteorder`-dependency, which was used in a few tests only anyway and is not needed since 1.32; also removes the `derive`-feature from the `failure`-crate, which is not needed also.
This commit is contained in:
commit
677a180f4c
@ -19,7 +19,6 @@ path = "src/cargo/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
byteorder = "1.2"
|
|
||||||
bytesize = "1.0"
|
bytesize = "1.0"
|
||||||
crates-io = { path = "crates/crates-io", version = "0.27" }
|
crates-io = { path = "crates/crates-io", version = "0.27" }
|
||||||
crossbeam-utils = "0.6"
|
crossbeam-utils = "0.6"
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{prelude::*, SeekFrom};
|
use std::io::{self, prelude::*, SeekFrom};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::support::find_json_mismatch;
|
use crate::support::find_json_mismatch;
|
||||||
use crate::support::registry::{self, alt_api_path};
|
use crate::support::registry::{self, alt_api_path};
|
||||||
|
|
||||||
use byteorder::{LittleEndian, ReadBytesExt};
|
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use tar::Archive;
|
use tar::Archive;
|
||||||
|
|
||||||
|
fn read_le_u32<R>(mut reader: R) -> io::Result<u32>
|
||||||
|
where
|
||||||
|
R: Read,
|
||||||
|
{
|
||||||
|
let mut buf = [0; 4];
|
||||||
|
reader.read_exact(&mut buf)?;
|
||||||
|
Ok(u32::from_le_bytes(buf))
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks the result of a crate publish.
|
/// Checks the result of a crate publish.
|
||||||
pub fn validate_upload(expected_json: &str, expected_crate_name: &str, expected_files: &[&str]) {
|
pub fn validate_upload(expected_json: &str, expected_crate_name: &str, expected_files: &[&str]) {
|
||||||
let new_path = registry::api_path().join("api/v1/crates/new");
|
let new_path = registry::api_path().join("api/v1/crates/new");
|
||||||
@ -44,7 +52,7 @@ fn _validate_upload(
|
|||||||
) {
|
) {
|
||||||
let mut f = File::open(new_path).unwrap();
|
let mut f = File::open(new_path).unwrap();
|
||||||
// 32-bit little-endian integer of length of JSON data.
|
// 32-bit little-endian integer of length of JSON data.
|
||||||
let json_sz = f.read_u32::<LittleEndian>().expect("read json length");
|
let json_sz = read_le_u32(&mut f).expect("read json length");
|
||||||
let mut json_bytes = vec![0; json_sz as usize];
|
let mut json_bytes = vec![0; json_sz as usize];
|
||||||
f.read_exact(&mut json_bytes).expect("read JSON data");
|
f.read_exact(&mut json_bytes).expect("read JSON data");
|
||||||
let actual_json = serde_json::from_slice(&json_bytes).expect("uploaded JSON should be valid");
|
let actual_json = serde_json::from_slice(&json_bytes).expect("uploaded JSON should be valid");
|
||||||
@ -53,7 +61,7 @@ fn _validate_upload(
|
|||||||
.expect("uploaded JSON did not match expected JSON");
|
.expect("uploaded JSON did not match expected JSON");
|
||||||
|
|
||||||
// 32-bit little-endian integer of length of crate file.
|
// 32-bit little-endian integer of length of crate file.
|
||||||
let crate_sz = f.read_u32::<LittleEndian>().expect("read crate length");
|
let crate_sz = read_le_u32(&mut f).expect("read crate length");
|
||||||
let mut krate_bytes = vec![0; crate_sz as usize];
|
let mut krate_bytes = vec![0; crate_sz as usize];
|
||||||
f.read_exact(&mut krate_bytes).expect("read crate data");
|
f.read_exact(&mut krate_bytes).expect("read crate data");
|
||||||
// Check at end.
|
// Check at end.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user