-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheqa_system_test_set.e
More file actions
214 lines (189 loc) · 6.15 KB
/
eqa_system_test_set.e
File metadata and controls
214 lines (189 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
note
description: "[
Sets of tests performing black box testing by launching an external system.
]"
author: ""
date: "$Date: 2009-08-05 16:47:29 +0800 (三, 05 8月 2009) $"
revision: "$Revision: 80111 $"
deferred class
EQA_SYSTEM_TEST_SET
inherit
EQA_TEST_SET
rename
on_prepare as on_prepare_frozen,
on_clean as on_clean_frozen
redefine
on_prepare_frozen,
on_clean_frozen
end
feature {EQA_SYSTEM_EXECUTION, EQA_EW_TEST_INSTRUCTION} -- Access
file_system: EQA_FILE_SYSTEM
-- File system for creating directories and files
require
prepared: is_prepared
local
l_file_system: detachable EQA_FILE_SYSTEM
l_env: like environment
l_platform: PLATFORM
do
l_file_system := file_system_cache
if l_file_system = Void then
create l_platform
l_env := environment
create l_file_system.make (l_env)
file_system_cache := l_file_system
end
Result := l_file_system
end
environment: EQA_SYSTEM_ENVIRONMENT
-- Environment specifying source/target directory for `Current'.
require
prepared: is_prepared
local
l_env: detachable like environment_cache
do
l_env := environment_cache
if l_env = Void then
create l_env.make (Current)
environment_cache := l_env
end
Result := l_env
end
feature {NONE} -- Access: execution
current_execution: detachable EQA_SYSTEM_EXECUTION
feature {NONE} -- Access: caching
file_system_cache: detachable like file_system
-- Cache for `file_system'
environment_cache: detachable like environment
-- Cache for `environment'
feature {NONE} -- Query
compare_output (a_output: READABLE_STRING_8)
require
current_execution_attached: current_execution /= Void
current_execution_exited: attached current_execution as l_exec_exited and then
l_exec_exited.is_launched and then l_exec_exited.has_exited
current_execution_stored_output: attached current_execution as l_exec_out and then
l_exec_out.output_path /= Void
local
l_path: detachable EQA_SYSTEM_PATH
l_execution: like current_execution
do
l_execution := current_execution
check l_execution /= Void end
l_path := l_execution.output_path
check l_path /= Void end
assert ("identical_output", file_system.has_same_content_as_string (l_path, a_output))
end
compare_output_with_file (a_output_path: EQA_SYSTEM_PATH)
require
current_execution_attached: current_execution /= Void
current_execution_exited: attached current_execution as l_exec_exited and then
l_exec_exited.is_launched and then l_exec_exited.has_exited
current_execution_stored_output: attached current_execution as l_exec_out and then
l_exec_out.output_path /= Void
a_output_path_not_empty: not a_output_path.is_empty
local
l_path: detachable EQA_SYSTEM_PATH
l_execution: like current_execution
do
l_execution := current_execution
check l_execution /= Void end
l_path := l_execution.output_path
check l_path /= Void end
assert ("identical_output", file_system.has_same_content_as_path (l_path, a_output_path))
end
feature {NONE} -- Basic operations
prepare_system (a_output_path: EQA_SYSTEM_PATH)
-- Create new `current_execution' using provided path to store output.
--
-- `a_output_path': Path where output retrieved from system will be stored.
local
l_exec: like current_execution
do
create l_exec.make (environment)
l_exec.set_output_path (a_output_path)
current_execution := l_exec
ensure
current_execution_attached: current_execution /= Void
current_execution_uses_environment: attached current_execution as l_exec_e and then
l_exec_e.environment = environment
current_execution_not_launched: attached current_execution as l_exec_nl and then
not l_exec_nl.is_launched
current_execution_uses_valid_output: attached current_execution as l_exec_o and then
l_exec_o.output_path ~ old a_output_path
end
run_system (a_args: ARRAY [STRING])
-- Launch `current_execution' and process output until it exits.
require
current_execution_attached: current_execution /= Void
current_execution_not_launched: attached current_execution as l_exec_nl and then
not l_exec_nl.is_launched
local
l_exec: like current_execution
do
l_exec := current_execution
check l_exec /= Void end
l_exec.clear_argument
a_args.do_all (agent (a_arg: STRING; a_exec: attached like current_execution)
require
a_arg_attached: a_arg /= Void
do
a_exec.add_argument (a_arg)
end (?, l_exec))
l_exec.launch
l_exec.process_output_until_exit
-- Safety assignments to satisfy postcondition
current_execution := l_exec
ensure
current_execution_unchanged: current_execution = old current_execution
current_execution_exited: attached current_execution as l_exec_exited and then
l_exec_exited.is_launched and then l_exec_exited.has_exited
end
feature {NONE} -- Events
frozen on_prepare_frozen
-- <Precursor>
do
assert ("multithreaded", (create {PLATFORM}).is_thread_capable)
on_prepare
ensure then
prepared: is_prepared
end
frozen on_clean_frozen
-- <Precursor>
do
on_clean
-- TODO: delete testing directory if test succeeded
file_system_cache := Void
environment_cache := Void
current_execution := Void
ensure then
environment_cache_detached: environment_cache = Void
file_system_cache_detached: file_system_cache = Void
current_execution_detached: current_execution = Void
end
on_prepare
-- Called when `on_prepare_frozen' is called.
do
ensure
prepared: is_prepared
end
on_clean
-- Called when `on_prepare_clean' is called.
require
prepared: is_prepared
do
end
invariant
environment_cache_valid: attached {like environment} environment_cache as l_env implies l_env.test_set = Current
file_system_cache_valid: attached {like file_system} file_system_cache as l_fs implies l_fs.environment = environment
note
copyright: "Copyright (c) 1984-2009, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end