Permalink
Browse files

big refactoring to fix unit tests. Not finished!

  • Loading branch information...
cadrian committed Oct 25, 2015
1 parent e3b8bc0 commit c4ebe3805f50b2639a98316abef2396eba8d1d5e
View
@@ -68,6 +68,26 @@ endif
all:$(for exe in $EXE; do printf ' %s' exe/$exe; done; echo)
EOF
+
+while read class; do
+ mkdir -p $dir/test/testable/$(dirname "$class")
+ base=$(echo "$class" | sed 's!\.e$!!;s!_def$!!')
+ expect=$dir/test/testable/${base}_expect.e
+ mock=$dir/test/testable/${base}_mock.e
+ source=$dir/src/$class
+
+ rm -f $expect $mock
+ se mock --expect $expect --mock $mock $source
+
+done <<EOF
+channel/channel_factory_def.e
+channel/client_channel.e
+channel/server_channel.e
+config/shared_def.e
+extern/extern_def.e
+EOF
+
+
for exe in $EXE
do
mkdir -p $bootstrap_dir/c/$exe
View
@@ -99,6 +99,12 @@ cluster
debug($debug_pwd)
end
+ testable: "src/testable"
+ default
+ assertion($assert)
+ debug($debug_pwd)
+ end
+
liberty_core: "\${$path_liberty_core}loadpath.se"
default
debug($debug_liberty)
@@ -16,45 +16,30 @@
expanded class CHANNEL_FACTORY
insert
- LOGGING
+ TEST_FACADE[CHANNEL_FACTORY_DEF]
feature {CLIENT}
new_client_channel (tmpdir: ABSTRACT_STRING): CLIENT_CHANNEL
require
tmpdir /= Void
do
- inspect
- shared.channel_method.out
- when "fifo" then
- create {CLIENT_FIFO} Result.make(tmpdir)
- when "socket" then
- create {CLIENT_SOCKET} Result.make(tmpdir)
- when "zmq" then
- create {CLIENT_ZMQ} Result.make(tmpdir)
- else
- log.error.put_line(once "Unknown channel method: #(1)" # shared.channel_method)
- die_with_code(1)
- end
+ Result := def.new_client_channel(tmpdir)
+ ensure
+ Result /= Void
end
feature {SERVER}
new_server_channel: SERVER_CHANNEL
do
- inspect
- shared.channel_method.out
- when "fifo" then
- create {SERVER_FIFO} Result.make
- when "socket" then
- create {SERVER_SOCKET} Result.make
- when "zmq" then
- create {SERVER_ZMQ} Result.make
- else
- log.error.put_line(once "Unknown channel method: #(1)" # shared.channel_method)
- die_with_code(1)
- end
+ Result := def.new_server_channel
+ ensure
+ Result /= Void
end
feature {}
- shared: SHARED
+ def_impl: CHANNEL_FACTORY_IMPL
+ once
+ create Result
+ end
end -- class CHANNEL_FACTORY
@@ -0,0 +1,36 @@
+-- This file is part of pwd.
+-- Copyright (C) 2012-2015 Cyril Adrian <cyril.adrian@gmail.com>
+--
+-- pwd is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, version 3 of the License.
+--
+-- pwd is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with pwd. If not, see <http://www.gnu.org/licenses/>.
+--
+deferred class CHANNEL_FACTORY_DEF
+
+inherit
+ TESTABLE
+
+feature {CHANNEL_FACTORY}
+ new_client_channel (tmpdir: ABSTRACT_STRING): CLIENT_CHANNEL
+ require
+ tmpdir /= Void
+ deferred
+ ensure
+ Result /= Void
+ end
+
+ new_server_channel: SERVER_CHANNEL
+ deferred
+ ensure
+ Result /= Void
+ end
+
+end -- class CHANNEL_FACTORY_DEF
@@ -0,0 +1,60 @@
+-- This file is part of pwd.
+-- Copyright (C) 2012-2015 Cyril Adrian <cyril.adrian@gmail.com>
+--
+-- pwd is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, version 3 of the License.
+--
+-- pwd is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with pwd. If not, see <http://www.gnu.org/licenses/>.
+--
+class CHANNEL_FACTORY_IMPL
+
+inherit
+ CHANNEL_FACTORY_DEF
+
+insert
+ LOGGING
+
+feature {CHANNEL_FACTORY}
+ new_client_channel (tmpdir: ABSTRACT_STRING): CLIENT_CHANNEL
+ do
+ inspect
+ shared.channel_method.out
+ when "fifo" then
+ create {CLIENT_FIFO} Result.make(tmpdir)
+ when "socket" then
+ create {CLIENT_SOCKET} Result.make(tmpdir)
+ when "zmq" then
+ create {CLIENT_ZMQ} Result.make(tmpdir)
+ else
+ log.error.put_line(once "Unknown channel method: #(1)" # shared.channel_method)
+ die_with_code(1)
+ end
+ end
+
+ new_server_channel: SERVER_CHANNEL
+ do
+ inspect
+ shared.channel_method.out
+ when "fifo" then
+ create {SERVER_FIFO} Result.make
+ when "socket" then
+ create {SERVER_SOCKET} Result.make
+ when "zmq" then
+ create {SERVER_ZMQ} Result.make
+ else
+ log.error.put_line(once "Unknown channel method: #(1)" # shared.channel_method)
+ die_with_code(1)
+ end
+ end
+
+feature {}
+ shared: SHARED
+
+end -- class CHANNEL_FACTORY_IMPL
@@ -24,7 +24,7 @@ insert
LOGGING
FILE_TOOLS
-create {CHANNEL_FACTORY}
+create {ANY}
make
feature {CLIENT}
@@ -29,7 +29,7 @@ insert
LOGGING
FILE_TOOLS
-create {CHANNEL_FACTORY}
+create {ANY}
make
feature {SERVER}
@@ -22,7 +22,7 @@ insert
CONFIGURABLE
LOGGING
-create {CHANNEL_FACTORY}
+create {ANY}
make
feature {CLIENT}
@@ -23,7 +23,7 @@ inherit
insert
LOGGING
-create {CHANNEL_FACTORY}
+create {ANY}
make
feature {SERVER}
@@ -22,7 +22,7 @@ insert
CONFIGURABLE
LOGGING
-create {CHANNEL_FACTORY}
+create {ANY}
make
feature {CLIENT}
@@ -18,7 +18,7 @@ class SERVER_ZMQ
inherit
SERVER_CHANNEL
-create {CHANNEL_FACTORY}
+create {ANY}
make
feature {SERVER}
Oops, something went wrong.

0 comments on commit c4ebe38

Please sign in to comment.