From d2e5059ab90e1e83f5214bc0ec09ead6a257ffb8 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 16 Sep 2016 16:34:50 -0700 Subject: [PATCH] Remove unnecessary external dependencies. The main libcretonne crate should not have any external dependencies if at all possible. Use simple substring matching instead of regular expressions in the verifier tests to achieve this. The tools crate no longer depends directly on glob and regex. It still has an indirect dependency on regex through libfilecheck. --- src/libcretonne/Cargo.toml | 5 ++++- src/libcretonne/verifier.rs | 10 +++------- src/tools/Cargo.lock | 10 ---------- src/tools/Cargo.toml | 2 -- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/libcretonne/Cargo.toml b/src/libcretonne/Cargo.toml index 5d3a9511e6..174fb2e0bf 100644 --- a/src/libcretonne/Cargo.toml +++ b/src/libcretonne/Cargo.toml @@ -13,4 +13,7 @@ name = "cretonne" path = "lib.rs" [dependencies] -regex = "0.1.71" +# It is a goal of the cretonne crate to have minimal external dependencies. +# Please don't add any unless they are essential to the task of creating binary +# machine code. Integration tests that need external dependencies can be +# accomodated in src/tools/tests. diff --git a/src/libcretonne/verifier.rs b/src/libcretonne/verifier.rs index d58283e3ae..2b544967e2 100644 --- a/src/libcretonne/verifier.rs +++ b/src/libcretonne/verifier.rs @@ -165,22 +165,18 @@ impl<'a> Verifier<'a> { #[cfg(test)] mod tests { - extern crate regex; - use super::*; use ir::Function; use ir::instructions::{InstructionData, Opcode}; use ir::types; - use self::regex::Regex; macro_rules! assert_err_with_msg { ($e:expr, $msg:expr) => ( - let err_re = Regex::new($msg).unwrap(); match $e { Ok(_) => { panic!("Expected an error!") }, - Err(Error { location, message } ) => { - if !err_re.is_match(&message) { - panic!(format!("'{}' did not contain the pattern '{}'", message, $msg)); + Err(Error { message, .. } ) => { + if !message.contains($msg) { + panic!(format!("'{}' did not contain the substring '{}'", message, $msg)); } } } diff --git a/src/tools/Cargo.lock b/src/tools/Cargo.lock index 2aca3c591b..50576fd02b 100644 --- a/src/tools/Cargo.lock +++ b/src/tools/Cargo.lock @@ -6,8 +6,6 @@ dependencies = [ "cretonne-reader 0.0.0", "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "filecheck 0.0.0", - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -22,9 +20,6 @@ dependencies = [ [[package]] name = "cretonne" version = "0.0.0" -dependencies = [ - "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "cretonne-reader" @@ -50,11 +45,6 @@ dependencies = [ "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "glob" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "kernel32-sys" version = "0.2.2" diff --git a/src/tools/Cargo.toml b/src/tools/Cargo.toml index ba465f7d0e..b4572f9f49 100644 --- a/src/tools/Cargo.toml +++ b/src/tools/Cargo.toml @@ -15,5 +15,3 @@ cretonne-reader = { path = "../libreader" } filecheck = { path = "../libfilecheck" } docopt = "0.6.80" rustc-serialize = "0.3.19" -regex = "0.1.71" -glob = "0.2.11"