patir 0.6.1 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +10 -1
- data/README.txt +2 -3
- data/Rakefile +2 -1
- data/docu/index.html +16 -1
- data/lib/patir/base.rb +1 -5
- data/lib/patir/command.rb +30 -22
- data/test/test_patir_base.rb +4 -5
- data/test/test_patir_command.rb +17 -7
- metadata +20 -7
data/History.txt
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
+
==0.6.4 / 2009-09-4
|
2
|
+
* context parameter added to Command#run
|
3
|
+
|
4
|
+
==0.6.3
|
5
|
+
* Repository restructured (git is used internally so the svn repository matches now the master branch)
|
6
|
+
* Cleanup. Some obsolete code was removed
|
7
|
+
* Unit tests clarified
|
8
|
+
==0.6.2
|
9
|
+
* RubyCommand and ShellCommand are now more robust handling StandardError exceptions.
|
1
10
|
==0.6.1
|
2
11
|
* RubyCommand failure logs are now clearer no more 'RubyCommand failed:' redundancies.
|
3
12
|
* RubyCommand: Backtrace added to error output if $DEBUG=true
|
4
13
|
==0.6.0
|
5
|
-
* RubyCommand now sets success when the block runs to the end. Block returns values
|
14
|
+
* RubyCommand now sets success when the block runs to the end. Block returns values are ignored. To indicate failure raise an exception.
|
6
15
|
|
7
16
|
== 0.5.8 /2008-09-18
|
8
17
|
* CommandSequence status updates set the correct status
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,8 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
require 'patir/base'
|
6
6
|
|
7
|
-
Hoe.
|
7
|
+
Hoe.spec('patir') do |p|
|
8
|
+
p.version = Patir::Version::STRING
|
8
9
|
p.author = "Vassilis Rizopoulos"
|
9
10
|
p.email = "riva@braveworld.net"
|
10
11
|
p.summary = 'patir (Project Automation Tools in Ruby) provides libraries for use in automation tools'
|
data/docu/index.html
CHANGED
@@ -38,13 +38,28 @@
|
|
38
38
|
You can browse the <a href="http://patir.rubyforge.org/svn/">patir subversion repository</a>.
|
39
39
|
</p>
|
40
40
|
<p>
|
41
|
-
Like all self-conscious developers the patir team does not claim infalibility. Neither are we
|
41
|
+
Like all self-conscious developers the patir team does not claim infalibility. Neither are we too proud to have our flaws pointed out, so if and when you find a bug, please post a report in our <a href="http://rubyforge.org/tracker/?group_id=3597">Bugtracker</a>
|
42
42
|
</p>
|
43
43
|
</div>
|
44
44
|
</div>
|
45
45
|
<div id="leftpanel">
|
46
46
|
<div align="justify" class="graypanel">
|
47
47
|
<span class="smalltitle">News</span><br /><br />
|
48
|
+
<span class="smallredtext">17 July 2009</span><br />
|
49
|
+
<span class="bodytext">rutema_web v1.0.0 is out!</span><br />
|
50
|
+
<a href="rutemaweb100.html" class="smallgraytext">More...</a><br /><br />
|
51
|
+
<span class="smallredtext">28 November 2008</span><br />
|
52
|
+
<span class="bodytext">rutemaweb v0.9.4 is out!</span><br />
|
53
|
+
<a href="rutemaweb094.html" class="smallgraytext">More...</a><br /><br />
|
54
|
+
<span class="smallredtext">11 November 2008</span><br />
|
55
|
+
<span class="bodytext">rutema v1.0.3 is out!</span><br />
|
56
|
+
<a href="rutema103.html" class="smallgraytext">More...</a><br /><br />
|
57
|
+
<span class="smallredtext">28 October 2008</span><br />
|
58
|
+
<span class="bodytext">rutema_elements v0.1.0 is out!</span><br />
|
59
|
+
<a href="elements010.html" class="smallgraytext">More...</a><br /><br />
|
60
|
+
<span class="smallredtext">10 October 2008</span><br />
|
61
|
+
<span class="bodytext">rutema v1.0.0 is out!</span><br />
|
62
|
+
<a href="rutema100.html" class="smallgraytext">More...</a><br /><br />
|
48
63
|
<span class="smallredtext">9 September 2008</span><br />
|
49
64
|
<span class="bodytext">rutema v0.9.0 is out!</span><br />
|
50
65
|
<a href="rutema090.html" class="smallgraytext">More...</a><br /><br />
|
data/lib/patir/base.rb
CHANGED
@@ -6,17 +6,13 @@ module Patir
|
|
6
6
|
module Version
|
7
7
|
MAJOR=0
|
8
8
|
MINOR=6
|
9
|
-
TINY=
|
9
|
+
TINY=4
|
10
10
|
STRING=[ MAJOR, MINOR, TINY ].join( "." )
|
11
11
|
end
|
12
12
|
#Error thrown usually in initialize methods when missing required parameters
|
13
13
|
#from the initialization hash.
|
14
14
|
class ParameterException<RuntimeError
|
15
15
|
end
|
16
|
-
#creates a drb service URL from an ip and a port number
|
17
|
-
def self.drb_service ip,port
|
18
|
-
return "druby://#{ip}:#{port}"
|
19
|
-
end
|
20
16
|
|
21
17
|
class PatirLoggerFormatter<Logger::Formatter
|
22
18
|
Format="[%s] %5s: %s\n"
|
data/lib/patir/command.rb
CHANGED
@@ -62,7 +62,7 @@ module Patir
|
|
62
62
|
#executes the command and returns the status of the command.
|
63
63
|
#
|
64
64
|
#overwrite this method in classes that include Command
|
65
|
-
def run
|
65
|
+
def run context=nil
|
66
66
|
@status=:success
|
67
67
|
return self.status
|
68
68
|
end
|
@@ -125,28 +125,34 @@ module Patir
|
|
125
125
|
end
|
126
126
|
|
127
127
|
#Executes the shell command and returns the status
|
128
|
-
def run
|
128
|
+
def run context=nil
|
129
129
|
start_time=Time.now
|
130
130
|
super
|
131
|
-
#create the working directory if it does not exist
|
132
|
-
FileUtils::mkdir_p(@working_directory,:verbose=>false)
|
133
|
-
#create the actual command, run it, grab stderr and stdout and set output,error, status and execution time
|
134
|
-
status, @output, @error = systemu(@command,:cwd=>@working_directory)
|
135
|
-
#lets get the status how we want it
|
136
131
|
begin
|
137
|
-
|
138
|
-
|
139
|
-
#
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
132
|
+
#create the working directory if it does not exist
|
133
|
+
FileUtils::mkdir_p(@working_directory,:verbose=>false)
|
134
|
+
#create the actual command, run it, grab stderr and stdout and set output,error, status and execution time
|
135
|
+
status, @output, @error = systemu(@command,:cwd=>@working_directory)
|
136
|
+
#lets get the status how we want it
|
137
|
+
begin
|
138
|
+
exited = status.exited?
|
139
|
+
rescue NotImplementedError
|
140
|
+
# so, JRuby as of version 1.1 does not understand exited?
|
141
|
+
exited = true
|
142
|
+
end
|
143
|
+
if exited
|
144
|
+
if status.exitstatus==0
|
145
|
+
@status=:success
|
146
|
+
else
|
147
|
+
@status=:error
|
148
|
+
end
|
145
149
|
else
|
146
|
-
@status=:
|
150
|
+
@status=:warning
|
147
151
|
end
|
148
|
-
|
149
|
-
@
|
152
|
+
rescue
|
153
|
+
@error<<"\n#{$!.message}"
|
154
|
+
@error<<"\n#{$!.backtrace}" if $DEBUG
|
155
|
+
@status=:error
|
150
156
|
end
|
151
157
|
#set the time it took us
|
152
158
|
@exec_time=Time.now-start_time
|
@@ -200,7 +206,7 @@ module Patir
|
|
200
206
|
#Executes the CommandSequence.
|
201
207
|
#
|
202
208
|
#Will run all step instances in sequence observing the exit strategies on warning/failures
|
203
|
-
def run
|
209
|
+
def run context=nil
|
204
210
|
#set the start time
|
205
211
|
@state.start_time=Time.now
|
206
212
|
#reset the stop time
|
@@ -219,7 +225,7 @@ module Patir
|
|
219
225
|
step.status=:running
|
220
226
|
notify(:sequence_status=>@state)
|
221
227
|
#run it, get the result and notify
|
222
|
-
result=step.run
|
228
|
+
result=step.run(context)
|
223
229
|
@state.step=step
|
224
230
|
step.status=:running
|
225
231
|
notify(:sequence_status=>@state)
|
@@ -268,12 +274,14 @@ module Patir
|
|
268
274
|
bstep.reset
|
269
275
|
#set the extended attributes
|
270
276
|
bstep.number=@steps.size
|
277
|
+
exit_strategy = :fail_on_error unless [:flunk_on_error,:fail_on_warning,:flunk_on_warning].include?(exit_strategy)
|
271
278
|
bstep.strategy=exit_strategy
|
272
279
|
#add it to the lot
|
273
280
|
@steps<<bstep
|
274
281
|
#add it to status as well
|
275
282
|
@state.step=bstep
|
276
283
|
notify(:sequence_status=>@state)
|
284
|
+
return bstep
|
277
285
|
end
|
278
286
|
|
279
287
|
#Resets the status. This will set :not_executed status,
|
@@ -478,7 +486,7 @@ module Patir
|
|
478
486
|
end
|
479
487
|
end
|
480
488
|
#Runs the associated block
|
481
|
-
def run
|
489
|
+
def run context=nil
|
482
490
|
@run=true
|
483
491
|
begin
|
484
492
|
t1=Time.now
|
@@ -486,7 +494,7 @@ module Patir
|
|
486
494
|
@cmd.call(self)
|
487
495
|
@status=:success
|
488
496
|
end
|
489
|
-
rescue
|
497
|
+
rescue StandardError
|
490
498
|
error<<"\n#{$!.message}"
|
491
499
|
error<<"\n#{$!.backtrace}" if $DEBUG
|
492
500
|
@status=:error
|
data/test/test_patir_base.rb
CHANGED
@@ -3,14 +3,12 @@ require 'test/unit'
|
|
3
3
|
require 'patir/base.rb'
|
4
4
|
|
5
5
|
class TestBase<Test::Unit::TestCase
|
6
|
+
TEMP_LOG="temp.log"
|
6
7
|
def teardown
|
7
8
|
#clean up
|
8
|
-
File.delete(
|
9
|
-
end
|
10
|
-
#simple match test
|
11
|
-
def test_drb_service
|
12
|
-
assert_equal("druby://service.host:7000",Patir.drb_service("service.host",7000))
|
9
|
+
File.delete(TEMP_LOG) if File.exists?(TEMP_LOG)
|
13
10
|
end
|
11
|
+
|
14
12
|
#This is not actually testing anything meaningfull but can be expanded when we learn more about
|
15
13
|
#the logger
|
16
14
|
def test_setup_logger
|
@@ -20,6 +18,7 @@ class TestBase<Test::Unit::TestCase
|
|
20
18
|
assert_not_nil(logger)
|
21
19
|
logger=Patir.setup_logger("temp.log",:silent)
|
22
20
|
assert_not_nil(logger)
|
21
|
+
assert(File.exists?(TEMP_LOG), "Log file not created")
|
23
22
|
logger.close
|
24
23
|
end
|
25
24
|
|
data/test/test_patir_command.rb
CHANGED
@@ -8,7 +8,7 @@ end
|
|
8
8
|
|
9
9
|
class MockCommandWarning
|
10
10
|
include Patir::Command
|
11
|
-
def run
|
11
|
+
def run context=nil
|
12
12
|
@status=:warning
|
13
13
|
return :warning
|
14
14
|
end
|
@@ -16,7 +16,7 @@ end
|
|
16
16
|
|
17
17
|
class MockCommandError
|
18
18
|
include Patir::Command
|
19
|
-
def run
|
19
|
+
def run context=nil
|
20
20
|
@status=:error
|
21
21
|
return :error
|
22
22
|
end
|
@@ -118,6 +118,7 @@ class TestCommandSequence<Test::Unit::TestCase
|
|
118
118
|
@error=MockCommandError.new
|
119
119
|
@warning=MockCommandWarning.new
|
120
120
|
end
|
121
|
+
|
121
122
|
def test_normal
|
122
123
|
seq=CommandSequence.new("test")
|
123
124
|
assert(seq.steps.empty?)
|
@@ -129,10 +130,13 @@ class TestCommandSequence<Test::Unit::TestCase
|
|
129
130
|
assert_nothing_raised{seq.run}
|
130
131
|
assert(seq.state.success?)
|
131
132
|
end
|
133
|
+
|
132
134
|
def test_flunk_on_error
|
133
135
|
seq=CommandSequence.new("test")
|
134
136
|
assert(seq.steps.empty?)
|
135
|
-
|
137
|
+
check_step=nil
|
138
|
+
assert_nothing_raised{check_step=seq.add_step(@echo,:flunk_on_error)}
|
139
|
+
assert_equal(:flunk_on_error,check_step.strategy)
|
136
140
|
assert_nothing_raised{seq.add_step(@error,:flunk_on_error)}
|
137
141
|
assert_nothing_raised{seq.add_step(@void,:flunk_on_error)}
|
138
142
|
assert(:not_executed==seq.state.step_state(0)[:status])
|
@@ -150,7 +154,9 @@ class TestCommandSequence<Test::Unit::TestCase
|
|
150
154
|
seq=CommandSequence.new("test")
|
151
155
|
assert(seq.steps.empty?)
|
152
156
|
assert_nothing_raised{seq.add_step(@echo)}
|
153
|
-
|
157
|
+
check_step=nil
|
158
|
+
assert_nothing_raised{check_step=seq.add_step(@error,:fail_on_error)}
|
159
|
+
assert_equal(:fail_on_error,check_step.strategy)
|
154
160
|
assert_nothing_raised{seq.add_step(@void)}
|
155
161
|
assert(:not_executed==seq.state.step_state(0)[:status])
|
156
162
|
assert(:not_executed==seq.state.step_state(1)[:status])
|
@@ -167,7 +173,9 @@ class TestCommandSequence<Test::Unit::TestCase
|
|
167
173
|
seq=CommandSequence.new("test")
|
168
174
|
assert(seq.steps.empty?)
|
169
175
|
assert_nothing_raised{seq.add_step(@echo)}
|
170
|
-
|
176
|
+
check_step=nil
|
177
|
+
assert_nothing_raised{check_step=seq.add_step(@error,:flunk_on_warning)}
|
178
|
+
assert_equal(:flunk_on_warning,check_step.strategy)
|
171
179
|
assert_nothing_raised{seq.add_step(@void)}
|
172
180
|
assert(:not_executed==seq.state.step_state(0)[:status])
|
173
181
|
assert(:not_executed==seq.state.step_state(1)[:status])
|
@@ -184,7 +192,9 @@ class TestCommandSequence<Test::Unit::TestCase
|
|
184
192
|
seq=CommandSequence.new("test")
|
185
193
|
assert(seq.steps.empty?)
|
186
194
|
assert_nothing_raised{seq.add_step(@echo)}
|
187
|
-
|
195
|
+
check_step=nil
|
196
|
+
assert_nothing_raised{check_step=seq.add_step(@warning,:fail_on_warning)}
|
197
|
+
assert_equal(:fail_on_warning,check_step.strategy)
|
188
198
|
assert_nothing_raised{seq.add_step(@void)}
|
189
199
|
assert(:not_executed==seq.state.step_state(0)[:status])
|
190
200
|
assert(:not_executed==seq.state.step_state(1)[:status])
|
@@ -198,7 +208,7 @@ class TestCommandSequence<Test::Unit::TestCase
|
|
198
208
|
end
|
199
209
|
end
|
200
210
|
|
201
|
-
class
|
211
|
+
class TestRubyCommand<Test::Unit::TestCase
|
202
212
|
include Patir
|
203
213
|
def test_normal_ruby
|
204
214
|
cmd=RubyCommand.new("test"){sleep 1}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vassilis Rizopoulos
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-09-04 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,9 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.3.3
|
34
34
|
version:
|
35
|
-
description:
|
35
|
+
description: |-
|
36
|
+
== FEATURES/PROBLEMS:
|
37
|
+
|
38
|
+
* Configuration library for creating Ruby configuration files
|
39
|
+
* Command library abstracting the execution of commands
|
40
|
+
|
41
|
+
== SYNOPSIS:
|
42
|
+
|
43
|
+
patir is the library of common functionality used in the patir projects.
|
44
|
+
This includes a class that allows you to build configuration files in Ruby and a library for command abstraction.
|
45
|
+
|
46
|
+
== REQUIREMENTS:
|
36
47
|
email: riva@braveworld.net
|
37
48
|
executables: []
|
38
49
|
|
@@ -76,7 +87,9 @@ files:
|
|
76
87
|
- docu/rw-scenario.png
|
77
88
|
- docu/screenshots.html
|
78
89
|
has_rdoc: true
|
79
|
-
homepage:
|
90
|
+
homepage:
|
91
|
+
licenses: []
|
92
|
+
|
80
93
|
post_install_message:
|
81
94
|
rdoc_options:
|
82
95
|
- --main
|
@@ -98,9 +111,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
111
|
requirements: []
|
99
112
|
|
100
113
|
rubyforge_project: patir
|
101
|
-
rubygems_version: 1.3.
|
114
|
+
rubygems_version: 1.3.5
|
102
115
|
signing_key:
|
103
|
-
specification_version:
|
116
|
+
specification_version: 3
|
104
117
|
summary: patir (Project Automation Tools in Ruby) provides libraries for use in automation tools
|
105
118
|
test_files:
|
106
119
|
- test/test_patir_base.rb
|