flashplayer 10.1.1.pre → 10.1.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/flashplayer/specification.rb +2 -2
- data/lib/flashplayer/task.legacy.rb +293 -0
- data/lib/flashplayer/task.rb +25 -306
- data/test/unit/task_test.rb +33 -9
- metadata +17 -27
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
10.1.
|
1
|
+
10.1.2.pre
|
@@ -10,7 +10,7 @@ Sprout::Specification.new do |s|
|
|
10
10
|
t.md5 = "ff6824b7fd676dd1b613204221f5b5b9"
|
11
11
|
t.add_executable :flashplayer, "Flash Player Debugger.app/Contents/MacOS/Flash Player Debugger"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
s.add_remote_file_target do |t|
|
15
15
|
t.platform = :win32
|
16
16
|
t.archive_type = :exe
|
@@ -26,6 +26,6 @@ Sprout::Specification.new do |s|
|
|
26
26
|
t.md5 = "6cabe6038343374b547043d29de14417"
|
27
27
|
t.add_executable :flashplayer, "flash_player_10_linux_dev/standalone/debugger/flashplayer"
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
end
|
31
31
|
|
@@ -0,0 +1,293 @@
|
|
1
|
+
|
2
|
+
=begin
|
3
|
+
|
4
|
+
class FlashPlayerTask < Rake::Task
|
5
|
+
# This is the opening prelude to a collection of test results. When the
|
6
|
+
# task encounters this string in the trace output log file, it will begin
|
7
|
+
# collecting trace statements with the expectation that the following
|
8
|
+
# strings will be well-formatted XML data matching what JUnit emits for
|
9
|
+
# Cruise Control.
|
10
|
+
#
|
11
|
+
# See the lib/asunit3/asunit.framework.XMLResultPrinter for more information.
|
12
|
+
@@test_result_pre_delimiter = '<XMLResultPrinter>'
|
13
|
+
|
14
|
+
# This is the closing string that will indicate the end of test result XML data
|
15
|
+
@@test_result_post_delimiter = '</XMLResultPrinter>'
|
16
|
+
|
17
|
+
@@home = nil
|
18
|
+
@@trust = nil
|
19
|
+
|
20
|
+
def initialize(task_name, app)
|
21
|
+
super(task_name, app)
|
22
|
+
@default_gem_name = 'sprout-flashplayer-tool'
|
23
|
+
@default_gem_version = '10.22.0'
|
24
|
+
@default_result_file = 'AsUnitResults.xml'
|
25
|
+
@inside_test_result = false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.define_task(args, &block)
|
29
|
+
t = super
|
30
|
+
yield t if block_given?
|
31
|
+
t.define
|
32
|
+
end
|
33
|
+
|
34
|
+
# Local system path to the Flash Player Trust file
|
35
|
+
def FlashPlayerTask.trust
|
36
|
+
if(@@trust)
|
37
|
+
return @@trust
|
38
|
+
end
|
39
|
+
@@trust = File.join(FlashPlayerTask.home, '#Security', 'FlashPlayerTrust', 'sprout.cfg')
|
40
|
+
return @@trust
|
41
|
+
end
|
42
|
+
|
43
|
+
# Local system path to where the Flash Player stores trace output logs and trust files
|
44
|
+
def FlashPlayerTask.home
|
45
|
+
if(@@home)
|
46
|
+
return @@home
|
47
|
+
end
|
48
|
+
|
49
|
+
FlashPlayerTask.home_paths.each do |path|
|
50
|
+
if(File.exists?(path))
|
51
|
+
return @@home = path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if(@@home.nil?)
|
56
|
+
raise FlashPlayerError.new('FlashPlayer unable to find home folder for your platform')
|
57
|
+
end
|
58
|
+
return @@home
|
59
|
+
end
|
60
|
+
|
61
|
+
# Collection of the potential locations of the Flash Player Home
|
62
|
+
# For each supported Platform, the first existing location
|
63
|
+
# will be used.
|
64
|
+
def FlashPlayerTask.home_paths
|
65
|
+
return [File.join(User.library, 'Preferences', 'Macromedia', 'Flash Player'),
|
66
|
+
File.join(User.library, 'Application Support', 'Macromedia'),
|
67
|
+
File.join(User.home, 'Application Data', 'Macromedia', 'Flash Player'),
|
68
|
+
File.join(User.home, 'AppData', 'Roaming', 'Macromedia', 'Flash Player'),
|
69
|
+
File.join(User.home, '.macromedia', 'Flash_Player')]
|
70
|
+
end
|
71
|
+
|
72
|
+
# The swf parameter can be set explicitly in the block sent to this task as in:
|
73
|
+
#
|
74
|
+
# flashplayer :run do |t|
|
75
|
+
# t.swf = 'bin/SomeProject.swf'
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# Or it can be set implicitly as a rake prerequisite as follows:
|
79
|
+
#
|
80
|
+
# flashplayer :run => 'bin/SomeProject' do |t|
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
def swf=(swf)
|
84
|
+
@swf = swf
|
85
|
+
end
|
86
|
+
|
87
|
+
def swf
|
88
|
+
@swf ||= nil
|
89
|
+
if(@swf.nil?)
|
90
|
+
prerequisites.each do |req|
|
91
|
+
if(req.index('.swf'))
|
92
|
+
@swf = req.to_s
|
93
|
+
break
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
return @swf
|
98
|
+
end
|
99
|
+
|
100
|
+
def gem_version=(version)
|
101
|
+
@gem_version = version
|
102
|
+
end
|
103
|
+
|
104
|
+
def gem_version
|
105
|
+
return @gem_version ||= nil
|
106
|
+
end
|
107
|
+
|
108
|
+
# Full name of the sprout tool gem that this tool task will use.
|
109
|
+
# This defaults to sprout-flashplayer-tool
|
110
|
+
def gem_name=(name)
|
111
|
+
@gem_name = name
|
112
|
+
end
|
113
|
+
|
114
|
+
def gem_name
|
115
|
+
return @gem_name ||= @default_gem_name
|
116
|
+
end
|
117
|
+
|
118
|
+
# The File where JUnit test results should be written. This value
|
119
|
+
# defaults to 'AsUnitResults.xml'
|
120
|
+
#
|
121
|
+
def test_result_file=(file)
|
122
|
+
@test_result_file = file
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_result_file
|
126
|
+
@test_result_file ||= @default_result_file
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_result
|
130
|
+
@test_result ||= ''
|
131
|
+
end
|
132
|
+
|
133
|
+
def define # :nodoc:
|
134
|
+
CLEAN.add(test_result_file)
|
135
|
+
end
|
136
|
+
|
137
|
+
def execute(*args)
|
138
|
+
super
|
139
|
+
raise FlashPlayerError.new("FlashPlayer task #{name} required field swf is nil") unless swf
|
140
|
+
|
141
|
+
log_file = nil
|
142
|
+
|
143
|
+
# Don't let trust or log file failures break other features...
|
144
|
+
begin
|
145
|
+
config = FlashPlayerConfig.new
|
146
|
+
log_file = config.log_file
|
147
|
+
FlashPlayerTrust.new(File.expand_path(File.dirname(swf)))
|
148
|
+
|
149
|
+
if(File.exists?(log_file))
|
150
|
+
File.open(log_file, 'w') do |f|
|
151
|
+
f.write('')
|
152
|
+
end
|
153
|
+
else
|
154
|
+
FileUtils.makedirs(File.dirname(log_file))
|
155
|
+
FileUtils.touch(log_file)
|
156
|
+
end
|
157
|
+
rescue StandardError => e
|
158
|
+
logger.puts '[WARNING] FlashPlayer encountered an error working with the mm.cfg log and/or editing the Trust file'
|
159
|
+
end
|
160
|
+
|
161
|
+
@running_process = nil
|
162
|
+
@thread = run(gem_name, gem_version, swf)
|
163
|
+
read_log(@thread, log_file) unless log_file.nil?
|
164
|
+
@thread.join
|
165
|
+
end
|
166
|
+
|
167
|
+
def run(tool, gem_version, swf)
|
168
|
+
path_to_exe = Sprout.get_executable(tool, nil, gem_version)
|
169
|
+
target = User.clean_path(path_to_exe)
|
170
|
+
@player_pid = nil
|
171
|
+
|
172
|
+
thread_out = $stdout
|
173
|
+
command = "#{target} #{User.clean_path(swf)}"
|
174
|
+
|
175
|
+
usr = User.new()
|
176
|
+
if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
|
177
|
+
return Thread.new {
|
178
|
+
system command
|
179
|
+
}
|
180
|
+
elsif usr.is_a?(OSXUser)
|
181
|
+
require 'clix_flash_player'
|
182
|
+
@clix_player = CLIXFlashPlayer.new
|
183
|
+
@clix_player.execute(target, swf)
|
184
|
+
return @clix_player
|
185
|
+
else
|
186
|
+
return Thread.new {
|
187
|
+
require 'open4'
|
188
|
+
@player_pid, stdin, stdout, stderr = Open4.popen4(command)
|
189
|
+
stdout.read
|
190
|
+
}
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def close
|
195
|
+
usr = User.new
|
196
|
+
if(usr.is_a?(WinUser))
|
197
|
+
Thread.kill(@thread)
|
198
|
+
elsif(usr.is_a?(OSXUser))
|
199
|
+
@clix_player.kill unless @clix_player.nil?
|
200
|
+
else
|
201
|
+
Process.kill("SIGALRM", @player_pid)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def read_log(thread, log_file)
|
206
|
+
lines_put = 0
|
207
|
+
|
208
|
+
if(log_file.nil?)
|
209
|
+
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file because the expected location was nil')
|
210
|
+
end
|
211
|
+
|
212
|
+
if(!File.exists?(log_file))
|
213
|
+
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file in the expected location: ' + log_file)
|
214
|
+
end
|
215
|
+
|
216
|
+
while(thread.alive?)
|
217
|
+
sleep(0.2)
|
218
|
+
lines_read = 0
|
219
|
+
|
220
|
+
File.open(log_file, 'r') do |file|
|
221
|
+
file.readlines.each do |line|
|
222
|
+
lines_read = lines_read + 1
|
223
|
+
if(lines_read > lines_put)
|
224
|
+
if(!parse_test_result(line, thread))
|
225
|
+
logger.puts "[trace] #{line}"
|
226
|
+
end
|
227
|
+
$stdout.flush
|
228
|
+
lines_put = lines_put + 1
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns true if inside of a test result
|
236
|
+
def parse_test_result(line, thread)
|
237
|
+
if(@inside_test_result)
|
238
|
+
if(line.index(@@test_result_post_delimiter))
|
239
|
+
@inside_test_result = false
|
240
|
+
write_test_result(test_result)
|
241
|
+
close
|
242
|
+
examine_test_result test_result
|
243
|
+
return true
|
244
|
+
else
|
245
|
+
test_result << line
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
if(line.index(@@test_result_pre_delimiter))
|
250
|
+
@inside_test_result = true
|
251
|
+
end
|
252
|
+
|
253
|
+
return @inside_test_result
|
254
|
+
end
|
255
|
+
|
256
|
+
def write_test_result(result)
|
257
|
+
FileUtils.makedirs(File.dirname(test_result_file))
|
258
|
+
File.open(test_result_file, File::CREAT|File::TRUNC|File::RDWR) do |f|
|
259
|
+
f.puts(result)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def examine_test_result(result)
|
264
|
+
require 'rexml/document'
|
265
|
+
doc = nil
|
266
|
+
begin
|
267
|
+
doc = REXML::Document.new(result)
|
268
|
+
rescue REXML::ParseException => e
|
269
|
+
puts "[WARNING] Invalid test results encountered"
|
270
|
+
return
|
271
|
+
end
|
272
|
+
|
273
|
+
# Handle JUnit Failures
|
274
|
+
failures = []
|
275
|
+
|
276
|
+
doc.elements.each('/testsuites/testsuite/testsuite/testcase/error') do |element|
|
277
|
+
failures << element.text
|
278
|
+
end
|
279
|
+
|
280
|
+
doc.elements.each("/testsuites/testsuite/testsuite/testcase/failure") do |element|
|
281
|
+
failures << element.text
|
282
|
+
end
|
283
|
+
|
284
|
+
if(failures.size > 0)
|
285
|
+
raise AssertionFailure.new("[ERROR] Test Failures Encountered \n#{failures.join("\n")}")
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
=end
|
292
|
+
|
293
|
+
|
data/lib/flashplayer/task.rb
CHANGED
@@ -1,28 +1,35 @@
|
|
1
1
|
|
2
2
|
module FlashPlayer
|
3
3
|
|
4
|
-
class Task
|
4
|
+
class Task < Rake::Task
|
5
5
|
|
6
6
|
attr_accessor :input
|
7
|
-
|
8
7
|
attr_accessor :pkg_name
|
9
8
|
attr_accessor :pkg_version
|
10
9
|
|
11
|
-
|
10
|
+
##
|
11
|
+
# This is the Rake::Task constructor
|
12
|
+
# signature...
|
13
|
+
def initialize task_name, rake_application
|
14
|
+
super
|
12
15
|
@logger = $stdout
|
13
16
|
@mm_config = MMConfig.new
|
14
17
|
@reader = LogFile.new
|
15
18
|
@trust_config = Trust.new
|
16
19
|
@process = nil
|
20
|
+
@input = task_name
|
17
21
|
|
18
22
|
@pkg_name = FlashPlayer::NAME
|
19
23
|
@pkg_version = FlashPlayer::VERSION
|
20
24
|
end
|
21
25
|
|
22
|
-
def
|
26
|
+
def invoke *args
|
27
|
+
super
|
28
|
+
#puts ">> invoke with: #{args} and input: #{input}"
|
29
|
+
update_input_if_necessary
|
23
30
|
update_mm_config
|
24
|
-
update_trust_config_with
|
25
|
-
player_thread = launch_player_with
|
31
|
+
update_trust_config_with input
|
32
|
+
player_thread = launch_player_with input
|
26
33
|
tail_flashlog player_thread
|
27
34
|
end
|
28
35
|
|
@@ -39,6 +46,16 @@ module FlashPlayer
|
|
39
46
|
|
40
47
|
private
|
41
48
|
|
49
|
+
def update_input_if_necessary
|
50
|
+
return if input.match(/\.swf$/)
|
51
|
+
prerequisites.each do |prereq|
|
52
|
+
if(prereq.match(/\.swf$/))
|
53
|
+
self.input = prereq
|
54
|
+
return
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
42
59
|
def update_mm_config
|
43
60
|
@mm_config.create
|
44
61
|
end
|
@@ -104,305 +121,7 @@ module Sprout
|
|
104
121
|
end
|
105
122
|
end
|
106
123
|
|
107
|
-
def flashplayer args
|
108
|
-
|
109
|
-
# This shouldn't take over the SWF task name
|
110
|
-
# but instead should be assigned a SWF.
|
111
|
-
task args do
|
112
|
-
player = FlashPlayer::Task.new
|
113
|
-
player.execute args
|
114
|
-
end
|
124
|
+
def flashplayer *args, &block
|
125
|
+
FlashPlayer::Task.define_task *args, &block
|
115
126
|
end
|
116
127
|
|
117
|
-
=begin
|
118
|
-
|
119
|
-
class FlashPlayerTask < Rake::Task
|
120
|
-
# This is the opening prelude to a collection of test results. When the
|
121
|
-
# task encounters this string in the trace output log file, it will begin
|
122
|
-
# collecting trace statements with the expectation that the following
|
123
|
-
# strings will be well-formatted XML data matching what JUnit emits for
|
124
|
-
# Cruise Control.
|
125
|
-
#
|
126
|
-
# See the lib/asunit3/asunit.framework.XMLResultPrinter for more information.
|
127
|
-
@@test_result_pre_delimiter = '<XMLResultPrinter>'
|
128
|
-
|
129
|
-
# This is the closing string that will indicate the end of test result XML data
|
130
|
-
@@test_result_post_delimiter = '</XMLResultPrinter>'
|
131
|
-
|
132
|
-
@@home = nil
|
133
|
-
@@trust = nil
|
134
|
-
|
135
|
-
def initialize(task_name, app)
|
136
|
-
super(task_name, app)
|
137
|
-
@default_gem_name = 'sprout-flashplayer-tool'
|
138
|
-
@default_gem_version = '10.22.0'
|
139
|
-
@default_result_file = 'AsUnitResults.xml'
|
140
|
-
@inside_test_result = false
|
141
|
-
end
|
142
|
-
|
143
|
-
def self.define_task(args, &block)
|
144
|
-
t = super
|
145
|
-
yield t if block_given?
|
146
|
-
t.define
|
147
|
-
end
|
148
|
-
|
149
|
-
# Local system path to the Flash Player Trust file
|
150
|
-
def FlashPlayerTask.trust
|
151
|
-
if(@@trust)
|
152
|
-
return @@trust
|
153
|
-
end
|
154
|
-
@@trust = File.join(FlashPlayerTask.home, '#Security', 'FlashPlayerTrust', 'sprout.cfg')
|
155
|
-
return @@trust
|
156
|
-
end
|
157
|
-
|
158
|
-
# Local system path to where the Flash Player stores trace output logs and trust files
|
159
|
-
def FlashPlayerTask.home
|
160
|
-
if(@@home)
|
161
|
-
return @@home
|
162
|
-
end
|
163
|
-
|
164
|
-
FlashPlayerTask.home_paths.each do |path|
|
165
|
-
if(File.exists?(path))
|
166
|
-
return @@home = path
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
if(@@home.nil?)
|
171
|
-
raise FlashPlayerError.new('FlashPlayer unable to find home folder for your platform')
|
172
|
-
end
|
173
|
-
return @@home
|
174
|
-
end
|
175
|
-
|
176
|
-
# Collection of the potential locations of the Flash Player Home
|
177
|
-
# For each supported Platform, the first existing location
|
178
|
-
# will be used.
|
179
|
-
def FlashPlayerTask.home_paths
|
180
|
-
return [File.join(User.library, 'Preferences', 'Macromedia', 'Flash Player'),
|
181
|
-
File.join(User.library, 'Application Support', 'Macromedia'),
|
182
|
-
File.join(User.home, 'Application Data', 'Macromedia', 'Flash Player'),
|
183
|
-
File.join(User.home, 'AppData', 'Roaming', 'Macromedia', 'Flash Player'),
|
184
|
-
File.join(User.home, '.macromedia', 'Flash_Player')]
|
185
|
-
end
|
186
|
-
|
187
|
-
# The swf parameter can be set explicitly in the block sent to this task as in:
|
188
|
-
#
|
189
|
-
# flashplayer :run do |t|
|
190
|
-
# t.swf = 'bin/SomeProject.swf'
|
191
|
-
# end
|
192
|
-
#
|
193
|
-
# Or it can be set implicitly as a rake prerequisite as follows:
|
194
|
-
#
|
195
|
-
# flashplayer :run => 'bin/SomeProject' do |t|
|
196
|
-
# end
|
197
|
-
#
|
198
|
-
def swf=(swf)
|
199
|
-
@swf = swf
|
200
|
-
end
|
201
|
-
|
202
|
-
def swf
|
203
|
-
@swf ||= nil
|
204
|
-
if(@swf.nil?)
|
205
|
-
prerequisites.each do |req|
|
206
|
-
if(req.index('.swf'))
|
207
|
-
@swf = req.to_s
|
208
|
-
break
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
return @swf
|
213
|
-
end
|
214
|
-
|
215
|
-
def gem_version=(version)
|
216
|
-
@gem_version = version
|
217
|
-
end
|
218
|
-
|
219
|
-
def gem_version
|
220
|
-
return @gem_version ||= nil
|
221
|
-
end
|
222
|
-
|
223
|
-
# Full name of the sprout tool gem that this tool task will use.
|
224
|
-
# This defaults to sprout-flashplayer-tool
|
225
|
-
def gem_name=(name)
|
226
|
-
@gem_name = name
|
227
|
-
end
|
228
|
-
|
229
|
-
def gem_name
|
230
|
-
return @gem_name ||= @default_gem_name
|
231
|
-
end
|
232
|
-
|
233
|
-
# The File where JUnit test results should be written. This value
|
234
|
-
# defaults to 'AsUnitResults.xml'
|
235
|
-
#
|
236
|
-
def test_result_file=(file)
|
237
|
-
@test_result_file = file
|
238
|
-
end
|
239
|
-
|
240
|
-
def test_result_file
|
241
|
-
@test_result_file ||= @default_result_file
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_result
|
245
|
-
@test_result ||= ''
|
246
|
-
end
|
247
|
-
|
248
|
-
def define # :nodoc:
|
249
|
-
CLEAN.add(test_result_file)
|
250
|
-
end
|
251
|
-
|
252
|
-
def execute(*args)
|
253
|
-
super
|
254
|
-
raise FlashPlayerError.new("FlashPlayer task #{name} required field swf is nil") unless swf
|
255
|
-
|
256
|
-
log_file = nil
|
257
|
-
|
258
|
-
# Don't let trust or log file failures break other features...
|
259
|
-
begin
|
260
|
-
config = FlashPlayerConfig.new
|
261
|
-
log_file = config.log_file
|
262
|
-
FlashPlayerTrust.new(File.expand_path(File.dirname(swf)))
|
263
|
-
|
264
|
-
if(File.exists?(log_file))
|
265
|
-
File.open(log_file, 'w') do |f|
|
266
|
-
f.write('')
|
267
|
-
end
|
268
|
-
else
|
269
|
-
FileUtils.makedirs(File.dirname(log_file))
|
270
|
-
FileUtils.touch(log_file)
|
271
|
-
end
|
272
|
-
rescue StandardError => e
|
273
|
-
puts '[WARNING] FlashPlayer encountered an error working with the mm.cfg log and/or editing the Trust file'
|
274
|
-
end
|
275
|
-
|
276
|
-
@running_process = nil
|
277
|
-
@thread = run(gem_name, gem_version, swf)
|
278
|
-
read_log(@thread, log_file) unless log_file.nil?
|
279
|
-
@thread.join
|
280
|
-
end
|
281
|
-
|
282
|
-
def run(tool, gem_version, swf)
|
283
|
-
path_to_exe = Sprout.get_executable(tool, nil, gem_version)
|
284
|
-
target = User.clean_path(path_to_exe)
|
285
|
-
@player_pid = nil
|
286
|
-
|
287
|
-
thread_out = $stdout
|
288
|
-
command = "#{target} #{User.clean_path(swf)}"
|
289
|
-
|
290
|
-
usr = User.new()
|
291
|
-
if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
|
292
|
-
return Thread.new {
|
293
|
-
system command
|
294
|
-
}
|
295
|
-
elsif usr.is_a?(OSXUser)
|
296
|
-
require 'clix_flash_player'
|
297
|
-
@clix_player = CLIXFlashPlayer.new
|
298
|
-
@clix_player.execute(target, swf)
|
299
|
-
return @clix_player
|
300
|
-
else
|
301
|
-
return Thread.new {
|
302
|
-
require 'open4'
|
303
|
-
@player_pid, stdin, stdout, stderr = Open4.popen4(command)
|
304
|
-
stdout.read
|
305
|
-
}
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
def close
|
310
|
-
usr = User.new
|
311
|
-
if(usr.is_a?(WinUser))
|
312
|
-
Thread.kill(@thread)
|
313
|
-
elsif(usr.is_a?(OSXUser))
|
314
|
-
@clix_player.kill unless @clix_player.nil?
|
315
|
-
else
|
316
|
-
Process.kill("SIGALRM", @player_pid)
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
def read_log(thread, log_file)
|
321
|
-
lines_put = 0
|
322
|
-
|
323
|
-
if(log_file.nil?)
|
324
|
-
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file because the expected location was nil')
|
325
|
-
end
|
326
|
-
|
327
|
-
if(!File.exists?(log_file))
|
328
|
-
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file in the expected location: ' + log_file)
|
329
|
-
end
|
330
|
-
|
331
|
-
while(thread.alive?)
|
332
|
-
sleep(0.2)
|
333
|
-
lines_read = 0
|
334
|
-
|
335
|
-
File.open(log_file, 'r') do |file|
|
336
|
-
file.readlines.each do |line|
|
337
|
-
lines_read = lines_read + 1
|
338
|
-
if(lines_read > lines_put)
|
339
|
-
if(!parse_test_result(line, thread))
|
340
|
-
puts "[trace] #{line}"
|
341
|
-
end
|
342
|
-
$stdout.flush
|
343
|
-
lines_put = lines_put + 1
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
# Returns true if inside of a test result
|
351
|
-
def parse_test_result(line, thread)
|
352
|
-
if(@inside_test_result)
|
353
|
-
if(line.index(@@test_result_post_delimiter))
|
354
|
-
@inside_test_result = false
|
355
|
-
write_test_result(test_result)
|
356
|
-
close
|
357
|
-
examine_test_result test_result
|
358
|
-
return true
|
359
|
-
else
|
360
|
-
test_result << line
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
if(line.index(@@test_result_pre_delimiter))
|
365
|
-
@inside_test_result = true
|
366
|
-
end
|
367
|
-
|
368
|
-
return @inside_test_result
|
369
|
-
end
|
370
|
-
|
371
|
-
def write_test_result(result)
|
372
|
-
FileUtils.makedirs(File.dirname(test_result_file))
|
373
|
-
File.open(test_result_file, File::CREAT|File::TRUNC|File::RDWR) do |f|
|
374
|
-
f.puts(result)
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
def examine_test_result(result)
|
379
|
-
require 'rexml/document'
|
380
|
-
doc = nil
|
381
|
-
begin
|
382
|
-
doc = REXML::Document.new(result)
|
383
|
-
rescue REXML::ParseException => e
|
384
|
-
puts "[WARNING] Invalid test results encountered"
|
385
|
-
return
|
386
|
-
end
|
387
|
-
|
388
|
-
# Handle JUnit Failures
|
389
|
-
failures = []
|
390
|
-
|
391
|
-
doc.elements.each('/testsuites/testsuite/testsuite/testcase/error') do |element|
|
392
|
-
failures << element.text
|
393
|
-
end
|
394
|
-
|
395
|
-
doc.elements.each("/testsuites/testsuite/testsuite/testcase/failure") do |element|
|
396
|
-
failures << element.text
|
397
|
-
end
|
398
|
-
|
399
|
-
if(failures.size > 0)
|
400
|
-
raise AssertionFailure.new("[ERROR] Test Failures Encountered \n#{failures.join("\n")}")
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
end
|
405
|
-
|
406
|
-
=end
|
407
|
-
|
408
|
-
|
data/test/unit/task_test.rb
CHANGED
@@ -6,22 +6,46 @@ class FlashPlayerTaskTest < Test::Unit::TestCase
|
|
6
6
|
context "A FlashPlayerTask" do
|
7
7
|
|
8
8
|
setup do
|
9
|
+
# Force reload of the Specification on each
|
10
|
+
# test method b/c SproutTestCase calls
|
11
|
+
# Executable.clear_entities! but 'require'
|
12
|
+
# only runs once per VM run...
|
13
|
+
load 'flashplayer/specification.rb'
|
9
14
|
@swf = File.join(fixtures, 'AsUnit4.swf')
|
10
15
|
end
|
11
16
|
|
12
|
-
should "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
should "work with swf as task name" do
|
18
|
+
t = flashplayer @swf
|
19
|
+
configure_task t
|
20
|
+
t.invoke
|
21
|
+
end
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
should "work with swf in block" do
|
24
|
+
t = flashplayer :run do |t|
|
25
|
+
t.input = @swf
|
26
|
+
end
|
27
|
+
configure_task t
|
28
|
+
t.invoke
|
29
|
+
assert_equal @swf, t.input
|
30
|
+
end
|
21
31
|
|
22
|
-
|
32
|
+
should "work with swf as prerequisite" do
|
33
|
+
t = flashplayer :run => @swf
|
34
|
+
configure_task t
|
35
|
+
t.invoke
|
36
|
+
assert_equal @swf, t.input
|
23
37
|
end
|
24
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def configure_task t
|
43
|
+
t.logger = StringIO.new
|
44
|
+
# Comment following lines to really launch the player:
|
45
|
+
sys = FakeSystem.new
|
46
|
+
t.stubs(:current_system).returns sys
|
47
|
+
sys.expects(:open_flashplayer_with)
|
48
|
+
end
|
25
49
|
end
|
26
50
|
|
27
51
|
class FakeSystem
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flashplayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 961916136
|
5
4
|
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 10
|
8
7
|
- 1
|
9
|
-
-
|
8
|
+
- 2
|
10
9
|
- pre
|
11
|
-
version: 10.1.
|
10
|
+
version: 10.1.2.pre
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Luke Bayes
|
@@ -16,53 +15,47 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-27 00:00:00 -07:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
|
22
|
+
name: sprout
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
requirements:
|
26
25
|
- - ">="
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 961915932
|
29
27
|
segments:
|
30
28
|
- 1
|
31
29
|
- 0
|
32
30
|
- pre
|
33
31
|
version: 1.0.pre
|
34
|
-
requirement: *id001
|
35
|
-
name: sprout
|
36
|
-
prerelease: false
|
37
32
|
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
38
35
|
- !ruby/object:Gem::Dependency
|
39
|
-
|
40
|
-
|
36
|
+
name: shoulda
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
38
|
requirements:
|
42
39
|
- - ">="
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
41
|
segments:
|
46
42
|
- 0
|
47
43
|
version: "0"
|
48
|
-
requirement: *id002
|
49
|
-
name: shoulda
|
50
|
-
prerelease: false
|
51
44
|
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *id002
|
52
47
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
54
|
-
|
48
|
+
name: mocha
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
50
|
requirements:
|
56
51
|
- - ">="
|
57
52
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 3
|
59
53
|
segments:
|
60
54
|
- 0
|
61
55
|
version: "0"
|
62
|
-
requirement: *id003
|
63
|
-
name: mocha
|
64
|
-
prerelease: false
|
65
56
|
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id003
|
66
59
|
description: The Adobe Flash Player
|
67
60
|
email: projectsprouts@googlegroups.com
|
68
61
|
executables: []
|
@@ -81,6 +74,7 @@ files:
|
|
81
74
|
- lib/flashplayer/mm_config.rb
|
82
75
|
- lib/flashplayer/module.rb
|
83
76
|
- lib/flashplayer/specification.rb
|
77
|
+
- lib/flashplayer/task.legacy.rb
|
84
78
|
- lib/flashplayer/task.rb
|
85
79
|
- lib/flashplayer/trust.rb
|
86
80
|
- lib/flashplayer.rb
|
@@ -104,20 +98,16 @@ require_paths:
|
|
104
98
|
- lib
|
105
99
|
- lib
|
106
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
101
|
requirements:
|
109
102
|
- - ">="
|
110
103
|
- !ruby/object:Gem::Version
|
111
|
-
hash: 3
|
112
104
|
segments:
|
113
105
|
- 0
|
114
106
|
version: "0"
|
115
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
108
|
requirements:
|
118
109
|
- - ">"
|
119
110
|
- !ruby/object:Gem::Version
|
120
|
-
hash: 25
|
121
111
|
segments:
|
122
112
|
- 1
|
123
113
|
- 3
|
@@ -126,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
116
|
requirements: []
|
127
117
|
|
128
118
|
rubyforge_project:
|
129
|
-
rubygems_version: 1.3.
|
119
|
+
rubygems_version: 1.3.6
|
130
120
|
signing_key:
|
131
121
|
specification_version: 3
|
132
122
|
summary: Adobe Flash Player
|