sprout 1.1.7.pre → 1.1.10.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/VERSION +1 -1
- data/lib/sprout.rb +0 -1
- data/lib/sprout/executable.rb +1 -0
- data/lib/sprout/executable/base.rb +57 -4
- data/lib/sprout/{daemon.rb → executable/session.rb} +47 -67
- data/lib/sprout/process_runner.rb +6 -4
- data/lib/sprout/system/base_system.rb +45 -6
- data/lib/sprout/test_helper.rb +0 -19
- data/test/fixtures/executable/fdb.rb +7 -11
- data/test/fixtures/executable/flex3sdk_gem/flex3sdk.rb +11 -11
- data/test/unit/executable_session_test.rb +40 -0
- data/test/unit/executable_test.rb +25 -0
- data/test/unit/sprout_test.rb +198 -198
- data/test/unit/unix_system_test.rb +5 -2
- metadata +5 -7
- data/test/fixtures/executable/windows_line_endings +0 -47
- data/test/fixtures/user/mxmlc_crlf +0 -3
- data/test/unit/daemon_test.rb +0 -93
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.10.pre
|
data/lib/sprout.rb
CHANGED
data/lib/sprout/executable.rb
CHANGED
@@ -236,6 +236,22 @@ module Sprout
|
|
236
236
|
initialize_parameters
|
237
237
|
end
|
238
238
|
|
239
|
+
def stdout=(io)
|
240
|
+
@stdout = io
|
241
|
+
end
|
242
|
+
|
243
|
+
def stdout
|
244
|
+
@stdout ||= Sprout.stdout
|
245
|
+
end
|
246
|
+
|
247
|
+
def stderr=(io)
|
248
|
+
@stderr = io
|
249
|
+
end
|
250
|
+
|
251
|
+
def stderr
|
252
|
+
@stderr ||= Sprout.stderr
|
253
|
+
end
|
254
|
+
|
239
255
|
def parse! commandline_options
|
240
256
|
begin
|
241
257
|
option_parser.parse! commandline_options
|
@@ -333,6 +349,47 @@ module Sprout
|
|
333
349
|
@default_file_expression ||= Sprout::Executable::DEFAULT_FILE_EXPRESSION
|
334
350
|
end
|
335
351
|
|
352
|
+
##
|
353
|
+
# Replace the binary that will be executed with a path to one of your
|
354
|
+
# choosing. This work is usually performed on the yielded instance from
|
355
|
+
# Rake like:
|
356
|
+
#
|
357
|
+
# mxmlc 'bin/SomeProject.swf' do |t|
|
358
|
+
# t.input = 'src/SomeProject.as'
|
359
|
+
# t.binary_path = 'vendor/sdks/4.1.0/bin/mxmlc'
|
360
|
+
# end
|
361
|
+
#
|
362
|
+
# It's important to note that Windows systems will check
|
363
|
+
# the provided path for binaries of the same name that end with .exe
|
364
|
+
# and .bat and will use those in place of the provided name if they
|
365
|
+
# exist.
|
366
|
+
#
|
367
|
+
# For example, if you set +binary_path+ to:
|
368
|
+
#
|
369
|
+
# t.binary_path = 'vendor/sdks/4.0.1/bin/mxmlc'
|
370
|
+
#
|
371
|
+
# And there is a similarly-named file in the same directory, but named:
|
372
|
+
#
|
373
|
+
# vendor/sdks/4.0.1/bin/mxmlc.bat
|
374
|
+
#
|
375
|
+
# Windows systems will execute this .bat file.
|
376
|
+
#
|
377
|
+
#
|
378
|
+
# @param path [File] Path to the executable binary that should be executed instead
|
379
|
+
# of whatever Sprout.load would have provided. If a value is set here, Sprout.load
|
380
|
+
# will not be called.
|
381
|
+
# @returns [File] Path to the executable binary that should be executed.
|
382
|
+
#
|
383
|
+
def binary_path=(path)
|
384
|
+
@binary_path = path
|
385
|
+
end
|
386
|
+
|
387
|
+
##
|
388
|
+
# @returns [File] Path to the executable binary that should be executed.
|
389
|
+
def binary_path
|
390
|
+
@binary_path ||= Sprout::Executable.load(executable, pkg_name, pkg_version).path
|
391
|
+
end
|
392
|
+
|
336
393
|
protected
|
337
394
|
|
338
395
|
##
|
@@ -417,10 +474,6 @@ module Sprout
|
|
417
474
|
|
418
475
|
private
|
419
476
|
|
420
|
-
def binary_path
|
421
|
-
Sprout::Executable.load(executable, pkg_name, pkg_version).path
|
422
|
-
end
|
423
|
-
|
424
477
|
def handle_library_prerequisites items
|
425
478
|
items.each do |task_name|
|
426
479
|
t = Rake.application[task_name]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
module Sprout
|
2
|
+
module Sprout::Executable
|
3
3
|
|
4
4
|
##
|
5
5
|
# The Sprout::Daemon class exposes the Domain Specific Language
|
@@ -43,7 +43,7 @@ module Sprout
|
|
43
43
|
# t.do_something_else
|
44
44
|
# end
|
45
45
|
#
|
46
|
-
class
|
46
|
+
class Session < Base
|
47
47
|
|
48
48
|
class << self
|
49
49
|
|
@@ -146,12 +146,22 @@ module Sprout
|
|
146
146
|
# via stdin, stdout and stderr.
|
147
147
|
attr_reader :process_runner
|
148
148
|
|
149
|
+
##
|
150
|
+
# The Thread that contains the forked running process.
|
151
|
+
attr_reader :process_thread
|
152
|
+
|
149
153
|
##
|
150
154
|
# @return [Array<Hash>] Return or create a new array.
|
151
155
|
def action_stack
|
152
156
|
@action_stack ||= []
|
153
157
|
end
|
154
158
|
|
159
|
+
##
|
160
|
+
# @return [Boolean] If executable is awaiting input.
|
161
|
+
def prompted?
|
162
|
+
@prompted
|
163
|
+
end
|
164
|
+
|
155
165
|
##
|
156
166
|
# Execute the Daemon executable, followed
|
157
167
|
# by the collection of stored actions in
|
@@ -187,8 +197,7 @@ module Sprout
|
|
187
197
|
@process_launched = true
|
188
198
|
wait_for_prompt
|
189
199
|
execute_actions
|
190
|
-
|
191
|
-
wait if should_wait
|
200
|
+
handle_user_input if should_wait
|
192
201
|
end
|
193
202
|
|
194
203
|
def wait
|
@@ -201,75 +210,32 @@ module Sprout
|
|
201
210
|
# an input prompt, so that another action
|
202
211
|
# can be submitted, or user input can be
|
203
212
|
# collected.
|
204
|
-
def wait_for_prompt
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
stderr = read_from process_runner.e, fake_stderr
|
210
|
-
stdout = read_from process_runner.r, fake_stdout, expected_prompt
|
211
|
-
stdout.join && stderr.kill
|
212
|
-
|
213
|
-
stdout_str = fake_stdout.read
|
214
|
-
stderr_str = fake_stderr.read
|
215
|
-
|
216
|
-
Sprout.stderr.printf(stderr_str)
|
217
|
-
Sprout.stdout.printf(stdout_str)
|
213
|
+
def wait_for_prompt
|
214
|
+
while process_thread.alive? && !prompted?
|
215
|
+
sleep 0.2
|
216
|
+
end
|
217
|
+
process_thread.alive?
|
218
218
|
end
|
219
219
|
|
220
220
|
##
|
221
221
|
# Expose the running process to manual
|
222
222
|
# input on the terminal, and write stdout
|
223
223
|
# back to the user.
|
224
|
-
def
|
225
|
-
while
|
226
|
-
|
227
|
-
|
228
|
-
|
224
|
+
def handle_user_input
|
225
|
+
while true
|
226
|
+
begin
|
227
|
+
break if !wait_for_prompt
|
228
|
+
input = $stdin.gets.chomp!
|
229
|
+
execute_action(input, true)
|
230
|
+
rescue SignalException => e
|
231
|
+
return false
|
232
|
+
end
|
229
233
|
end
|
234
|
+
wait
|
230
235
|
end
|
231
236
|
|
232
237
|
protected
|
233
238
|
|
234
|
-
##
|
235
|
-
# This is the ass-hattery that we need to go
|
236
|
-
# through in order to read from stderr and
|
237
|
-
# stdout from a long-running process without
|
238
|
-
# eternally blocking the parent - and providing
|
239
|
-
# the ability to asynchronously write into the
|
240
|
-
# input stream.
|
241
|
-
#
|
242
|
-
# If you know how to better do this accross
|
243
|
-
# platforms (mac, win and nix) without losing
|
244
|
-
# information (i.e. combining stderr and stdout
|
245
|
-
# into a single stream), I'm all ears!
|
246
|
-
def read_from pipe, to, until_prompt=nil
|
247
|
-
line = ''
|
248
|
-
lines = ''
|
249
|
-
Thread.new do
|
250
|
-
Thread.current.abort_on_exception = true
|
251
|
-
while true do
|
252
|
-
break if pipe.eof?
|
253
|
-
char = pipe.readpartial 1
|
254
|
-
line << char
|
255
|
-
if char == "\n"
|
256
|
-
to.puts line
|
257
|
-
to.flush
|
258
|
-
lines << line
|
259
|
-
line = ''
|
260
|
-
end
|
261
|
-
if !until_prompt.nil? && line.match(until_prompt)
|
262
|
-
lines << line
|
263
|
-
to.printf line
|
264
|
-
to.flush
|
265
|
-
line = ''
|
266
|
-
break
|
267
|
-
end
|
268
|
-
end
|
269
|
-
lines
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
239
|
def process_launched?
|
274
240
|
@process_launched
|
275
241
|
end
|
@@ -305,7 +271,19 @@ module Sprout
|
|
305
271
|
#
|
306
272
|
# @return [Thread]
|
307
273
|
def system_execute binary, params
|
308
|
-
|
274
|
+
# Combine the stderr and stdout for long-lived
|
275
|
+
# processes so that they are both written to
|
276
|
+
# stdout, this allows us to collect these streams
|
277
|
+
# without threads or blocking eternally.
|
278
|
+
#
|
279
|
+
# Thanks to https://github.com/apinstein for this
|
280
|
+
# solution.
|
281
|
+
#params = "#{params} " + '2>&1'
|
282
|
+
@process_thread = Sprout.current_system.execute_thread binary, params, prompt do |message|
|
283
|
+
Sprout.stdout.printf message
|
284
|
+
@prompted = true if prompt.match message
|
285
|
+
end
|
286
|
+
@process_runner = process_thread['runner']
|
309
287
|
end
|
310
288
|
|
311
289
|
private
|
@@ -314,7 +292,7 @@ module Sprout
|
|
314
292
|
# Execute the collection of provided actions.
|
315
293
|
def execute_actions
|
316
294
|
action_stack.each do |action|
|
317
|
-
|
295
|
+
execute_action(action)
|
318
296
|
end
|
319
297
|
@action_stack = []
|
320
298
|
end
|
@@ -323,9 +301,11 @@ module Sprout
|
|
323
301
|
# Execute a single action.
|
324
302
|
def execute_action action, silence=false
|
325
303
|
action = action.strip
|
326
|
-
|
327
|
-
|
328
|
-
|
304
|
+
if wait_for_prompt
|
305
|
+
stdout.puts(action) unless silence
|
306
|
+
@prompted = false
|
307
|
+
process_runner.puts action
|
308
|
+
end
|
329
309
|
end
|
330
310
|
|
331
311
|
end
|
@@ -77,21 +77,23 @@ module Sprout
|
|
77
77
|
##
|
78
78
|
# Kill the process.
|
79
79
|
def kill
|
80
|
-
|
80
|
+
update_status 9
|
81
81
|
end
|
82
82
|
|
83
83
|
##
|
84
84
|
# Close the process
|
85
85
|
def close
|
86
|
-
|
86
|
+
w.close_write
|
87
87
|
end
|
88
88
|
|
89
89
|
##
|
90
90
|
# Send an update signal to the process.
|
91
|
-
|
91
|
+
#
|
92
|
+
# @param sig [Integer] The signal to send, default 0 (or no action requested)
|
93
|
+
def update_status sig=0
|
92
94
|
pid_int = Integer("#{ @pid }")
|
93
95
|
begin
|
94
|
-
Process::kill
|
96
|
+
Process::kill sig, pid_int
|
95
97
|
true
|
96
98
|
rescue Errno::ESRCH
|
97
99
|
false
|
@@ -95,21 +95,60 @@ module Sprout::System
|
|
95
95
|
end
|
96
96
|
|
97
97
|
##
|
98
|
-
# Execute a new process in a separate thread
|
98
|
+
# Execute a new process in a separate thread and yield whatever output
|
99
|
+
# is written to its stderr and stdout.
|
99
100
|
#
|
100
|
-
|
101
|
-
|
102
|
-
|
101
|
+
# @return [Sprout::ProcessRunner]
|
102
|
+
# @param tool [File] Path to the executable.
|
103
|
+
# @param options [String] The command line options that the executable accepts.
|
104
|
+
# @param prompt [Regex] The prompt that will trigger the listener block to be called.
|
105
|
+
# @yield [String] Message that was received from the process, called when #prompt is encountered.
|
106
|
+
#
|
107
|
+
def execute_thread tool, options='', prompt=nil, &block
|
108
|
+
t = Thread.new do
|
103
109
|
Thread.current.abort_on_exception = true
|
104
110
|
runner = execute_silent(tool, options)
|
111
|
+
Thread.current['runner'] = runner
|
112
|
+
out = read_from runner.r, prompt, &block
|
113
|
+
err = read_from runner.e, prompt, &block
|
114
|
+
out.join && err.kill
|
105
115
|
end
|
116
|
+
|
106
117
|
# Wait for the runner to be created
|
107
118
|
# before returning a nil reference
|
108
119
|
# that never gets populated...
|
109
|
-
while runner.nil? do
|
120
|
+
while t['runner'].nil? do
|
110
121
|
sleep(0.1)
|
111
122
|
end
|
112
|
-
|
123
|
+
|
124
|
+
t
|
125
|
+
end
|
126
|
+
|
127
|
+
def read_from pipe, prompt, &block
|
128
|
+
Thread.new do
|
129
|
+
Thread.current.abort_on_exception = true
|
130
|
+
lines = ''
|
131
|
+
line = ''
|
132
|
+
pipe.sync = true
|
133
|
+
pipe.each_char do |char|
|
134
|
+
break if pipe.closed?
|
135
|
+
line << char
|
136
|
+
|
137
|
+
if line.match prompt
|
138
|
+
yield line if block_given?
|
139
|
+
lines << line
|
140
|
+
lines = ''
|
141
|
+
line = ''
|
142
|
+
next
|
143
|
+
end
|
144
|
+
|
145
|
+
if char == "\n"
|
146
|
+
lines << line
|
147
|
+
yield line if block_given?
|
148
|
+
line = ''
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
113
152
|
end
|
114
153
|
|
115
154
|
##
|
data/lib/sprout/test_helper.rb
CHANGED
@@ -233,25 +233,6 @@ module Sprout::TestHelper
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
-
##
|
237
|
-
# Update the Sprout::Executable registry so that subsequent
|
238
|
-
# requests for an executable return a fake one instead of
|
239
|
-
# the real one.
|
240
|
-
#
|
241
|
-
# @param exe [Symbol] The executable that will be sent to the load request (e.g. :fdb, :mxmlc, etc.).
|
242
|
-
# @param fake_name [String] The path to the fake executable that should be used.
|
243
|
-
#
|
244
|
-
# Note: Calling this method will set a mocha expectation
|
245
|
-
# that the Sprout::Executable.load method will be called during
|
246
|
-
# the test method run.
|
247
|
-
#
|
248
|
-
def insert_fake_executable fake
|
249
|
-
# Comment the following and install the flashsdk gem
|
250
|
-
# to run test against actual executables instead of fakes:
|
251
|
-
path_response = OpenStruct.new(:path => fake)
|
252
|
-
Sprout::Executable.expects(:load).returns path_response
|
253
|
-
end
|
254
|
-
|
255
236
|
##
|
256
237
|
# Create and/or return sprout/cache directory relative to the
|
257
238
|
# fixtures folder nearest the file that calls this method.
|
@@ -1,25 +1,21 @@
|
|
1
1
|
|
2
2
|
module Sprout
|
3
3
|
|
4
|
-
class FDB <
|
4
|
+
class FDB < Executable::Session
|
5
5
|
|
6
6
|
set :default_prefix, '-'
|
7
7
|
|
8
8
|
##
|
9
|
-
#
|
10
|
-
|
9
|
+
# Set the binary_path explicitly since we
|
10
|
+
# don't need pkg_name or pkg_version for test environment.
|
11
|
+
#set :binary_path, 'test/fixtures/executable/flex3sdk_gem/fdb'
|
12
|
+
#Toggle comments to use the real exe:
|
13
|
+
set :binary_path, '~/Library/Sprouts/1.1/cache/flex4/4.1.0.16076/bin/fdb'
|
11
14
|
|
12
|
-
##
|
13
|
-
# The default gem version
|
14
|
-
set :pkg_version, '>= 4.1.0.pre'
|
15
|
-
|
16
|
-
##
|
17
|
-
# The default executable target
|
18
|
-
set :executable, :fdb
|
19
15
|
|
20
16
|
##
|
21
17
|
# The regex for when input can be accepted again.
|
22
|
-
set :prompt, /^\(fdb\) |\(y or n\) /
|
18
|
+
set :prompt, /^\(fdb\) |\(y or n\) |^Waiting for Player to connect/
|
23
19
|
|
24
20
|
##
|
25
21
|
# Force the fake to write to stderr:
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
exe = OpenStruct.new({
|
3
|
-
:name => :mxmlc,
|
4
|
-
:pkg_name => 'flex3sdk',
|
5
|
-
:pkg_version => '3.0.0',
|
6
|
-
:platform => :universal,
|
7
|
-
:path => File.join(File.dirname(__FILE__), 'mxmlc')
|
8
|
-
})
|
9
|
-
|
10
|
-
Sprout::Executable.register exe
|
11
|
-
|
1
|
+
|
2
|
+
exe = OpenStruct.new({
|
3
|
+
:name => :mxmlc,
|
4
|
+
:pkg_name => 'flex3sdk',
|
5
|
+
:pkg_version => '3.0.0',
|
6
|
+
:platform => :universal,
|
7
|
+
:path => File.join(File.dirname(__FILE__), 'mxmlc')
|
8
|
+
})
|
9
|
+
|
10
|
+
Sprout::Executable.register exe
|
11
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'fixtures/executable/fdb'
|
3
|
+
|
4
|
+
class ExecutableSessionTest < Test::Unit::TestCase
|
5
|
+
include Sprout::TestHelper
|
6
|
+
|
7
|
+
context "a new executable session" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
# Uncomment the following to see interactive sessions:
|
11
|
+
#Sprout.stdout = $stdout
|
12
|
+
#Sprout.stderr = $stderr
|
13
|
+
end
|
14
|
+
|
15
|
+
should "execute without shell params" do
|
16
|
+
@fdb = Sprout::FDB.new
|
17
|
+
# Comment to hit real FDB:
|
18
|
+
@fdb.binary_path = File.join fixtures, 'executable', 'flex3sdk_gem', 'fdb'
|
19
|
+
|
20
|
+
@fdb.execute false
|
21
|
+
@fdb.run
|
22
|
+
|
23
|
+
# Uncomment if you are on OSX and want to
|
24
|
+
# test the real FDB while running a real SWF:
|
25
|
+
#Kernel.system 'open ~/Projects/Sprouts/flashsdk/test/fixtures/flashplayer/AsUnit\ Runner.swf'
|
26
|
+
#@fdb.wait_for_prompt
|
27
|
+
|
28
|
+
@fdb.break "AsUnitRunner:12"
|
29
|
+
|
30
|
+
@fdb.continue
|
31
|
+
@fdb.continue
|
32
|
+
|
33
|
+
#@fdb.handle_user_input
|
34
|
+
@fdb.quit
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -44,6 +44,26 @@ class ExecutableTest < Test::Unit::TestCase
|
|
44
44
|
assert_equal "---string-param=string1", @tool.to_shell
|
45
45
|
end
|
46
46
|
|
47
|
+
should "create default stdout" do
|
48
|
+
assert_equal Sprout.stdout, @tool.stdout
|
49
|
+
end
|
50
|
+
|
51
|
+
should "accept custom stdout" do
|
52
|
+
out = StringIO.new
|
53
|
+
@tool.stdout = out
|
54
|
+
assert_equal out, @tool.stdout
|
55
|
+
end
|
56
|
+
|
57
|
+
should "create default stderr" do
|
58
|
+
assert_equal Sprout.stderr, @tool.stderr
|
59
|
+
end
|
60
|
+
|
61
|
+
should "accept custom stderr" do
|
62
|
+
err = StringIO.new
|
63
|
+
@tool.stderr = err
|
64
|
+
assert_equal err, @tool.stderr
|
65
|
+
end
|
66
|
+
|
47
67
|
should "not share parameter values across instances" do
|
48
68
|
first = FakeOtherExecutableTask.new
|
49
69
|
second = FakeOtherExecutableTask.new
|
@@ -172,6 +192,11 @@ class ExecutableTest < Test::Unit::TestCase
|
|
172
192
|
end
|
173
193
|
end
|
174
194
|
|
195
|
+
should "accept custom binary_path" do
|
196
|
+
@tool.binary_path = @mxmlc_executable
|
197
|
+
assert_equal @mxmlc_executable, @tool.binary_path
|
198
|
+
end
|
199
|
+
|
175
200
|
should "accept default gem name" do
|
176
201
|
assert_equal 'flex4sdk', @tool.pkg_name
|
177
202
|
end
|
data/test/unit/sprout_test.rb
CHANGED
@@ -1,198 +1,198 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SproutTest < Test::Unit::TestCase
|
4
|
-
include Sprout::TestHelper
|
5
|
-
|
6
|
-
context "The Sprout::TestHelper" do
|
7
|
-
|
8
|
-
context "find_fixtures" do
|
9
|
-
|
10
|
-
setup do
|
11
|
-
@from = File.join(fixtures, 'sprout_test_case', 'test', 'other')
|
12
|
-
@expected_fixtures = File.join(fixtures, 'sprout_test_case', 'test', 'fixtures')
|
13
|
-
FileUtils.makedirs @from
|
14
|
-
end
|
15
|
-
|
16
|
-
teardown do
|
17
|
-
remove_file File.join(fixtures, 'sprout_test_case')
|
18
|
-
end
|
19
|
-
|
20
|
-
should "find_fixtures within a test folder" do
|
21
|
-
result = find_fixtures @from
|
22
|
-
assert_equal @expected_fixtures, result
|
23
|
-
end
|
24
|
-
|
25
|
-
should "throw if reaches system root" do
|
26
|
-
assert_raises Sprout::Errors::UsageError do
|
27
|
-
find_fixtures File.dirname(File.dirname(File.dirname(__FILE__)))
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
context "Errors" do
|
35
|
-
include Sprout::Errors
|
36
|
-
|
37
|
-
[
|
38
|
-
ArchiveUnpackerError,
|
39
|
-
DestinationExistsError,
|
40
|
-
ExecutionError,
|
41
|
-
ExecutableRegistrationError,
|
42
|
-
MissingExecutableError,
|
43
|
-
ProcessRunnerError,
|
44
|
-
SproutError,
|
45
|
-
ExecutableError,
|
46
|
-
UnknownArchiveType,
|
47
|
-
UsageError,
|
48
|
-
VersionRequirementNotMetError
|
49
|
-
].each do |error|
|
50
|
-
|
51
|
-
should "be available to instantiate a #{error.to_s}" do
|
52
|
-
error.new
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "cache" do
|
58
|
-
setup do
|
59
|
-
@library = File.join(fixtures, 'sprout')
|
60
|
-
end
|
61
|
-
|
62
|
-
should "find library from system" do
|
63
|
-
user = Sprout::System::OSXSystem.new
|
64
|
-
user.stubs(:library).returns @library
|
65
|
-
Sprout.stubs(:current_system).returns user
|
66
|
-
|
67
|
-
expected_cache = File.join(@library, 'Sprouts', Sprout::VERSION::MAJOR_MINOR, 'cache')
|
68
|
-
assert_equal expected_cache, Sprout.cache
|
69
|
-
end
|
70
|
-
|
71
|
-
should "find library for unix system" do
|
72
|
-
user = Sprout::System::UnixSystem.new
|
73
|
-
user.stubs(:library).returns @library
|
74
|
-
Sprout.stubs(:current_system).returns user
|
75
|
-
|
76
|
-
expected_cache = File.join(@library, '.sprouts', Sprout::VERSION::MAJOR_MINOR, 'cache')
|
77
|
-
assert_equal expected_cache, Sprout.cache
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "A new sprout test case" do
|
82
|
-
|
83
|
-
should "be able to work as a particular user but then revert when done" do
|
84
|
-
original_class = Sprout.current_system.class
|
85
|
-
|
86
|
-
block_called = false
|
87
|
-
|
88
|
-
systems = [
|
89
|
-
Sprout::System::VistaSystem,
|
90
|
-
Sprout::System::WinNixSystem,
|
91
|
-
Sprout::System::WinSystem,
|
92
|
-
Sprout::System::JavaSystem,
|
93
|
-
Sprout::System::OSXSystem,
|
94
|
-
Sprout::System::UnixSystem
|
95
|
-
]
|
96
|
-
incr = 0
|
97
|
-
|
98
|
-
as_each_system do |sys|
|
99
|
-
block_called = true
|
100
|
-
assert_equal systems[incr], Sprout.current_system.class, "Requests for the current system should yield a UNIX system"
|
101
|
-
incr += 1
|
102
|
-
end
|
103
|
-
|
104
|
-
assert_equal original_class, Sprout.current_system.class
|
105
|
-
assert block_called, "Ensure the block was yielded to..."
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "Executables" do
|
110
|
-
|
111
|
-
context "with a sandboxed load path" do
|
112
|
-
|
113
|
-
setup do
|
114
|
-
path = File.join fixtures, "executable", "flex3sdk_gem"
|
115
|
-
$:.unshift path
|
116
|
-
end
|
117
|
-
|
118
|
-
teardown do
|
119
|
-
$:.shift
|
120
|
-
end
|
121
|
-
|
122
|
-
should "find requested executables" do
|
123
|
-
path = Sprout::Executable.load(:mxmlc, 'flex3sdk', '>= 3.0.0').path
|
124
|
-
assert_not_nil path
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context "with a stubbed load path" do
|
129
|
-
|
130
|
-
setup do
|
131
|
-
Sprout::Executable.stubs(:require_ruby_package).returns true
|
132
|
-
@path = 'test/fixtures/process_runner/chmod_script.sh'
|
133
|
-
end
|
134
|
-
|
135
|
-
should "work when registered with different gem names" do
|
136
|
-
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
137
|
-
register_executable :mxmlc, 'flex4sdk', '1.0.pre', @path
|
138
|
-
end
|
139
|
-
|
140
|
-
should "work when registered with different exe names" do
|
141
|
-
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
142
|
-
register_executable :compc, 'flex3sdk', '1.0.pre', @path
|
143
|
-
end
|
144
|
-
|
145
|
-
context "that are registered" do
|
146
|
-
should "work the first time" do
|
147
|
-
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
148
|
-
end
|
149
|
-
|
150
|
-
context "and then requested" do
|
151
|
-
setup do
|
152
|
-
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
153
|
-
end
|
154
|
-
|
155
|
-
should "succeed if the executable is available and no version specified" do
|
156
|
-
assert_equal @path, Sprout::Executable.load(:mxmlc, 'flex3sdk').path
|
157
|
-
end
|
158
|
-
|
159
|
-
should "succeed if version requirement is met" do
|
160
|
-
assert_equal @path, Sprout::Executable.load(:mxmlc, 'flex3sdk', '>= 1.0.pre').path
|
161
|
-
end
|
162
|
-
|
163
|
-
should "fail if version requirement is not met" do
|
164
|
-
assert_raises Sprout::Errors::LoadError do
|
165
|
-
Sprout::Executable.load :mxmlc, 'flex3sdk', '>= 1.1.0'
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
context "that are not registered" do
|
173
|
-
should "fail when requested" do
|
174
|
-
assert_raises Sprout::Errors::LoadError do
|
175
|
-
Sprout::Executable.load :mxmlc, 'flex3sdk'
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
private
|
184
|
-
|
185
|
-
def register_executable name, pkg_name, pkg_version, path, platform=:universal
|
186
|
-
exe = OpenStruct.new({
|
187
|
-
:name => name,
|
188
|
-
:path => path,
|
189
|
-
:pkg_name => pkg_name,
|
190
|
-
:pkg_version => pkg_version,
|
191
|
-
:platform => platform
|
192
|
-
})
|
193
|
-
Sprout::Executable.register exe
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SproutTest < Test::Unit::TestCase
|
4
|
+
include Sprout::TestHelper
|
5
|
+
|
6
|
+
context "The Sprout::TestHelper" do
|
7
|
+
|
8
|
+
context "find_fixtures" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
@from = File.join(fixtures, 'sprout_test_case', 'test', 'other')
|
12
|
+
@expected_fixtures = File.join(fixtures, 'sprout_test_case', 'test', 'fixtures')
|
13
|
+
FileUtils.makedirs @from
|
14
|
+
end
|
15
|
+
|
16
|
+
teardown do
|
17
|
+
remove_file File.join(fixtures, 'sprout_test_case')
|
18
|
+
end
|
19
|
+
|
20
|
+
should "find_fixtures within a test folder" do
|
21
|
+
result = find_fixtures @from
|
22
|
+
assert_equal @expected_fixtures, result
|
23
|
+
end
|
24
|
+
|
25
|
+
should "throw if reaches system root" do
|
26
|
+
assert_raises Sprout::Errors::UsageError do
|
27
|
+
find_fixtures File.dirname(File.dirname(File.dirname(__FILE__)))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context "Errors" do
|
35
|
+
include Sprout::Errors
|
36
|
+
|
37
|
+
[
|
38
|
+
ArchiveUnpackerError,
|
39
|
+
DestinationExistsError,
|
40
|
+
ExecutionError,
|
41
|
+
ExecutableRegistrationError,
|
42
|
+
MissingExecutableError,
|
43
|
+
ProcessRunnerError,
|
44
|
+
SproutError,
|
45
|
+
ExecutableError,
|
46
|
+
UnknownArchiveType,
|
47
|
+
UsageError,
|
48
|
+
VersionRequirementNotMetError
|
49
|
+
].each do |error|
|
50
|
+
|
51
|
+
should "be available to instantiate a #{error.to_s}" do
|
52
|
+
error.new
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "cache" do
|
58
|
+
setup do
|
59
|
+
@library = File.join(fixtures, 'sprout')
|
60
|
+
end
|
61
|
+
|
62
|
+
should "find library from system" do
|
63
|
+
user = Sprout::System::OSXSystem.new
|
64
|
+
user.stubs(:library).returns @library
|
65
|
+
Sprout.stubs(:current_system).returns user
|
66
|
+
|
67
|
+
expected_cache = File.join(@library, 'Sprouts', Sprout::VERSION::MAJOR_MINOR, 'cache')
|
68
|
+
assert_equal expected_cache, Sprout.cache
|
69
|
+
end
|
70
|
+
|
71
|
+
should "find library for unix system" do
|
72
|
+
user = Sprout::System::UnixSystem.new
|
73
|
+
user.stubs(:library).returns @library
|
74
|
+
Sprout.stubs(:current_system).returns user
|
75
|
+
|
76
|
+
expected_cache = File.join(@library, '.sprouts', Sprout::VERSION::MAJOR_MINOR, 'cache')
|
77
|
+
assert_equal expected_cache, Sprout.cache
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "A new sprout test case" do
|
82
|
+
|
83
|
+
should "be able to work as a particular user but then revert when done" do
|
84
|
+
original_class = Sprout.current_system.class
|
85
|
+
|
86
|
+
block_called = false
|
87
|
+
|
88
|
+
systems = [
|
89
|
+
Sprout::System::VistaSystem,
|
90
|
+
Sprout::System::WinNixSystem,
|
91
|
+
Sprout::System::WinSystem,
|
92
|
+
Sprout::System::JavaSystem,
|
93
|
+
Sprout::System::OSXSystem,
|
94
|
+
Sprout::System::UnixSystem
|
95
|
+
]
|
96
|
+
incr = 0
|
97
|
+
|
98
|
+
as_each_system do |sys|
|
99
|
+
block_called = true
|
100
|
+
assert_equal systems[incr], Sprout.current_system.class, "Requests for the current system should yield a UNIX system"
|
101
|
+
incr += 1
|
102
|
+
end
|
103
|
+
|
104
|
+
assert_equal original_class, Sprout.current_system.class
|
105
|
+
assert block_called, "Ensure the block was yielded to..."
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "Executables" do
|
110
|
+
|
111
|
+
context "with a sandboxed load path" do
|
112
|
+
|
113
|
+
setup do
|
114
|
+
path = File.join fixtures, "executable", "flex3sdk_gem"
|
115
|
+
$:.unshift path
|
116
|
+
end
|
117
|
+
|
118
|
+
teardown do
|
119
|
+
$:.shift
|
120
|
+
end
|
121
|
+
|
122
|
+
should "find requested executables" do
|
123
|
+
path = Sprout::Executable.load(:mxmlc, 'flex3sdk', '>= 3.0.0').path
|
124
|
+
assert_not_nil path
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "with a stubbed load path" do
|
129
|
+
|
130
|
+
setup do
|
131
|
+
Sprout::Executable.stubs(:require_ruby_package).returns true
|
132
|
+
@path = 'test/fixtures/process_runner/chmod_script.sh'
|
133
|
+
end
|
134
|
+
|
135
|
+
should "work when registered with different gem names" do
|
136
|
+
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
137
|
+
register_executable :mxmlc, 'flex4sdk', '1.0.pre', @path
|
138
|
+
end
|
139
|
+
|
140
|
+
should "work when registered with different exe names" do
|
141
|
+
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
142
|
+
register_executable :compc, 'flex3sdk', '1.0.pre', @path
|
143
|
+
end
|
144
|
+
|
145
|
+
context "that are registered" do
|
146
|
+
should "work the first time" do
|
147
|
+
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
148
|
+
end
|
149
|
+
|
150
|
+
context "and then requested" do
|
151
|
+
setup do
|
152
|
+
register_executable :mxmlc, 'flex3sdk', '1.0.pre', @path
|
153
|
+
end
|
154
|
+
|
155
|
+
should "succeed if the executable is available and no version specified" do
|
156
|
+
assert_equal @path, Sprout::Executable.load(:mxmlc, 'flex3sdk').path
|
157
|
+
end
|
158
|
+
|
159
|
+
should "succeed if version requirement is met" do
|
160
|
+
assert_equal @path, Sprout::Executable.load(:mxmlc, 'flex3sdk', '>= 1.0.pre').path
|
161
|
+
end
|
162
|
+
|
163
|
+
should "fail if version requirement is not met" do
|
164
|
+
assert_raises Sprout::Errors::LoadError do
|
165
|
+
Sprout::Executable.load :mxmlc, 'flex3sdk', '>= 1.1.0'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context "that are not registered" do
|
173
|
+
should "fail when requested" do
|
174
|
+
assert_raises Sprout::Errors::LoadError do
|
175
|
+
Sprout::Executable.load :mxmlc, 'flex3sdk'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
def register_executable name, pkg_name, pkg_version, path, platform=:universal
|
186
|
+
exe = OpenStruct.new({
|
187
|
+
:name => name,
|
188
|
+
:path => path,
|
189
|
+
:pkg_name => pkg_name,
|
190
|
+
:pkg_version => pkg_version,
|
191
|
+
:platform => platform
|
192
|
+
})
|
193
|
+
Sprout::Executable.register exe
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
|
@@ -33,9 +33,11 @@ class UnixSystemTest < Test::Unit::TestCase
|
|
33
33
|
context "when fed an application with windows line endings" do
|
34
34
|
|
35
35
|
setup do
|
36
|
-
|
36
|
+
exe_with_crlf = "#!/bin/sh\r\n\r\n################################################################################\r\n##\r\n## ADOBE SYSTEMS INCORPORATED\r\n## Copyright 2007 Adobe Systems Incorporated\r\n## All Rights Reserved.\r\n##\r\n## NOTICE: Adobe permits you to use, modify, and distribute this file\r\n## in accordance with the terms of the license agreement accompanying it.\r\n##\r\n################################################################################\r\n\r\n#\r\n# mxmlc launch script for unix. On windows, mxmlc.exe is used and\r\n# java settings are managed in jvm.config in this directory.\r\n#\r\n\r\ncase `uname` in\r\n CYGWIN*)\r\n OS=\"Windows\"\r\n ;;\r\n *)\r\n OS=Unix\r\nesac\r\n\r\nif [ $OS = \"Windows\" ]; then\r\n # set FLEX_HOME relative to mxmlc if not set\r\n test \"$FLEX_HOME\" = \"\" && {\r\n FLEX_HOME=`dirname $0`/..\r\n FLEX_HOME=`cygpath -m $FLEX_HOME`\r\n }\r\n\r\nelif [ $OS = \"Unix\" ]; then\r\n\r\n # set FLEX_HOME relative to mxmlc if not set\r\n test \"$FLEX_HOME\" = \"\" && {\r\n FLEX_HOME=`dirname \"$0\"`/..\r\n }\r\n\r\nfi\r\n\r\n# don't use $FLEX_HOME in this variable because it may contain spaces,\r\n# instead put it on the java args directly, with double-quotes around it\r\nVMARGS=\"-Xmx384m -Dsun.io.useCanonCaches=false\"\r\n\r\njava $VMARGS -jar \"$FLEX_HOME/lib/mxmlc.jar\" +flexlib=\"$FLEX_HOME/frameworks\" \"$@\"\r\n"
|
37
37
|
@target = File.join fixtures, 'executable', 'windows_line_endings.tmp'
|
38
|
-
|
38
|
+
File.open(@target, 'wb+') do |f|
|
39
|
+
f.write exe_with_crlf
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
teardown do
|
@@ -50,3 +52,4 @@ class UnixSystemTest < Test::Unit::TestCase
|
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
55
|
+
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 10
|
9
9
|
- pre
|
10
|
-
version: 1.1.
|
10
|
+
version: 1.1.10.pre
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luke Bayes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-18 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -211,7 +211,6 @@ files:
|
|
211
211
|
- lib/sprout/archive_unpacker.rb
|
212
212
|
- lib/sprout/command_line.rb
|
213
213
|
- lib/sprout/concern.rb
|
214
|
-
- lib/sprout/daemon.rb
|
215
214
|
- lib/sprout/dir.rb
|
216
215
|
- lib/sprout/errors.rb
|
217
216
|
- lib/sprout/executable/base.rb
|
@@ -224,6 +223,7 @@ files:
|
|
224
223
|
- lib/sprout/executable/parameter_factory.rb
|
225
224
|
- lib/sprout/executable/path.rb
|
226
225
|
- lib/sprout/executable/paths.rb
|
226
|
+
- lib/sprout/executable/session.rb
|
227
227
|
- lib/sprout/executable/string_param.rb
|
228
228
|
- lib/sprout/executable/strings.rb
|
229
229
|
- lib/sprout/executable/url.rb
|
@@ -325,7 +325,6 @@ files:
|
|
325
325
|
- test/fixtures/executable/src/Main.as
|
326
326
|
- test/fixtures/executable/subclass/executable_subclass.rb
|
327
327
|
- test/fixtures/executable/subclass/executable_superclass.rb
|
328
|
-
- test/fixtures/executable/windows_line_endings
|
329
328
|
- test/fixtures/generators/song_generator.rb
|
330
329
|
- test/fixtures/generators/song_subclass/least_favorite.rb
|
331
330
|
- test/fixtures/generators/song_subclass/templates/Song.txt
|
@@ -357,13 +356,12 @@ files:
|
|
357
356
|
- test/fixtures/specification/flexunit4.sproutspec
|
358
357
|
- test/fixtures/specification/lib/as3reflection/Reflection.as
|
359
358
|
- test/fixtures/specification/src/AsUnit.as
|
360
|
-
- test/fixtures/user/mxmlc_crlf
|
361
359
|
- test/unit/archive_unpacker_test.rb
|
362
360
|
- test/unit/boolean_param_test.rb
|
363
361
|
- test/unit/command_line_test.rb
|
364
|
-
- test/unit/daemon_test.rb
|
365
362
|
- test/unit/executable_option_parser_test.rb
|
366
363
|
- test/unit/executable_param_test.rb
|
364
|
+
- test/unit/executable_session_test.rb
|
367
365
|
- test/unit/executable_test.rb
|
368
366
|
- test/unit/fake_executable_task.rb
|
369
367
|
- test/unit/fake_other_executable.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
################################################################################
|
4
|
-
##
|
5
|
-
## ADOBE SYSTEMS INCORPORATED
|
6
|
-
## Copyright 2007 Adobe Systems Incorporated
|
7
|
-
## All Rights Reserved.
|
8
|
-
##
|
9
|
-
## NOTICE: Adobe permits you to use, modify, and distribute this file
|
10
|
-
## in accordance with the terms of the license agreement accompanying it.
|
11
|
-
##
|
12
|
-
################################################################################
|
13
|
-
|
14
|
-
#
|
15
|
-
# mxmlc launch script for unix. On windows, mxmlc.exe is used and
|
16
|
-
# java settings are managed in jvm.config in this directory.
|
17
|
-
#
|
18
|
-
|
19
|
-
case `uname` in
|
20
|
-
CYGWIN*)
|
21
|
-
OS="Windows"
|
22
|
-
;;
|
23
|
-
*)
|
24
|
-
OS=Unix
|
25
|
-
esac
|
26
|
-
|
27
|
-
if [ $OS = "Windows" ]; then
|
28
|
-
# set FLEX_HOME relative to mxmlc if not set
|
29
|
-
test "$FLEX_HOME" = "" && {
|
30
|
-
FLEX_HOME=`dirname $0`/..
|
31
|
-
FLEX_HOME=`cygpath -m $FLEX_HOME`
|
32
|
-
}
|
33
|
-
|
34
|
-
elif [ $OS = "Unix" ]; then
|
35
|
-
|
36
|
-
# set FLEX_HOME relative to mxmlc if not set
|
37
|
-
test "$FLEX_HOME" = "" && {
|
38
|
-
FLEX_HOME=`dirname "$0"`/..
|
39
|
-
}
|
40
|
-
|
41
|
-
fi
|
42
|
-
|
43
|
-
# don't use $FLEX_HOME in this variable because it may contain spaces,
|
44
|
-
# instead put it on the java args directly, with double-quotes around it
|
45
|
-
VMARGS="-Xmx384m -Dsun.io.useCanonCaches=false"
|
46
|
-
|
47
|
-
java $VMARGS -jar "$FLEX_HOME/lib/mxmlc.jar" +flexlib="$FLEX_HOME/frameworks" "$@"
|
data/test/unit/daemon_test.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'fixtures/executable/fdb'
|
3
|
-
|
4
|
-
class DaemonTest < Test::Unit::TestCase
|
5
|
-
include Sprout::TestHelper
|
6
|
-
|
7
|
-
context "a new daemon delegate" do
|
8
|
-
|
9
|
-
setup do
|
10
|
-
# Uncomment the following to see interactive sessions:
|
11
|
-
#Sprout.stdout = $stdout
|
12
|
-
#Sprout.stderr = $stderr
|
13
|
-
|
14
|
-
# Comment the following and install the flashsdk
|
15
|
-
# to run test against actual fdb:
|
16
|
-
insert_fake_executable File.join(fixtures, 'executable', 'flex3sdk_gem', 'fdb')
|
17
|
-
end
|
18
|
-
|
19
|
-
should "execute without shell params" do
|
20
|
-
@fdb = Sprout::FDB.new
|
21
|
-
# For some reason, using mocha expectations are
|
22
|
-
# actually stubbing the methods and breaking this
|
23
|
-
# test. Not sure what I'm doing wrong here...
|
24
|
-
#@fdb.expects(:execute_action).at_least(6)
|
25
|
-
@fdb.run
|
26
|
-
@fdb.break "AsUnitRunner:12"
|
27
|
-
@fdb.continue
|
28
|
-
@fdb.kill
|
29
|
-
@fdb.confirm
|
30
|
-
@fdb.quit
|
31
|
-
@fdb.execute
|
32
|
-
end
|
33
|
-
|
34
|
-
should "open and wait for real-time interactions" do
|
35
|
-
@fdb = Sprout::FDB.new
|
36
|
-
# For some reason, using mocha expectations are
|
37
|
-
# actually stubbing the methods and breaking this
|
38
|
-
# test. Not sure what I'm doing wrong here...
|
39
|
-
#@fdb.expects(:execute_action).at_least(6)
|
40
|
-
@fdb.execute false
|
41
|
-
@fdb.run
|
42
|
-
@fdb.break "AsUnitRunner:12"
|
43
|
-
@fdb.continue
|
44
|
-
@fdb.kill
|
45
|
-
@fdb.confirm
|
46
|
-
@fdb.quit
|
47
|
-
@fdb.wait # wait for actions to finish.
|
48
|
-
end
|
49
|
-
|
50
|
-
should "print errors" do
|
51
|
-
##
|
52
|
-
# Collect the messages sent to stderr:
|
53
|
-
|
54
|
-
@fdb = Sprout::FDB.new
|
55
|
-
# For some reason, using mocha expectations are
|
56
|
-
# actually stubbing the methods and breaking this
|
57
|
-
# test. Not sure what I'm doing wrong here...
|
58
|
-
#@fdb.expects(:execute_action).at_least(6)
|
59
|
-
@fdb.execute false
|
60
|
-
@fdb.run_with_error
|
61
|
-
@fdb.quit
|
62
|
-
@fdb.wait # wait for actions to finish.
|
63
|
-
|
64
|
-
assert_matches /This is an error!/, Sprout.stderr.read
|
65
|
-
end
|
66
|
-
|
67
|
-
should "execute from rake task" do
|
68
|
-
f = fdb :fdb_debug do |t|
|
69
|
-
t.run
|
70
|
-
t.break "AsUnitRunner:12"
|
71
|
-
t.continue
|
72
|
-
t.kill
|
73
|
-
t.confirm
|
74
|
-
t.quit
|
75
|
-
end
|
76
|
-
|
77
|
-
f.execute
|
78
|
-
|
79
|
-
# NOTE: If this call raises, then the
|
80
|
-
# Executable.update_rake_task_name method
|
81
|
-
# must have changed, and the Daemon override
|
82
|
-
# is no longer preventing non-File tasks
|
83
|
-
# from being added to the CLEAN collection.
|
84
|
-
#
|
85
|
-
# Adding this as a message to the error would
|
86
|
-
# not display for some reason...
|
87
|
-
assert_equal 0, CLEAN.size
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|