rutema 0.9.3 → 1.0.0
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 -0
- data/Manifest.txt +3 -5
- data/Rakefile +3 -3
- data/bin/rutema_upgrader +74 -0
- data/bin/rutemax +0 -0
- data/distro_test.sh +1 -2
- data/lib/rutema/configuration.rb +1 -30
- data/lib/rutema/gems.rb +3 -1
- data/lib/rutema/model.rb +17 -1
- data/lib/rutema/reporters/activerecord.rb +5 -1
- data/lib/rutema/reporters/email.rb +3 -0
- data/lib/rutema/reporters/text.rb +4 -4
- data/lib/rutema/system.rb +29 -17
- data/test/data/sample09.db +0 -0
- data/test/migration.spec +9 -0
- data/test/rutema.rutema +1 -1
- data/test/rutema.spec +1 -2
- data/test/test_configuration.rb +1 -8
- data/test/test_reporter.rb +35 -11
- data/test/test_system.rb +11 -3
- metadata +9 -12
- data/bin/rutemah +0 -9
- data/lib/rutema/historian.rb +0 -106
- data/test/distro_test/config/database.rutemah +0 -7
- data/test/distro_test/config/jruby.rutemah +0 -7
- data/test/test_historian.rb +0 -82
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 1.0.0 / 2008-10-06
|
2
|
+
* DB schema change: title and description added to scenario table
|
3
|
+
* footer parameter for the email reporter
|
4
|
+
* Specification titles included in the text reports
|
5
|
+
* When parsing multiple specifications a duplicate name will now generate a parser error
|
6
|
+
* rutema_updater upgrades existing databases, check http://patir.rubyforge.org/rutema/update_090_to_100.html
|
7
|
+
* rutemah scrapped
|
8
|
+
* rutemax logs it's version always
|
9
|
+
* activerecord 2.1.1 is now in use
|
10
|
+
|
1
11
|
== 0.9.3 / 2008-09-10
|
2
12
|
* Sorted result summaries in the text and the email reporter
|
3
13
|
* ActiveRecordReporter registration logging
|
data/Manifest.txt
CHANGED
@@ -3,13 +3,12 @@ History.txt
|
|
3
3
|
Manifest.txt
|
4
4
|
README.txt
|
5
5
|
Rakefile
|
6
|
-
bin/rutemah
|
7
6
|
bin/rutemax
|
7
|
+
bin/rutema_upgrader
|
8
8
|
distro_test.sh
|
9
9
|
lib/rutema/configuration.rb
|
10
10
|
lib/rutema/db.rb
|
11
11
|
lib/rutema/gems.rb
|
12
|
-
lib/rutema/historian.rb
|
13
12
|
lib/rutema/model.rb
|
14
13
|
lib/rutema/reporter.rb
|
15
14
|
lib/rutema/reporters/activerecord.rb
|
@@ -19,11 +18,10 @@ lib/rutema/reporters/text.rb
|
|
19
18
|
lib/rutema/specification.rb
|
20
19
|
lib/rutema/system.rb
|
21
20
|
selftest.sh
|
21
|
+
test/data/sample09.db
|
22
22
|
test/distro_test/config/database.rutema
|
23
|
-
test/distro_test/config/database.rutemah
|
24
23
|
test/distro_test/config/full.rutema
|
25
24
|
test/distro_test/config/jruby.rutema
|
26
|
-
test/distro_test/config/jruby.rutemah
|
27
25
|
test/distro_test/config/minimal.rutema
|
28
26
|
test/distro_test/specs/T001.spec
|
29
27
|
test/distro_test/specs/T002.spec
|
@@ -35,8 +33,8 @@ test/distro_test/specs/no_title.spec
|
|
35
33
|
test/distro_test/specs/sample.spec
|
36
34
|
test/rutema.rutema
|
37
35
|
test/rutema.spec
|
36
|
+
test/migration.spec
|
38
37
|
test/test_configuration.rb
|
39
|
-
test/test_historian.rb
|
40
38
|
test/test_model.rb
|
41
39
|
test/test_reporter.rb
|
42
40
|
test/test_specification.rb
|
data/Rakefile
CHANGED
@@ -14,13 +14,13 @@ Hoe.new('rutema', "#{Rutema::Version::STRING}") do |p|
|
|
14
14
|
p.description = p.paragraphs_of('README.txt', 1..5).join("\n\n")
|
15
15
|
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
16
16
|
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
17
|
-
p.extra_deps<<['patir',">=0.
|
17
|
+
p.extra_deps<<['patir',">=0.6.0"]
|
18
18
|
p.extra_deps<<['highline']
|
19
19
|
p.extra_deps<<['mailfactory']
|
20
|
-
p.extra_deps<<['activerecord','=2.
|
20
|
+
p.extra_deps<<['activerecord','=2.1.1']
|
21
21
|
p.extra_deps<<['ruport']
|
22
22
|
p.extra_deps<<['acts_as_reportable']
|
23
|
-
p.spec_extras={:executables=>["rutemax","
|
23
|
+
p.spec_extras={:executables=>["rutemax","rutema_upgrader"],
|
24
24
|
:default_executable=>"rutemax"}
|
25
25
|
end
|
26
26
|
|
data/bin/rutema_upgrader
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright (c) 2008 Vassilis Rizopoulos. All rights reserved.
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rutema/system'
|
4
|
+
require 'patir/base'
|
5
|
+
|
6
|
+
#Parses the command line arguments
|
7
|
+
def parse_command_line args
|
8
|
+
args.options do |opt|
|
9
|
+
opt.on("Usage:")
|
10
|
+
opt.on("rutema_upgrader [options] config_file")
|
11
|
+
opt.on("Options:")
|
12
|
+
opt.on("--debug", "-d","Turns on debug messages") { $DEBUG=true }
|
13
|
+
opt.on("-v", "--version","Displays the version") { $stdout.puts("v#{Version::STRING}");exit 0 }
|
14
|
+
opt.on("--help", "-h", "-?", "This text") { $stdout.puts opt; exit 0 }
|
15
|
+
opt.parse!
|
16
|
+
#and now the rest
|
17
|
+
if args.empty?
|
18
|
+
$stdout.puts opt
|
19
|
+
exit 0
|
20
|
+
else
|
21
|
+
return args.shift
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
logger=Patir.setup_logger
|
26
|
+
config_file=parse_command_line(ARGV)
|
27
|
+
begin
|
28
|
+
raise "No configuration file defined!" if !config_file
|
29
|
+
configuration=Rutema::RutemaXConfigurator.new(config_file,logger).configuration
|
30
|
+
Dir.chdir(File.dirname(config_file)) do
|
31
|
+
coordinator=Rutema::Coordinator.new(configuration,logger)
|
32
|
+
specs=coordinator.parse_all_specifications
|
33
|
+
specifications=Hash.new
|
34
|
+
specs.each do |s|
|
35
|
+
specifications[s.name]=[s.title,s.description]
|
36
|
+
end
|
37
|
+
database=nil
|
38
|
+
configuration.reporters.each do |rep|
|
39
|
+
if rep[:class]==Rutema::ActiveRecordReporter
|
40
|
+
database=rep[:db][:database]
|
41
|
+
break
|
42
|
+
end
|
43
|
+
end
|
44
|
+
if database && File.exists?(database)
|
45
|
+
Rutema.connect_to_ar(database,logger,false)
|
46
|
+
test_scenario=Rutema::Model::Scenario.find(:first)
|
47
|
+
if test_scenario.respond_to?(:title) && test_scenario.respond_to?(:description)
|
48
|
+
logger.info("Schema appears updated")
|
49
|
+
else
|
50
|
+
logger.info("Updating schema")
|
51
|
+
#Rutema::Model::UpgradeV9toV10.up
|
52
|
+
end
|
53
|
+
logger.info("Setting title and description values")
|
54
|
+
Rutema::Model::Scenario.find(:all).each do |sc|
|
55
|
+
if specifications[sc.name]
|
56
|
+
logger.info("Setting columns for #{sc.name}:#{sc.id}")
|
57
|
+
sc.title=specifications[sc.name][0]
|
58
|
+
sc.description=specifications[sc.name][1]
|
59
|
+
sc.save
|
60
|
+
end
|
61
|
+
end
|
62
|
+
else
|
63
|
+
logger.fatal("Database '#{database}' does not exist")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
rescue Patir::ConfigurationException
|
67
|
+
logger.debug($!)
|
68
|
+
logger.fatal("Configuration error '#{$!.message}'")
|
69
|
+
exit 1
|
70
|
+
rescue
|
71
|
+
logger.debug($!)
|
72
|
+
logger.fatal("#{$!.message}")
|
73
|
+
exit 1
|
74
|
+
end
|
data/bin/rutemax
CHANGED
File without changes
|
data/distro_test.sh
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
rutemax -c test/distro_test/config/minimal.rutema
|
3
|
-
rutemax -c test/distro_test/config/database.rutema
|
4
|
-
rutemah -c test/distro_test/config/database.rutemah all
|
3
|
+
rutemax -c test/distro_test/config/database.rutema
|
5
4
|
rutemax -c test/distro_test/config/full.rutema --check
|
6
5
|
rutemax -c test/distro_test/config/full.rutema
|
7
6
|
#rutemax -c test/distro_test/config/minimal.rutema --step
|
data/lib/rutema/configuration.rb
CHANGED
@@ -63,7 +63,6 @@ module Rutema
|
|
63
63
|
|
64
64
|
#Hash values for passing data to the system. It's supposed to be used in the reporters and contain
|
65
65
|
#values such as version numbers, tester names etc.
|
66
|
-
#
|
67
66
|
def context= definition
|
68
67
|
@context||=Hash.new
|
69
68
|
raise Patir::ConfigurationException,"Only accepting hash values as context_data" unless definition.kind_of?(Hash)
|
@@ -72,7 +71,7 @@ module Rutema
|
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
|
-
#Adds the files to the
|
74
|
+
#Adds the files to the specifications available to RutemaX.
|
76
75
|
def tests= array_of_files
|
77
76
|
@tests||=Array.new
|
78
77
|
@tests+=array_of_files
|
@@ -117,18 +116,6 @@ module Rutema
|
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
120
|
-
#This module defines the "configuration directives" used in the configuration of RutemaH
|
121
|
-
module RutemaHConfiguration
|
122
|
-
#The configuration keys for the historian's database. This is adapter dependent.
|
123
|
-
#
|
124
|
-
#Currently SQLite is supported on MRI and h2 on jRuby.
|
125
|
-
#
|
126
|
-
#:database defines the name of the file (or directory for h2) to use for the database and is the only required key.
|
127
|
-
def db= definition
|
128
|
-
raise Patir::ConfigurationException,"required key :database is missing from #{definition}" unless definition[:database]
|
129
|
-
@db=definition
|
130
|
-
end
|
131
|
-
end
|
132
119
|
#This class reads a RutemaX configuration file
|
133
120
|
class RutemaXConfigurator<Patir::Configurator
|
134
121
|
include RutemaXConfiguration
|
@@ -161,20 +148,4 @@ module Rutema
|
|
161
148
|
end
|
162
149
|
end
|
163
150
|
|
164
|
-
#This class reads a RutemaH configuration file
|
165
|
-
class RutemaHConfigurator<RutemaXConfigurator
|
166
|
-
include RutemaHConfiguration
|
167
|
-
def initialize config_file,logger=nil
|
168
|
-
super(config_file,logger)
|
169
|
-
end
|
170
|
-
|
171
|
-
def configuration
|
172
|
-
cfg=super
|
173
|
-
Dir.chdir(File.dirname(config_file)) do |path|
|
174
|
-
@db[:database]=File.expand_path(@db[:database])
|
175
|
-
cfg.db=@db
|
176
|
-
end
|
177
|
-
return cfg
|
178
|
-
end
|
179
|
-
end
|
180
151
|
end
|
data/lib/rutema/gems.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
gem 'activerecord','=2.
|
2
|
+
gem 'activerecord','=2.1.1'
|
3
3
|
require 'active_record'
|
4
|
+
gem 'patir','>=0.5.8'
|
4
5
|
require 'patir/configuration'
|
5
6
|
require 'patir/command'
|
6
7
|
require 'patir/base'
|
8
|
+
|
7
9
|
require 'ruport/acts_as_reportable'
|
8
10
|
require 'mailfactory'
|
9
11
|
require 'highline'
|
data/lib/rutema/model.rb
CHANGED
@@ -32,6 +32,8 @@ module Rutema
|
|
32
32
|
t.column :start_time, :datetime,:null=>false
|
33
33
|
t.column :stop_time, :datetime
|
34
34
|
t.column :version, :string
|
35
|
+
t.column :title, :string
|
36
|
+
t.column :description, :string
|
35
37
|
end
|
36
38
|
|
37
39
|
create_table :steps do |t|
|
@@ -56,7 +58,7 @@ module Rutema
|
|
56
58
|
has_many :scenarios
|
57
59
|
has_many :parse_errors
|
58
60
|
serialize :context
|
59
|
-
acts_as_reportable
|
61
|
+
acts_as_reportable
|
60
62
|
end
|
61
63
|
|
62
64
|
class Scenario<ActiveRecord::Base
|
@@ -74,5 +76,19 @@ module Rutema
|
|
74
76
|
belongs_to :run
|
75
77
|
acts_as_reportable
|
76
78
|
end
|
79
|
+
|
80
|
+
class UpgradeV9toV10<ActiveRecord::Migration
|
81
|
+
def self.up
|
82
|
+
puts("Adding new columns")
|
83
|
+
add_column(:scenarios, :title, :string,{:default=>"title"})
|
84
|
+
add_column(:scenarios, :description, :string,{:default=>"description"})
|
85
|
+
puts("Updating existing scenario entries")
|
86
|
+
Rutema::Model::Scenario.find(:all).each do |sc|
|
87
|
+
puts "Updating scenario #{sc.id}"
|
88
|
+
sc.title="#{name}"
|
89
|
+
sc.description="#{name}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
77
93
|
end
|
78
94
|
end
|
@@ -25,7 +25,7 @@ module Rutema
|
|
25
25
|
@dbfile=database_configuration[:database]
|
26
26
|
end
|
27
27
|
Rutema.connect_to_ar(@dbfile,@logger)
|
28
|
-
@logger.info("Reporter
|
28
|
+
@logger.info("Reporter #{self.to_s} registered")
|
29
29
|
end
|
30
30
|
|
31
31
|
#We get all the data for a Rutema::Model::Run entry in here.
|
@@ -53,8 +53,12 @@ module Rutema
|
|
53
53
|
spec=specifications[scenario.sequence_name]
|
54
54
|
if spec
|
55
55
|
sc.version=spec.version if spec.has_version?
|
56
|
+
sc.title=spec.title
|
57
|
+
sc.description=spec.description
|
56
58
|
else
|
57
59
|
@logger.debug("Could not find specification for #{scenario.sequence_name}")
|
60
|
+
sc.title=scenario.sequence_name
|
61
|
+
sc.description=""
|
58
62
|
end
|
59
63
|
if scenario.strategy==:attended
|
60
64
|
sc.attended=true
|
@@ -43,6 +43,8 @@ module Rutema
|
|
43
43
|
#customize
|
44
44
|
@subject=definition[:subject]
|
45
45
|
@subject||=""
|
46
|
+
@footer=definition[:footer]
|
47
|
+
@footer||=""
|
46
48
|
@logger.info("Reporter '#{self.to_s}' registered")
|
47
49
|
end
|
48
50
|
|
@@ -54,6 +56,7 @@ module Rutema
|
|
54
56
|
def report specifications,runner_states,parse_errors,configuration
|
55
57
|
@mail.subject = "#{@subject}"
|
56
58
|
@mail.text = TextReporter.new.report(specifications,runner_states,parse_errors,configuration)
|
59
|
+
@mail.text << "\n\n#{@footer}"
|
57
60
|
begin
|
58
61
|
if @recipients.empty?
|
59
62
|
@logger.error("No recipients for the report mail")
|
@@ -27,15 +27,15 @@ module Rutema
|
|
27
27
|
msg<<"\nNo scenarios in this run" if runner_states.empty?
|
28
28
|
msg<<"\nOne scenario in the current run:" if runner_states.size==1
|
29
29
|
msg<<"\n#{runner_states.size} scenarios in the current run:" if runner_states.size>1
|
30
|
-
rstates=runner_states.sort_by
|
30
|
+
rstates=runner_states.sort_by do |state|
|
31
|
+
state.sequence_id.to_i
|
32
|
+
end
|
31
33
|
rstates.each do |state|
|
34
|
+
msg<<"\n#{specifications[state.sequence_name].title}" if specifications[state.sequence_name]
|
32
35
|
msg<<"\n#{state.summary}\n---"
|
33
36
|
end
|
34
37
|
return msg
|
35
38
|
end
|
36
|
-
def sorted_scenario_report runner_states
|
37
|
-
|
38
|
-
end
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
data/lib/rutema/system.rb
CHANGED
@@ -9,9 +9,9 @@ require 'rutema/gems'
|
|
9
9
|
module Rutema
|
10
10
|
#This module defines the version numbers for the library
|
11
11
|
module Version
|
12
|
-
MAJOR=
|
13
|
-
MINOR=
|
14
|
-
TINY=
|
12
|
+
MAJOR=1
|
13
|
+
MINOR=0
|
14
|
+
TINY=0
|
15
15
|
STRING=[ MAJOR, MINOR, TINY ].join( "." )
|
16
16
|
end
|
17
17
|
#The Elements module provides the namespace for the various modules adding parser functionality
|
@@ -61,7 +61,11 @@ module Rutema
|
|
61
61
|
class ParserError<RuntimeError
|
62
62
|
end
|
63
63
|
|
64
|
-
#Base class that bombs out when used
|
64
|
+
#Base class that bombs out when used.
|
65
|
+
#
|
66
|
+
#Initialze expects a hash and as a base implementation assigns :logger as the internal logger.
|
67
|
+
#
|
68
|
+
#By default the internal logger will log to the console if no logger is provided.
|
65
69
|
class SpecificationParser
|
66
70
|
attr_reader :configuration
|
67
71
|
def initialize params
|
@@ -313,7 +317,18 @@ module Rutema
|
|
313
317
|
@configuration.context.end_time=Time.now
|
314
318
|
@logger.info("Run completed in #{@configuration.context.end_time-@configuration.context.start_time}s")
|
315
319
|
end
|
316
|
-
|
320
|
+
|
321
|
+
#Parses all specification files defined in the configuration
|
322
|
+
def parse_all_specifications
|
323
|
+
@configuration.tests.collect do |t|
|
324
|
+
begin
|
325
|
+
parse_specification(t)
|
326
|
+
rescue
|
327
|
+
@logger.debug($!)
|
328
|
+
@logger.error($!.message)
|
329
|
+
end
|
330
|
+
end.compact
|
331
|
+
end
|
317
332
|
#Delegates reporting to all configured reporters spawning one thread per reporter
|
318
333
|
#
|
319
334
|
#It then joins the threads and returns when all of them are finished.
|
@@ -377,7 +392,13 @@ module Rutema
|
|
377
392
|
@parsed_files<<filename
|
378
393
|
@parsed_files.uniq!
|
379
394
|
spec=@parser.parse_specification(spec_file)
|
380
|
-
@specifications[spec.name]
|
395
|
+
if @specifications[spec.name]
|
396
|
+
msg="Duplicate specification name '#{spec.name}' in '#{spec_file}'"
|
397
|
+
@logger.error(msg)
|
398
|
+
@parse_errors<<{:filename=>spec_file,:error=>msg}
|
399
|
+
else
|
400
|
+
@specifications[spec.name]=spec
|
401
|
+
end
|
381
402
|
rescue ParserError
|
382
403
|
@logger.error("Error parsing '#{spec_file}': #{$!.message}")
|
383
404
|
@parse_errors<<{:filename=>filename,:error=>$!.message}
|
@@ -389,16 +410,6 @@ module Rutema
|
|
389
410
|
end
|
390
411
|
return spec
|
391
412
|
end
|
392
|
-
def parse_all_specifications
|
393
|
-
@configuration.tests.collect do |t|
|
394
|
-
begin
|
395
|
-
parse_specification(t)
|
396
|
-
rescue
|
397
|
-
@logger.debug($!)
|
398
|
-
@logger.error($!.message)
|
399
|
-
end
|
400
|
-
end.compact
|
401
|
-
end
|
402
413
|
|
403
414
|
def run_scenarios specs
|
404
415
|
specs.compact!
|
@@ -591,6 +602,7 @@ module Rutema
|
|
591
602
|
def initialize command_line_args
|
592
603
|
parse_command_line(command_line_args)
|
593
604
|
@logger=Patir.setup_logger(@log_file)
|
605
|
+
@logger.info("rutemax v#{Version::STRING}")
|
594
606
|
begin
|
595
607
|
raise "No configuration file defined!" if !@config_file
|
596
608
|
@configuration=RutemaXConfigurator.new(@config_file,@logger).configuration
|
@@ -618,7 +630,7 @@ module Rutema
|
|
618
630
|
opt.on("--log FILE", "-l FILE",String,"Redirects the log output to FILE") { |@log_file|}
|
619
631
|
opt.on("--check","Runs just the check test"){@check=true}
|
620
632
|
opt.on("--step","Runs test cases step by step"){@step=true}
|
621
|
-
opt.on("-v", "--version","Displays the version") { $stdout.puts("v#{Version::STRING}");exit 0 }
|
633
|
+
opt.on("-v", "--version","Displays the version") { $stdout.puts("rutemax v#{Version::STRING}");exit 0 }
|
622
634
|
opt.on("--help", "-h", "-?", "This text") { $stdout.puts opt; exit 0 }
|
623
635
|
opt.on("The commands are:")
|
624
636
|
opt.on("\tall - Runs all tests")
|
Binary file
|
data/test/migration.spec
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<specification name="TR002">
|
2
|
+
<title>Migration v0.9 to v1.0</title>
|
3
|
+
<description>Test that the database migration code is succesfull between versions 0.9.0 and 1.0.0</description>
|
4
|
+
<scenario>
|
5
|
+
<command cmd="cp data/sample09.db data/test.db"/>
|
6
|
+
<command cmd="rutema_upgrader data/test.db"/>
|
7
|
+
<command cmd="rm data/test.db"/>
|
8
|
+
</scenario>
|
9
|
+
</specification>
|
data/test/rutema.rutema
CHANGED
data/test/rutema.spec
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
<specification name="TR001">
|
2
2
|
<title>Rutema self hosting test</title>
|
3
|
-
<description>Test that rutemax
|
3
|
+
<description>Test that rutemax is usable as a step in a specification using the distro test example</description>
|
4
4
|
<scenario>
|
5
5
|
<command cmd="rutemax -c distro_test/config/minimal.rutema"/>
|
6
6
|
<command cmd="rutemax -c distro_test/config/database.rutema"/>
|
7
7
|
<command cmd="rutemax -c distro_test/config/database.rutema distro_test/specs/T001.spec"/>
|
8
8
|
<command cmd="rutemax -c distro_test/config/full.rutema"/>
|
9
|
-
<command cmd="rutemah -c distro_test/config/database.rutemah all"/>
|
10
9
|
</scenario>
|
11
10
|
</specification>
|
data/test/test_configuration.rb
CHANGED
@@ -32,14 +32,7 @@ module TestRutema
|
|
32
32
|
assert_not_nil(cfg.tests)
|
33
33
|
assert_not_nil(cfg.context)
|
34
34
|
end
|
35
|
-
|
36
|
-
cfg=nil
|
37
|
-
#load the valid configuration
|
38
|
-
assert_nothing_raised() { cfg=Rutema::RutemaHConfigurator.new("distro_test/config/database.rutemah").configuration}
|
39
|
-
assert_not_nil(cfg.db)
|
40
|
-
assert_nothing_raised() { cfg=Rutema::RutemaHConfigurator.new("distro_test/config/jruby.rutemah").configuration}
|
41
|
-
assert_not_nil(cfg.db)
|
42
|
-
end
|
35
|
+
|
43
36
|
def test_specification_paths
|
44
37
|
cfg=Rutema::RutemaXConfigurator.new("distro_test/config/full.rutema").configuration
|
45
38
|
assert_not_nil(cfg.tests)
|
data/test/test_reporter.rb
CHANGED
@@ -67,33 +67,57 @@ module TestRutema
|
|
67
67
|
st.step=MockCommand.new(2)
|
68
68
|
st.step=MockCommand.new(3)
|
69
69
|
@status=[st]
|
70
|
+
|
70
71
|
end
|
71
72
|
def test_new
|
73
|
+
spec=mock()
|
74
|
+
spec.expects(:title).returns("A test sequence")
|
75
|
+
specs={"test_seq"=>spec}
|
72
76
|
definition={:server=>"localhost",:port=>25,:recipients=>["test"],:sender=>"rutema",:subject=>"test"}
|
73
77
|
r=Rutema::EmailReporter.new(definition)
|
74
78
|
Net::SMTP.expects(:start).times(2)
|
75
|
-
assert_nothing_raised() { puts r.report(
|
76
|
-
assert_nothing_raised() { puts r.report(
|
79
|
+
assert_nothing_raised() { puts r.report(specs,@status,@parse_errors,nil) }
|
80
|
+
assert_nothing_raised() { puts r.report(specs,[],[],nil) }
|
77
81
|
end
|
78
82
|
|
79
83
|
def test_multiple_scenarios
|
84
|
+
#The status mocks
|
80
85
|
status1=mock()
|
81
|
-
status1.expects(:summary).returns("
|
82
|
-
status1.expects(:sequence_id).returns(
|
86
|
+
status1.expects(:summary).returns("test6. Status - error. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - warning\n\t3:'try' - error")
|
87
|
+
status1.expects(:sequence_id).returns(6)
|
88
|
+
status1.expects(:sequence_name).returns("T2").times(2)
|
83
89
|
status2=mock()
|
84
|
-
status2.expects(:summary).returns("
|
85
|
-
status2.expects(:sequence_id).returns(
|
90
|
+
status2.expects(:summary).returns("test10. Status - success. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - success\n\t3:'try' - success")
|
91
|
+
status2.expects(:sequence_id).returns(10)
|
92
|
+
status2.expects(:sequence_name).returns("T1").times(2)
|
86
93
|
status3=mock()
|
87
|
-
status3.expects(:summary).returns("
|
94
|
+
status3.expects(:summary).returns("testNil. Status - success. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - success\n\t3:'try' - success")
|
88
95
|
status3.expects(:sequence_id).returns(nil)
|
96
|
+
status3.expects(:sequence_name).returns(nil)
|
89
97
|
status4=mock()
|
90
|
-
status4.expects(:summary).returns("
|
91
|
-
status4.expects(:sequence_id).returns("
|
92
|
-
|
98
|
+
status4.expects(:summary).returns("test10s. Status - success. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - success\n\t3:'try' - success")
|
99
|
+
status4.expects(:sequence_id).returns("10s")
|
100
|
+
status4.expects(:sequence_name).returns("Setup").times(2)
|
101
|
+
status5=mock()
|
102
|
+
status5.expects(:summary).returns("test60. Status - error. States 3\nStep status summary:\n\t1:'echo' - success\n\t2:'check' - warning\n\t3:'try' - error")
|
103
|
+
status5.expects(:sequence_id).returns(60)
|
104
|
+
status5.expects(:sequence_name).returns("T1").times(2)
|
105
|
+
stati=[status1,status2,status3,status4,status5]
|
106
|
+
#mock the mailing code
|
93
107
|
definition={:server=>"localhost",:port=>25,:recipients=>["test"],:sender=>"rutema",:subject=>"test"}
|
94
108
|
r=Rutema::EmailReporter.new(definition)
|
95
109
|
Net::SMTP.expects(:start)
|
96
|
-
|
110
|
+
#The specification mocks
|
111
|
+
spec1=mock()
|
112
|
+
spec1.expects(:title).times(2).returns("T1")
|
113
|
+
spec2=mock()
|
114
|
+
spec2.expects(:title).returns("T2")
|
115
|
+
spec3=mock()
|
116
|
+
spec3.expects(:title).returns("Setup")
|
117
|
+
specs={"T1"=>spec1,
|
118
|
+
"T2"=>spec2,
|
119
|
+
"Setup"=>spec3}
|
120
|
+
assert_nothing_raised() { puts r.report(specs,stati,@parse_errors,nil) }
|
97
121
|
end
|
98
122
|
end
|
99
123
|
end
|
data/test/test_system.rb
CHANGED
@@ -120,19 +120,27 @@ EOT
|
|
120
120
|
conf=OpenStruct.new(:parser=>{:class=>Rutema::BaseXMLParser},
|
121
121
|
:tools=>{},
|
122
122
|
:paths=>{},
|
123
|
-
:tests=>[],
|
123
|
+
:tests=>["distro_test/specs/sample.spec","distro_test/specs/duplicate_name.spec"],
|
124
124
|
:reporters=>[],
|
125
125
|
:context=>OpenStruct.new)
|
126
126
|
coord=nil
|
127
|
-
assert_nothing_raised() { coord=Rutema::Coordinator.new(conf) }
|
128
127
|
assert_nothing_raised() do
|
128
|
+
coord=Rutema::Coordinator.new(conf)
|
129
129
|
coord.run(:all)
|
130
|
+
assert_equal(1,coord.parse_errors.size)
|
131
|
+
coord=Rutema::Coordinator.new(conf)
|
130
132
|
coord.run(:attended)
|
133
|
+
assert_equal(1,coord.parse_errors.size)
|
134
|
+
coord=Rutema::Coordinator.new(conf)
|
131
135
|
coord.run(:unattended)
|
136
|
+
assert_equal(1,coord.parse_errors.size)
|
137
|
+
coord=Rutema::Coordinator.new(conf)
|
132
138
|
coord.run("distro_test/specs/sample.spec")
|
139
|
+
assert_equal(0,coord.parse_errors.size)
|
140
|
+
coord=Rutema::Coordinator.new(conf)
|
133
141
|
coord.run("distro_test/specs/no_title.spec")
|
142
|
+
assert_equal(1,coord.parse_errors.size)
|
134
143
|
end
|
135
|
-
assert_equal(1,coord.parse_errors.size)
|
136
144
|
puts coord.to_s if $DEBUG
|
137
145
|
end
|
138
146
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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: 2008-
|
12
|
+
date: 2008-10-06 00:00:00 +02:00
|
13
13
|
default_executable: rutemax
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.6.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.1.1
|
54
54
|
version:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ruport
|
@@ -86,7 +86,7 @@ description: "== DESCRIPTION: rutema is a test execution tool with a twist. It a
|
|
86
86
|
email: riva@braveworld.net
|
87
87
|
executables:
|
88
88
|
- rutemax
|
89
|
-
-
|
89
|
+
- rutema_upgrader
|
90
90
|
extensions: []
|
91
91
|
|
92
92
|
extra_rdoc_files:
|
@@ -100,13 +100,12 @@ files:
|
|
100
100
|
- Manifest.txt
|
101
101
|
- README.txt
|
102
102
|
- Rakefile
|
103
|
-
- bin/rutemah
|
104
103
|
- bin/rutemax
|
104
|
+
- bin/rutema_upgrader
|
105
105
|
- distro_test.sh
|
106
106
|
- lib/rutema/configuration.rb
|
107
107
|
- lib/rutema/db.rb
|
108
108
|
- lib/rutema/gems.rb
|
109
|
-
- lib/rutema/historian.rb
|
110
109
|
- lib/rutema/model.rb
|
111
110
|
- lib/rutema/reporter.rb
|
112
111
|
- lib/rutema/reporters/activerecord.rb
|
@@ -116,11 +115,10 @@ files:
|
|
116
115
|
- lib/rutema/specification.rb
|
117
116
|
- lib/rutema/system.rb
|
118
117
|
- selftest.sh
|
118
|
+
- test/data/sample09.db
|
119
119
|
- test/distro_test/config/database.rutema
|
120
|
-
- test/distro_test/config/database.rutemah
|
121
120
|
- test/distro_test/config/full.rutema
|
122
121
|
- test/distro_test/config/jruby.rutema
|
123
|
-
- test/distro_test/config/jruby.rutemah
|
124
122
|
- test/distro_test/config/minimal.rutema
|
125
123
|
- test/distro_test/specs/T001.spec
|
126
124
|
- test/distro_test/specs/T002.spec
|
@@ -132,8 +130,8 @@ files:
|
|
132
130
|
- test/distro_test/specs/sample.spec
|
133
131
|
- test/rutema.rutema
|
134
132
|
- test/rutema.spec
|
133
|
+
- test/migration.spec
|
135
134
|
- test/test_configuration.rb
|
136
|
-
- test/test_historian.rb
|
137
135
|
- test/test_model.rb
|
138
136
|
- test/test_reporter.rb
|
139
137
|
- test/test_specification.rb
|
@@ -161,13 +159,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
159
|
requirements: []
|
162
160
|
|
163
161
|
rubyforge_project: patir
|
164
|
-
rubygems_version: 1.
|
162
|
+
rubygems_version: 1.3.0
|
165
163
|
signing_key:
|
166
164
|
specification_version: 2
|
167
165
|
summary: rutema is a test execution and management framework for heterogeneous testing environments
|
168
166
|
test_files:
|
169
167
|
- test/test_configuration.rb
|
170
|
-
- test/test_historian.rb
|
171
168
|
- test/test_model.rb
|
172
169
|
- test/test_reporter.rb
|
173
170
|
- test/test_specification.rb
|
data/bin/rutemah
DELETED
data/lib/rutema/historian.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
# Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__),"..")
|
3
|
-
require 'rutema/model'
|
4
|
-
require 'rutema/system'
|
5
|
-
require 'rutema/db'
|
6
|
-
require 'rutema/gems'
|
7
|
-
|
8
|
-
module Rutema
|
9
|
-
#The "historian" application class
|
10
|
-
#
|
11
|
-
#RutemaH provides reports for test results over time using the data stored by the ActiveRecordReporter
|
12
|
-
class RutemaH
|
13
|
-
require 'optparse'
|
14
|
-
def initialize command_line_args
|
15
|
-
parse_command_line(command_line_args)
|
16
|
-
logger=Patir.setup_logger(@log_file)
|
17
|
-
begin
|
18
|
-
raise "No configuration file defined!" if !@config_file
|
19
|
-
configuration=RutemaHConfigurator.new(@config_file,logger).configuration
|
20
|
-
historian=Historian.new(configuration,logger)
|
21
|
-
puts historian.history(@command)
|
22
|
-
rescue Patir::ConfigurationException
|
23
|
-
logger.debug($!)
|
24
|
-
logger.fatal("Configuration error '#{$!.message}'")
|
25
|
-
exit 1
|
26
|
-
rescue
|
27
|
-
logger.debug($!)
|
28
|
-
logger.fatal("#{$!.message}")
|
29
|
-
exit 1
|
30
|
-
end
|
31
|
-
end
|
32
|
-
private
|
33
|
-
def parse_command_line args
|
34
|
-
args.options do |opt|
|
35
|
-
opt.on("Usage:")
|
36
|
-
opt.on("rutemah [options] -c CONFIG command")
|
37
|
-
opt.on("Options:")
|
38
|
-
opt.on("--debug", "-d","Turns on debug messages") { $DEBUG=true }
|
39
|
-
opt.on("--config FILE", "-c FILE",String,"Loads the configuration from FILE") { |@config_file|}
|
40
|
-
opt.on("--log FILE", "-l FILE",String,"Redirects the log output to FILE") { |@log_file|}
|
41
|
-
opt.on("-v", "--version","Displays the version") { $stdout.puts("v#{Version::STRING}");exit 0 }
|
42
|
-
opt.on("--help", "-h", "-?", "This text") { $stdout.puts opt; exit 0 }
|
43
|
-
opt.on("Commands are:")
|
44
|
-
opt.on("all - lists all entries in the database")
|
45
|
-
opt.on("\"testname\" - lists all tests runs for the given test name")
|
46
|
-
opt.parse!
|
47
|
-
#and now the rest
|
48
|
-
if args.empty?
|
49
|
-
$stdout.puts opt
|
50
|
-
exit 0
|
51
|
-
else
|
52
|
-
@command=args.shift
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end#parse_command_line
|
56
|
-
end
|
57
|
-
|
58
|
-
class Historian
|
59
|
-
def initialize configuration,logger=nil
|
60
|
-
@logger=logger
|
61
|
-
@logger||=Patir.setup_logger
|
62
|
-
@configuration=configuration
|
63
|
-
Rutema.connect_to_ar(@configuration.db[:database],@logger,false)
|
64
|
-
end
|
65
|
-
|
66
|
-
def history mode
|
67
|
-
begin
|
68
|
-
case mode
|
69
|
-
when "all"
|
70
|
-
table=Model::Scenario.report_table(:all)
|
71
|
-
if table.empty?
|
72
|
-
@logger.warn("No entries found")
|
73
|
-
else
|
74
|
-
ret=Ruport::Data::Grouping(beautify(table),:by=>"run_id")
|
75
|
-
end
|
76
|
-
when String
|
77
|
-
ret=per_spec(mode)
|
78
|
-
end
|
79
|
-
rescue
|
80
|
-
@logger.debug($!)
|
81
|
-
@logger.error("Could not retrieve scenario data from the database")
|
82
|
-
end
|
83
|
-
return ret
|
84
|
-
end
|
85
|
-
private
|
86
|
-
def beautify table
|
87
|
-
@logger.debug("Beautifying...")
|
88
|
-
table.reorder("run_id","name","status","attended","version","start_time","stop_time")
|
89
|
-
table.replace_column("version") {|r| r.version ? r.version : "N/A"}
|
90
|
-
table.replace_column("attended") {|r| r.attended=="t" ? "yes" : "no"}
|
91
|
-
table.replace_column("start_time") {|r| r.stop_time ? r.start_time : nil}
|
92
|
-
return table
|
93
|
-
end
|
94
|
-
def per_spec spec_name
|
95
|
-
@logger.debug("History of #{spec_name}")
|
96
|
-
table=Model::Scenario.report_table(:all,:conditions=>"name = '#{spec_name}'",:except=>["id","number"])
|
97
|
-
if table.empty?
|
98
|
-
@logger.warn("No test run records found for #{spec_name}")
|
99
|
-
nil
|
100
|
-
else
|
101
|
-
beautify(table)
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
#include the configuration from database.rutema
|
2
|
-
configuration.load_from_file("database.rutema")
|
3
|
-
#This is the verbose version of the configuration entry:
|
4
|
-
#configuration.db={:database=>"sample.db",:adapter=>"sqlite3"}
|
5
|
-
#For the time being the adapter is being automatically set according to the platform we're running on, so the :adapter is ignored
|
6
|
-
#SQLite for MRI and h2 for jRuby
|
7
|
-
configuration.db={:database=>"sample.db"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
#include the configuration from database.rutema
|
2
|
-
configuration.load_from_file("database.rutema")
|
3
|
-
#This is the verbose version of the configuration entry:
|
4
|
-
#configuration.db=:database=>"db/h2",:adapter=>"jdbch2"}
|
5
|
-
#For the time being the adapter is being automatically set according to the platform we're running on, so the :adapter is ignored
|
6
|
-
#SQLite for MRI and h2 for jRuby
|
7
|
-
configuration.db={:database=>"db/h2"}
|
data/test/test_historian.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
require 'test/unit'
|
3
|
-
require 'ostruct'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'rutema/historian'
|
6
|
-
#$DEBUG=true
|
7
|
-
module TestRutema
|
8
|
-
class TestHistorian<Test::Unit::TestCase
|
9
|
-
def setup
|
10
|
-
@configuration=OpenStruct.new
|
11
|
-
@configuration.db={:database=>":memory:"}
|
12
|
-
@configuration.db={:database=>"db/h2"} if RUBY_PLATFORM =~ /java/
|
13
|
-
end
|
14
|
-
def teardown
|
15
|
-
ActiveRecord::Base.remove_connection
|
16
|
-
FileUtils.rm_rf("db/") if File.exists?("db/")
|
17
|
-
end
|
18
|
-
def test_history
|
19
|
-
assert_nothing_raised() do
|
20
|
-
h=Rutema::Historian.new(@configuration)
|
21
|
-
Rutema::Model::Schema.up
|
22
|
-
a_bunch_of_data
|
23
|
-
assert_not_nil( h.history("all"), "There should be some history there" )
|
24
|
-
assert_not_nil(h.history("TC001"), "TC001 should have some history" )
|
25
|
-
assert_nil(h.history("test5"), "No history expected of test5" )
|
26
|
-
assert_not_nil( h.history("all") )
|
27
|
-
assert_not_nil( h.history("TC002") )
|
28
|
-
end
|
29
|
-
end
|
30
|
-
def test_no_db
|
31
|
-
ActiveRecord::Base.remove_connection
|
32
|
-
if RUBY_PLATFORM =~ /java/
|
33
|
-
@configuration.db={:database=>"foo",:adapter=>"jdbch2"}
|
34
|
-
else
|
35
|
-
@configuration.db={:database=>"foo",:adapter=>"sqlite3"}
|
36
|
-
|
37
|
-
end
|
38
|
-
assert_nothing_raised() do
|
39
|
-
h=Rutema::Historian.new(@configuration)
|
40
|
-
assert_nothing_raised() { h.history("all")}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def a_bunch_of_data
|
45
|
-
runs=[]
|
46
|
-
runs<<Rutema::Model::Run.new(:context=>{:version=>"0.4a"},:scenarios=>success_scenarios)
|
47
|
-
runs<<Rutema::Model::Run.new(:context=>{:version=>"0.4b"},:scenarios=>success_scenarios)
|
48
|
-
runs<<Rutema::Model::Run.new(:context=>{:version=>"0.4c"},:scenarios=>failure_scenarios)
|
49
|
-
runs.each{|r| r.save}
|
50
|
-
end
|
51
|
-
def success_scenarios
|
52
|
-
scenarios=[]
|
53
|
-
1.upto(2) do |i|
|
54
|
-
steps=[]
|
55
|
-
steps<<Rutema::Model::Step.new(:name=>"hard",:number=>1,:status=>"success",
|
56
|
-
:output=>"the first step is hard",:error=>"",:duration=>1)
|
57
|
-
steps<<Rutema::Model::Step.new(:name=>"easy",:number=>2,:status=>"success",
|
58
|
-
:output=>"the next step is easy",:error=>"",:duration=>1)
|
59
|
-
scenarios<<Rutema::Model::Scenario.new(:name=>"TC00#{i}",:version=>"100",
|
60
|
-
:attended=>false,:status=>"success",
|
61
|
-
:start_time=>(Time.now-10000*i),:stop_time=>(Time.now-10000*i),
|
62
|
-
:steps=>steps)
|
63
|
-
end
|
64
|
-
return scenarios
|
65
|
-
end
|
66
|
-
def failure_scenarios
|
67
|
-
failed_step=Rutema::Model::Step.new(:name=>"echo",:number=>1,:status=>"error",
|
68
|
-
:output=>"Hel^.",:error=>"IO error",:duration=>1)
|
69
|
-
[Rutema::Model::Scenario.new(:name=>"TC003",:version=>"10",
|
70
|
-
:attended=>false,:status=>"error",:steps=>[failed_step],
|
71
|
-
:start_time=>(Time.now-10000),:stop_time=>Time.now)]
|
72
|
-
end
|
73
|
-
def setup_for_mri
|
74
|
-
ActiveRecord::Base.establish_connection(:adapter => "sqlite3",:database =>":memory:")
|
75
|
-
@configuration.db={:database=>":memory:",:adapter=>"sqlite3"}
|
76
|
-
end
|
77
|
-
def setup_for_java
|
78
|
-
ActiveRecord::Base.establish_connection(:adapter => "jdbch2",:database =>"db/h2")
|
79
|
-
@configuration.db={:database=>"db/h2",:adapter=>"jdbch2"}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|