move everything test related into test cfg
authoralfadur
Tue, 28 Aug 2018 17:19:25 +0300
changeset 13713 59ea2403f62d
parent 13709 e335daaa77a9
child 13769 c5edfcfac68b
move everything test related into test cfg
gameServer2/Cargo.toml
gameServer2/src/main.rs
gameServer2/src/protocol/messages.rs
gameServer2/src/protocol/mod.rs
gameServer2/src/protocol/parser.rs
gameServer2/src/server/handlers/common.rs
--- a/gameServer2/Cargo.toml	Mon Aug 27 22:28:56 2018 +0300
+++ b/gameServer2/Cargo.toml	Tue Aug 28 17:19:25 2018 +0300
@@ -14,9 +14,11 @@
 nom = "4.0"
 env_logger = "0.4"
 log = "0.4"
-proptest = "0.8"
 base64 = "0.9"
 bitflags = "1.0"
 serde = "1.0"
 serde_yaml = "0.7"
 serde_derive = "1.0"
+
+[dev-dependencies]
+proptest = "0.8"
\ No newline at end of file
--- a/gameServer2/src/main.rs	Mon Aug 27 22:28:56 2018 +0300
+++ b/gameServer2/src/main.rs	Tue Aug 28 17:19:25 2018 +0300
@@ -12,6 +12,7 @@
 #[macro_use]
 extern crate log;
 extern crate env_logger;
+#[cfg(test)]
 #[macro_use] extern crate proptest;
 #[macro_use] extern crate bitflags;
 extern crate serde;
--- a/gameServer2/src/protocol/messages.rs	Mon Aug 27 22:28:56 2018 +0300
+++ b/gameServer2/src/protocol/messages.rs	Tue Aug 28 17:19:25 2018 +0300
@@ -151,6 +151,7 @@
     };
 }
 
+#[cfg(test)]
 macro_rules! several {
     [$part: expr] => { once($part) };
     [$part: expr, $($other: expr),*] => { once($part).chain(several![$($other),*]) };
@@ -161,6 +162,7 @@
      *
      * This is the inverse of the `message` parser.
      */
+    #[cfg(test)]
     pub(crate) fn to_raw_protocol(&self) -> String {
         use self::HWProtocolMessage::*;
         match self {
--- a/gameServer2/src/protocol/mod.rs	Mon Aug 27 22:28:56 2018 +0300
+++ b/gameServer2/src/protocol/mod.rs	Tue Aug 28 17:19:25 2018 +0300
@@ -7,6 +7,7 @@
 };
 
 pub mod messages;
+#[cfg(test)]
 pub mod test;
 mod parser;
 
--- a/gameServer2/src/protocol/parser.rs	Mon Aug 27 22:28:56 2018 +0300
+++ b/gameServer2/src/protocol/parser.rs	Tue Aug 28 17:19:25 2018 +0300
@@ -14,9 +14,10 @@
     ops::Range
 };
 use super::{
-    messages::{HWProtocolMessage, HWProtocolMessage::*},
-    test::gen_proto_msg
+    messages::{HWProtocolMessage, HWProtocolMessage::*}
 };
+#[cfg(test)]
+use super::test::gen_proto_msg;
 use crate::server::coretypes::{
     HedgehogInfo, TeamInfo, GameCfg, VoteType, MAX_HEDGEHOGS_PER_TEAM
 };
@@ -242,6 +243,7 @@
 
 named!(pub extract_messages<&[u8], Vec<HWProtocolMessage> >, many0!(complete!(message)));
 
+#[cfg(test)]
 proptest! {
     #[test]
     fn is_parser_composition_idempotent(ref msg in gen_proto_msg()) {
--- a/gameServer2/src/server/handlers/common.rs	Mon Aug 27 22:28:56 2018 +0300
+++ b/gameServer2/src/server/handlers/common.rs	Tue Aug 28 17:19:25 2018 +0300
@@ -23,8 +23,8 @@
 #[cfg(test)]
 mod tests {
     use super::*;
-    use protocol::messages::HWServerMessage::ChatMsg;
-    use server::actions::{
+    use crate::protocol::messages::HWServerMessage::ChatMsg;
+    use crate::server::actions::{
         Action::{self, Send}, PendingMessage,
     };