From 91186e8c5819b4d0dae25d82c574d0402e7c4052 Mon Sep 17 00:00:00 2001 From: Lukas Lueg Date: Sun, 7 Jul 2019 22:29:13 +0200 Subject: [PATCH] Remove byteorder-dependency --- Cargo.toml | 1 - tests/testsuite/support/publish.rs | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1eed40489..2592905ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ path = "src/cargo/lib.rs" [dependencies] atty = "0.2" -byteorder = "1.2" bytesize = "1.0" crates-io = { path = "crates/crates-io", version = "0.27" } crossbeam-utils = "0.6" diff --git a/tests/testsuite/support/publish.rs b/tests/testsuite/support/publish.rs index d8a0d5a31..0230aa638 100644 --- a/tests/testsuite/support/publish.rs +++ b/tests/testsuite/support/publish.rs @@ -1,15 +1,23 @@ use std::collections::{HashMap, HashSet}; use std::fs::File; -use std::io::{prelude::*, SeekFrom}; +use std::io::{self, prelude::*, SeekFrom}; use std::path::{Path, PathBuf}; use crate::support::find_json_mismatch; use crate::support::registry::{self, alt_api_path}; -use byteorder::{LittleEndian, ReadBytesExt}; use flate2::read::GzDecoder; use tar::Archive; +fn read_le_u32(mut reader: R) -> io::Result +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. 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"); @@ -44,7 +52,7 @@ fn _validate_upload( ) { let mut f = File::open(new_path).unwrap(); // 32-bit little-endian integer of length of JSON data. - let json_sz = f.read_u32::().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]; 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"); @@ -53,7 +61,7 @@ fn _validate_upload( .expect("uploaded JSON did not match expected JSON"); // 32-bit little-endian integer of length of crate file. - let crate_sz = f.read_u32::().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]; f.read_exact(&mut krate_bytes).expect("read crate data"); // Check at end.