From 007da592750bc076c0e26fe1903da8345d2a8c52 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 29 Dec 2015 14:51:26 +0100 Subject: [PATCH 1/4] Add travis.yml --- .travis.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..487b4a19 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +sudo: false +language: rust +rust: + - beta + - nightly + - stable + +matrix: + allow_failures: + - rust: nightly + +before_script: + - | + pip install 'travis-cargo<0.2' --user && + export PATH=$HOME/.local/bin:$PATH + +script: + - | + travis-cargo build && + travis-cargo test && + travis-cargo bench && + travis-cargo --only stable doc + +addons: + apt: + packages: + - libcurl4-openssl-dev + - libelf-dev + - libdw-dev + +after_success: + - travis-cargo --only stable doc-upload + - travis-cargo coveralls --no-sudo + +notifications: + email: + on_success: never + +env: + global: + - TRAVIS_CARGO_NIGHTLY_FEATURE=dev From b5da0cb613f5f68154100d8de019276feb4a6c22 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 29 Dec 2015 15:01:35 +0100 Subject: [PATCH 2/4] Fix use... in test modules --- src/storage/file/id.rs | 3 ++- src/storage/file/mod.rs | 6 +++--- src/storage/json/parser.rs | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index 3c8ddf36..8c5e121c 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -113,7 +113,8 @@ impl Into for FileID { #[cfg(test)] mod test { - use super::{FileID, FileIDType}; + use storage::file::id::FileID; + use storage::file::id_type::FileIDType; #[test] fn file_id_from_string() { diff --git a/src/storage/file/mod.rs b/src/storage/file/mod.rs index 16a072ef..61a7f749 100644 --- a/src/storage/file/mod.rs +++ b/src/storage/file/mod.rs @@ -100,10 +100,10 @@ impl Debug for File { mod test { // we use the JSON parser here, so we can generate FileHeaderData use storage::json::parser::JsonHeaderParser; - use super::match_header_spec; + use storage::file::header::match_header_spec; use storage::parser::{FileHeaderParser, ParserError}; - use storage::file::FileHeaderData as FHD; - use storage::file::FileHeaderSpec as FHS; + use storage::file::header::data::FileHeaderData as FHD; + use storage::file::header::spec::FileHeaderSpec as FHS; #[test] fn test_spec_matching() { diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 7011b6c2..8a76436b 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -150,8 +150,8 @@ mod test { use super::JsonHeaderParser; use storage::parser::{FileHeaderParser, ParserError}; - use storage::file::FileHeaderData as FHD; - use storage::file::FileHeaderSpec as FHS; + use storage::file::header::data::FileHeaderData as FHD; + use storage::file::header::spec::FileHeaderSpec as FHS; #[test] fn test_deserialization() { From e21da820c44157ac0df462f7856f66437166e269 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 29 Dec 2015 15:05:39 +0100 Subject: [PATCH 3/4] Fix test for to use FileID::parse() --- src/storage/file/id.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/storage/file/id.rs b/src/storage/file/id.rs index 8c5e121c..c274077e 100644 --- a/src/storage/file/id.rs +++ b/src/storage/file/id.rs @@ -124,25 +124,27 @@ mod test { let s2 = String::from("/home/user/testmodule-UUID-some-id.extension.imag"); let s3 = String::from("/home/user/testmodule-NOHASH-some-id.imag"); - let id1 = FileID::from(s1); - let id2 = FileID::from(s2); - let id3 = FileID::from(s3); + let id1 = FileID::parse(&s1).unwrap(); + let id2 = FileID::parse(&s2).unwrap(); + assert!(FileID::parse(&s3).is_none()); println!("Id 1 : {:?}", id1); println!("Id 2 : {:?}", id2); - println!("Id 3 : {:?}", id3); assert_eq!(FileIDType::UUID, id1.get_type()); assert_eq!(FileIDType::UUID, id2.get_type()); - assert_eq!(FileIDType::NONE, id3.get_type()); + + let h1 : String = id1.get_id().into(); + let h2 : String = id2.get_id().into(); + + assert_eq!(String::from("some-id"), h1); + assert_eq!(String::from("some-id"), h2); let f1 : String = id1.into(); let f2 : String = id2.into(); - let f3 : String = id3.into(); - assert_eq!(String::from("some-id"), f1); - assert_eq!(String::from("some-id"), f2); - assert_eq!(String::from("INVALID"), f3); + assert_eq!(String::from("UUID-some-id"), f1); + assert_eq!(String::from("UUID-some-id"), f2); } fn setup_logger() { From e3b22d488d441a8b7560d06dd38788439a751189 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 29 Dec 2015 15:05:44 +0100 Subject: [PATCH 4/4] Remove box-syntax in test --- src/storage/json/parser.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/json/parser.rs b/src/storage/json/parser.rs index 8a76436b..ea5738b7 100644 --- a/src/storage/json/parser.rs +++ b/src/storage/json/parser.rs @@ -148,6 +148,8 @@ impl Serialize for FileHeaderData { #[cfg(test)] mod test { + use std::ops::Deref; + use super::JsonHeaderParser; use storage::parser::{FileHeaderParser, ParserError}; use storage::file::header::data::FileHeaderData as FHD; @@ -177,9 +179,9 @@ mod test { Some(FHD::Map{keys: keys}) => { for k in keys { match k { - FHD::Key{name: name, value: box value} => { + FHD::Key{name: name, value: value} => { assert!(name == "a" || name == "b", "Key unknown"); - match &value { + match value.deref() { &FHD::UInteger(u) => assert_eq!(u, 1), &FHD::Integer(i) => assert_eq!(i, -2), _ => assert!(false, "Integers are not here"),