cerberus 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,11 +1,19 @@
1
1
  = Cerberus Changelog
2
2
 
3
+ == Version 0.2.2
4
+ Minor fix release
5
+
6
+ * Make rake executable recongnition process less verbose
7
+ * Refactored builder mecahnism in Cerberus. Now adding new Builder possible in much more easiest way
8
+ * Added Maven2 builder
9
+ * Add possibility to specify Builder type on application creation by BUILDER=xxx option
10
+ * Process correctly folders locked by SVN
11
+
3
12
  == Version 0.2.1
4
13
  Minor fix release
5
14
 
6
15
  * publisher -> active flag now not mandatory. Use 'mail' publisher as active if not set any
7
16
 
8
-
9
17
  == Version 0.2.0
10
18
  Config file was changed since 0.1.1 and you need regenerate config files.
11
19
  Or change it by hands: see doc/OPTIONS file to list of all avalable options.
data/README CHANGED
@@ -17,14 +17,14 @@ He guarded the gate to Hades (the Greek underworld) and ensured that the dead co
17
17
 
18
18
  So Cerberus will guard your tests and not allow your project to go to the world of dead.
19
19
 
20
- There is several solutions already present, why do you need to use Cerberus?
21
- Main advantages of Cerberus over other solutions:
22
- = Cerberus could be installed on any machine not only where SVN repository located.
23
- = Cerberus works not only for Rails projects, but for any other Ruby (or better to say for projects that use Rake)
24
- = Cerberus multiplatform solution: it runs excellent both on *nix and Windows.
25
- = Cerberus distributed via RubyGems, so it is very easy to install and very easy to update to the latest available versin
26
- = Cerberus very easy start to use. Just type 'cerberus add PROJECT_URL|PROJECT_DIR'
27
- = Cerberus is lightweigt solution: mots of the time ruby process even not run - Rake runs only in case if changes in project found
20
+ There are several CI solutions already present, why do you need to use Cerberus?
21
+ Main advantages of Cerberus over other solutions are:
22
+ 1) Cerberus could be installed on any machine not only where SVN repository located.
23
+ 2) Cerberus works not only for Rails projects, but for any other Ruby projects as well as for other platforms (Maven2 for Java)
24
+ 3) Cerberus multiplatform solution: it runs excellent both on *nix and Windows.
25
+ 4) Cerberus distributed via RubyGems, so it is very easy to install and very easy to update to the latest stable version
26
+ 5) Cerberus very easy to start using. Just type 'cerberus add PROJECT_URL|PROJECT_DIR'
27
+ 6) Cerberus is lightweight solution: most of the time ruby process even not runs - Rake runs only in case if changes in project sources are found.
28
28
 
29
29
 
30
30
  To use Cerberus it is very easy. First install it. Easiest way to do it through RubyGems package manager.
data/Rakefile CHANGED
@@ -51,7 +51,7 @@ GEM_SPEC = Gem::Specification.new do |s|
51
51
  Cerberus could be easily invoked from Cron (for Unix) or nnCron (for Windows) utilities.
52
52
  DESC
53
53
 
54
- s.add_dependency 'actionmailer', '>= 1.2.3'
54
+ s.add_dependency 'actionmailer', '>= 1.2.5'
55
55
  s.add_dependency 'rake', '>= 0.7.1'
56
56
  s.add_dependency 'jabber4r', '>= 0.8.0'
57
57
  s.add_dependency 'Ruby-IRC', '>= 1.0.3'
data/doc/FAQ CHANGED
@@ -19,3 +19,15 @@ Action:
19
19
  SWHide NormalPriority
20
20
  START-APPW: c:\progra~1\ruby\bin\cerberus.CMD build cerberus
21
21
  )#
22
+
23
+
24
+ * How to change task for Rake
25
+ In my project we need to run Rails migrations before tests. But by default Cerberus runs :default task.
26
+ How could I run migations?
27
+
28
+ it is easy - just set Rake tasks option in config
29
+ builder:
30
+ rake:
31
+ task: migrate test
32
+
33
+ And it would run migrations
data/doc/OPTIONS CHANGED
@@ -27,7 +27,7 @@ publisher:
27
27
  scm:
28
28
  type: svn A
29
29
  url: A
30
- builder
30
+ builder:
31
31
  type: rake #supported: maven2 A
32
32
  rake: C
33
33
  task: test CA
@@ -38,8 +38,10 @@ L - Only for command line interface
38
38
  C - Cerberus config
39
39
  A - application level config
40
40
 
41
+
41
42
  L
42
43
  recipients (add)
43
44
  verbose or quite ??(add, build)
44
45
  application_name (add)
45
- scm (add, default svn)
46
+ scm (add, default svn)
47
+ builder
@@ -1,2 +1,31 @@
1
1
  class Cerberus::Builder::Maven2
2
+ attr_reader :output
3
+
4
+ def initialize(config)
5
+ @config = config
6
+ end
7
+
8
+ def run
9
+ Dir.chdir @config[:application_root]
10
+ cmd = @config[:builder, :maven2, :cmd] || 'mvn'
11
+ task = @config[:builder, :maven2, :task] || 'test'
12
+ output = `#{@config[:bin_path]}#{cmd} #{task} 2>&1`
13
+ @output = add_error_information(output)
14
+ successful?
15
+ end
16
+
17
+ def successful?
18
+ $?.exitstatus == 0 and not @output.include?('[ERROR] BUILD FAILURE')
19
+ end
20
+
21
+ def add_error_information(str)
22
+ output = ''
23
+ while str =~ /^(.|\n)*Running (.*)\n(.|\n)* <<< FAILURE!$/
24
+ failed_class = $2
25
+ output << $` << $&
26
+ output << "\n" << IO.readlines("#{@config[:application_root]}/target/surefire-reports/#{failed_class}.txt")[4..-1].join
27
+ str = $'
28
+ end
29
+ output << str
30
+ end
2
31
  end
@@ -1,2 +1,39 @@
1
1
  class Cerberus::Builder::Rake
2
+ include Cerberus::Utils
3
+ attr_reader :output
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ end
8
+
9
+ def run
10
+ Dir.chdir @config[:application_root]
11
+ @output = `#{@config[:bin_path]}#{choose_rake_exec()} #{@config[:builder, :rake, :task]} 2>&1`
12
+ successful?
13
+ end
14
+
15
+ def successful?
16
+ $?.exitstatus == 0 and not @output.include?('rake aborted!')
17
+ end
18
+
19
+ private
20
+ def choose_rake_exec
21
+ ext = ['']
22
+
23
+ if os() == :windows
24
+ ext << '.bat' << '.cmd'
25
+ end
26
+
27
+ silence_stream(STDERR) {
28
+ ext.each do |e|
29
+ begin
30
+ out = `#{@config[:bin_path]}rake#{e} --version`
31
+ return "rake#{e}" if out =~ /rake/
32
+ rescue
33
+ end
34
+ end
35
+ }
36
+
37
+ raise "Rake builder did not find. Make sure that such script exists and have executable permissions."
38
+ end
2
39
  end
@@ -13,7 +13,7 @@ require 'cerberus/scm/svn'
13
13
 
14
14
  module Cerberus
15
15
  SCM_TYPES = {
16
- 'svn' => Cerberus::SCM::SVN
16
+ :svn => Cerberus::SCM::SVN
17
17
  }
18
18
 
19
19
  PUBLISHER_TYPES = {
@@ -23,22 +23,26 @@ module Cerberus
23
23
  :rss => Cerberus::Publisher::RSS
24
24
  }
25
25
 
26
+ BUILDER_TYPES = {
27
+ :maven2 => Cerberus::Builder::Maven2,
28
+ :rake => Cerberus::Builder::Rake
29
+ }
30
+
26
31
  class AddCommand
27
32
  EXAMPLE_CONFIG = File.expand_path(File.dirname(__FILE__) + '/config.example.yml')
28
33
  include Cerberus::Utils
29
34
 
30
35
  def initialize(path, cli_options = {})
31
- @path, @config = path, Config.new(nil, cli_options)
36
+ @path, @cli_options = path, HashWithIndifferentAccess.new(cli_options)
32
37
  end
33
38
 
34
39
  def run
35
- scm_type = @config[:scm] || 'svn'
36
- say "SCM #{scm_type} not supported" unless SCM_TYPES[scm_type]
37
-
38
- scm = SCM_TYPES[scm_type].new(@path, @config)
40
+ scm_type = @cli_options[:scm] || 'svn'
41
+ say "SCM #{scm_type} not supported" unless SCM_TYPES[scm_type.to_sym]
42
+ scm = SCM_TYPES[scm_type.to_sym].new(@path, @cli_options)
39
43
  say "Can't find any #{scm_type} application under #{@path}" unless scm.url
40
44
 
41
- application_name = @config[:application_name] || extract_project_name(@path)
45
+ application_name = @cli_options[:application_name] || extract_project_name(@path)
42
46
 
43
47
  create_example_config
44
48
 
@@ -48,10 +52,11 @@ module Cerberus
48
52
  app_config = { 'scm' => {
49
53
  'url' => scm.url,
50
54
  'type' => scm_type },
51
- 'publisher' => {'mail' => {'recipients' => @config[:recipients]}}
55
+ 'publisher' => {'mail' => {'recipients' => @cli_options[:recipients]}},
56
+ 'builder' => {'type' => @cli_options[:builder]}
52
57
  }
53
58
  dump_yml(config_name, app_config)
54
- puts "Application '#{application_name}' was successfully added to Cerberus" unless @config[:quiet]
59
+ puts "Application '#{application_name}' was successfully added to Cerberus" unless @cli_options[:quiet]
55
60
  end
56
61
 
57
62
  private
@@ -68,7 +73,7 @@ module Cerberus
68
73
 
69
74
  class BuildCommand
70
75
  include Cerberus::Utils
71
- attr_reader :output, :success, :scm, :status
76
+ attr_reader :builder, :success, :scm, :status
72
77
 
73
78
  def initialize(application_name, cli_options = {})
74
79
  unless File.exists?("#{HOME}/config/#{application_name}.yml")
@@ -82,7 +87,11 @@ module Cerberus
82
87
 
83
88
  @status = Status.new("#{app_root}/status.log")
84
89
 
85
- @scm = SCM_TYPES[@config[:scm, :type] || 'svn'].new(@config[:application_root], @config)
90
+ scm_type = @config[:scm, :type] || 'svn'
91
+ @scm = SCM_TYPES[scm_type.to_sym].new(@config[:application_root], @config)
92
+
93
+ builder_type = @config[:builder, :type] || 'rake'
94
+ @builder = BUILDER_TYPES[builder_type.to_sym].new(@config)
86
95
  end
87
96
 
88
97
  def run
@@ -92,7 +101,7 @@ module Cerberus
92
101
 
93
102
  state =
94
103
  if @scm.has_changes? or not previous_status
95
- if status = make
104
+ if status = @builder.run
96
105
  @status.keep(:succesful)
97
106
  case previous_status
98
107
  when :failed
@@ -134,33 +143,6 @@ module Cerberus
134
143
  end
135
144
  end
136
145
  end
137
-
138
- private
139
- def make
140
- Dir.chdir @config[:application_root]
141
- @output = `#{@config[:bin_path]}#{choose_rake_exec()} #{@config[:builder, :rake, :task]} 2>&1`
142
- make_successful?
143
- end
144
-
145
- def make_successful?
146
- $?.exitstatus == 0 and not @output.include?('rake aborted!')
147
- end
148
-
149
- def choose_rake_exec
150
- ext = ['']
151
-
152
- if os() == :windows
153
- ext << '.bat' << '.cmd'
154
- end
155
-
156
- ext.each{|e|
157
- begin
158
- out = `#{@config[:bin_path]}rake#{e} --version`
159
- return "rake#{e}" if out =~ /rake/
160
- rescue
161
- end
162
- }
163
- end
164
146
  end
165
147
 
166
148
  class BuildAllCommand
@@ -3,24 +3,24 @@ require 'cerberus/version'
3
3
  module Cerberus
4
4
  module Publisher
5
5
  class Base
6
- def self.formatted_message(state, build, options)
6
+ def self.formatted_message(state, manager, options)
7
7
  subject =
8
8
  case state
9
9
  when :setup
10
- "Cerberus set up for project (##{build.scm.current_revision})"
10
+ "Cerberus set up for project (##{manager.scm.current_revision})"
11
11
  when :broken
12
- "Build still broken (##{build.scm.current_revision})"
12
+ "Build still broken (##{manager.scm.current_revision})"
13
13
  when :failure
14
- "Build broken by #{build.scm.last_author} (##{build.scm.current_revision})"
14
+ "Build broken by #{manager.scm.last_author} (##{manager.scm.current_revision})"
15
15
  when :revival
16
- "Build fixed by #{build.scm.last_author} (##{build.scm.current_revision})"
16
+ "Build fixed by #{manager.scm.last_author} (##{manager.scm.current_revision})"
17
17
  else
18
18
  raise "Unknown build state #{state}"
19
19
  end
20
20
 
21
21
  subject = "[#{options[:application_name]}] #{subject}"
22
22
  generated_by = "--\nCerberus #{Cerberus::VERSION::STRING}, http://rubyforge.org/projects/cerberus"
23
- body = [ build.scm.last_commit_message, build.output, generated_by ].join("\n\n")
23
+ body = [ manager.scm.last_commit_message, manager.builder.output, generated_by ].join("\n\n")
24
24
 
25
25
  return subject, body
26
26
  end
@@ -2,10 +2,10 @@ require 'IRC'
2
2
  require 'cerberus/publisher/base'
3
3
 
4
4
  class Cerberus::Publisher::IRC < Cerberus::Publisher::Base
5
- def self.publish(state, build, options)
5
+ def self.publish(state, manager, options)
6
6
  irc_options = options[:publisher, :irc]
7
7
  raise "There is no channel provided for IRC publisher" unless irc_options[:channel]
8
- subject,body = Cerberus::Publisher::Base.formatted_message(state, build, options)
8
+ subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
9
9
  message = subject + "\n" + '*' * subject.length + "\n" + body
10
10
 
11
11
 
@@ -2,12 +2,12 @@ require 'jabber4r/jabber4r'
2
2
  require 'cerberus/publisher/base'
3
3
 
4
4
  class Cerberus::Publisher::Jabber < Cerberus::Publisher::Base
5
- def self.publish(state, build, options)
5
+ def self.publish(state, manager, options)
6
6
  begin
7
7
  jabber_options = options[:publisher, :jabber]
8
8
  raise "There is no recipients provided for Jabber publisher" unless jabber_options[:recipients]
9
9
 
10
- subject,body = Cerberus::Publisher::Base.formatted_message(state, build, options)
10
+ subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
11
11
 
12
12
  session = login(jabber_options[:jid], jabber_options[:password])
13
13
  jabber_options[:recipients].split(',').each do |address|
@@ -2,12 +2,12 @@ require 'action_mailer'
2
2
  require 'cerberus/publisher/base'
3
3
 
4
4
  class Cerberus::Publisher::Mail < Cerberus::Publisher::Base
5
- def self.publish(state, build, options)
5
+ def self.publish(state, manager, options)
6
6
  mail_opts = options[:publisher, :mail].dup
7
7
  raise "There is no recipients provided for mail publisher" unless mail_opts[:recipients]
8
8
 
9
9
  configure(mail_opts)
10
- ActionMailerPublisher.deliver_message(state, build, options)
10
+ ActionMailerPublisher.deliver_message(state, manager, options)
11
11
  end
12
12
 
13
13
  private
@@ -21,8 +21,8 @@ class Cerberus::Publisher::Mail < Cerberus::Publisher::Base
21
21
  end
22
22
 
23
23
  class ActionMailerPublisher < ActionMailer::Base
24
- def message(state, build, options)
25
- @subject, @body = Cerberus::Publisher::Base.formatted_message(state, build, options)
24
+ def message(state, manager, options)
25
+ @subject, @body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
26
26
  @recipients, @sent_on = options[:publisher, :mail, :recipients], Time.now
27
27
  @from = options[:publisher, :mail, :sender] || "'Cerberus' <cerberus@example.com>"
28
28
  # raise "Please specify recipient addresses for application '#{options[:application_name]}'" unless options[:recipients]
@@ -1,9 +1,9 @@
1
1
  require 'cerberus/publisher/base'
2
2
 
3
3
  class Cerberus::Publisher::RSS < Cerberus::Publisher::Base
4
- def self.publish(state, build, options)
4
+ def self.publish(state, manager, options)
5
5
  config = options[:publisher, :rss]
6
- subject,body = Cerberus::Publisher::Base.formatted_message(state, build, options)
6
+ subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
7
7
 
8
8
  pub_date = Time.now.iso8601
9
9
  result = <<-END
@@ -21,6 +21,6 @@ class Cerberus::Publisher::RSS < Cerberus::Publisher::Base
21
21
  </rss>
22
22
  END
23
23
 
24
- File.open(config[:file], 'w'){|f| f.write(result)}
24
+ IO.write(config[:file], result)
25
25
  end
26
26
  end
@@ -1,18 +1,22 @@
1
1
  class Cerberus::SCM::SVN
2
- def initialize(path, options = {})
2
+ def initialize(path, config = {})
3
3
  raise "Path can't be nil" unless path
4
4
 
5
- @path, @options = path.strip, options
5
+ @path, @config = path.strip, config
6
6
  @encoded_path = (@path.include?(' ') ? "\"#{@path}\"" : @path)
7
+
8
+ if test(?d, @path + '/.svn') #check first that it was not locked
9
+ execute("cleanup") if locked?
10
+ FileUtils.rm_rf @path if locked? #In case if we could not unlock from command line - remove this directory at all
11
+ end
7
12
  end
8
13
 
9
14
  def update!
10
15
  if test(?d, @path + '/.svn')
11
- execute("svn cleanup") #TODO check first that it was locked
12
- @status = execute("svn update")
16
+ @status = execute("update")
13
17
  else
14
18
  FileUtils.mkpath(@path) unless test(?d,@path)
15
- @status = execute("svn checkout", nil, @options[:scm, :url])
19
+ @status = execute("checkout", nil, @config[:scm, :url])
16
20
  end
17
21
  end
18
22
 
@@ -29,7 +33,7 @@ class Cerberus::SCM::SVN
29
33
  end
30
34
 
31
35
  def last_commit_message
32
- message = execute("svn log", "--limit 1 -v")
36
+ message = execute("log", "--limit 1 -v")
33
37
  #strip first line that contains command line itself (svn log --limit ...)
34
38
  if ((idx = message.index('-'*72)) != 0 )
35
39
  message[idx..-1]
@@ -43,11 +47,15 @@ class Cerberus::SCM::SVN
43
47
  end
44
48
 
45
49
  private
46
- def info
47
- @info ||= YAML.load(execute("svn info"))
48
- end
50
+ def locked?
51
+ execute("st") =~ /^..L/
52
+ end
53
+
54
+ def info
55
+ @info ||= YAML.load(execute("info"))
56
+ end
49
57
 
50
- def execute(command, parameters = nil, pre_parameters = nil)
51
- `#{@options[:bin_path]}#{command} #{pre_parameters} #{@encoded_path} #{parameters}`
52
- end
58
+ def execute(command, parameters = nil, pre_parameters = nil)
59
+ `#{@config[:bin_path]}svn #{command} #{pre_parameters} #{@encoded_path} #{parameters}`
60
+ end
53
61
  end
@@ -48,4 +48,10 @@ class Hash
48
48
  end
49
49
  end
50
50
  end
51
+ end
52
+
53
+ class IO
54
+ def self.write(filename, str)
55
+ File.open(filename, 'w'){|f| f.write str}
56
+ end
51
57
  end
@@ -2,7 +2,7 @@ module Cerberus
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -78,3 +78,50 @@ class ATest < Test::Unit::TestCase
78
78
  end
79
79
  end
80
80
 
81
+ Revision-number: 2
82
+ Prop-content-length: 127
83
+ Content-length: 127
84
+
85
+ K 7
86
+ svn:log
87
+ V 24
88
+ Added custom rake tasks
89
+
90
+ K 10
91
+ svn:author
92
+ V 8
93
+ Apomozov
94
+ K 8
95
+ svn:date
96
+ V 27
97
+ 2006-08-21T12:15:18.697839Z
98
+ PROPS-END
99
+
100
+ Node-path: Rakefile
101
+ Node-kind: file
102
+ Node-action: change
103
+ Text-content-length: 354
104
+ Text-content-md5: f2c9b7345783c55045e523e052ddaf9e
105
+ Content-length: 354
106
+
107
+ require 'rake'
108
+ require 'rake/testtask'
109
+
110
+ task :default => :test
111
+
112
+ desc "Run the unit tests in test/unit"
113
+ Rake::TestTask.new(:test) do |t|
114
+ t.libs << "test"
115
+ t.pattern = 'test/*_test.rb'
116
+ t.verbose = true
117
+ end
118
+
119
+ task :custom1 do
120
+ puts "Task 'custom1' has been invoked"
121
+ end
122
+
123
+ task :custom2 do
124
+ puts "Task 'custom2' has been invoked"
125
+ end
126
+
127
+
@@ -49,6 +49,11 @@ class FunctionalTest < Test::Unit::TestCase
49
49
  build = Cerberus::BuildCommand.new('myapp')
50
50
  build.run
51
51
  assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
52
+ output = ActionMailer::Base.deliveries[0].body
53
+
54
+ #Check outpus that run needed tasks
55
+ assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
56
+ assert output !~ /Task 'custom1' has been invoked/
52
57
 
53
58
  status_file = HOME + '/work/myapp/status.log'
54
59
  assert File.exists?(status_file)
@@ -140,4 +145,14 @@ class FunctionalTest < Test::Unit::TestCase
140
145
  assert_equal 'succesful', IO.read(status_file)
141
146
  end
142
147
  end
148
+
149
+ def test_custom_task_for_rake
150
+ add_application('rake_cust', SVN_URL, 'builder' => {'rake' => {'task' => 'custom1 custom2'}})
151
+ build = Cerberus::BuildAllCommand.new
152
+ build.run
153
+ assert_equal 1, ActionMailer::Base.deliveries.size
154
+ output = ActionMailer::Base.deliveries[0].body
155
+ assert_match /Task 'custom1' has been invoked/, output
156
+ assert_match /Task 'custom2' has been invoked/, output
157
+ end
143
158
  end
@@ -25,7 +25,7 @@ class IntegrationTest < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def test_add_project_with_parameters
28
- output = run_cerb(" add #{SVN_URL} APPLICATION_NAME=hello_world RECIPIENTS=aa@gmail.com")
28
+ output = run_cerb(" add #{SVN_URL} APPLICATION_NAME=hello_world RECIPIENTS=aa@gmail.com BUILDER=maven2")
29
29
  assert_match /was successfully added/, output
30
30
 
31
31
  assert File.exists?(HOME + '/config/hello_world.yml')
@@ -33,6 +33,7 @@ class IntegrationTest < Test::Unit::TestCase
33
33
 
34
34
  assert_equal SVN_URL, cfg['scm']['url']
35
35
  assert_equal 'aa@gmail.com', cfg['publisher']['mail']['recipients']
36
+ assert_equal 'maven2', cfg['builder']['type']
36
37
  end
37
38
 
38
39
  def test_run_project
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  require 'cerberus/publisher/irc'
4
4
  require 'cerberus/config'
5
5
  require 'mock/irc'
6
- require 'mock/build'
6
+ require 'mock/manager'
7
7
 
8
8
  class IRCPublisherTest < Test::Unit::TestCase
9
9
  def test_publisher
10
10
  options = Cerberus::Config.new(nil, :publisher => {:irc => {:channel => 'hello'}}, :application_name => 'IrcApp')
11
- build = DummyBuild.new('last message', 'this is output', 1232, 'anatol')
11
+ build = DummyManager.new('last message', 'this is output', 1232, 'anatol')
12
12
 
13
13
  Cerberus::Publisher::IRC.publish(:setup, build, options)
14
14
 
@@ -2,12 +2,12 @@ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  require 'cerberus/publisher/jabber'
4
4
  require 'mock/jabber4r'
5
- require 'mock/build'
5
+ require 'mock/manager'
6
6
 
7
7
  class JabberPublisherTest < Test::Unit::TestCase
8
8
  def test_publisher
9
9
  options = Cerberus::Config.new(nil, :publisher => {:jabber => {:recipients => ' jit1@google.com, another@google.com '}}, :application_name => 'MegaApp')
10
- build = DummyBuild.new('last message', 'this is output', 1232, 'anatol')
10
+ build = DummyManager.new('last message', 'this is output', 1232, 'anatol')
11
11
 
12
12
  Cerberus::Publisher::Jabber.publish(:setup, build, options)
13
13
 
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  require 'cerberus/publisher/mail'
4
- require 'mock/build'
4
+ require 'mock/manager'
5
5
 
6
6
  class MailPublisherTest < Test::Unit::TestCase
7
7
  def setup
@@ -12,7 +12,7 @@ class MailPublisherTest < Test::Unit::TestCase
12
12
  options = Cerberus::Config.new(nil, :publisher => {
13
13
  :mail => {:recipients => 'anatol.pomozov@hello.com', :sender => 'haha', :delivery_method => 'test'}},
14
14
  :application_name => 'MyApp')
15
- build = DummyBuild.new('last message', 'this is output', 1232, 'anatol')
15
+ build = DummyManager.new('last message', 'this is output', 1232, 'anatol')
16
16
 
17
17
  Cerberus::Publisher::Mail.publish(:setup, build, options)
18
18
 
@@ -0,0 +1,68 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ require 'cerberus/builder/maven2'
4
+ require 'mock/manager'
5
+ require 'tmpdir'
6
+
7
+ class Cerberus::Builder::Maven2
8
+ attr_writer :output
9
+ end
10
+
11
+ class Maven2BuilderTest < Test::Unit::TestCase
12
+ def test_builder
13
+ tmp = Dir::tmpdir
14
+ builder = Cerberus::Builder::Maven2.new(:application_root => tmp)
15
+ builder.output = MVN_OUTPUT
16
+ assert !builder.successful?
17
+
18
+ surefire_file = "#{tmp}/target/surefire-reports/wicket.markup.html.form.persistence.CookieValuePersisterTest.txt"
19
+ FileUtils.mkpath File.dirname(surefire_file)
20
+ IO.write(surefire_file, SUREFIRE_CLASS_OUTPUT)
21
+
22
+ output = builder.add_error_information(MVN_OUTPUT)
23
+ assert output.include?('at wicket.markup.html.basic.SimplePageTest.testRenderHomePage_3(SimplePageTest.java:285)')
24
+ end
25
+ end
26
+
27
+
28
+ MVN_OUTPUT =<<-END
29
+ -------------------------------------------------------
30
+ T E S T S
31
+ -------------------------------------------------------
32
+ Running wicket.markup.html.list.PagedTableNavigatorWithMarginTest
33
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.313 sec
34
+ Running wicket.markup.html.list.IncrementalTableNavigationTest
35
+ === wicket.markup.html.list.IncrementalTableNavigationPage ===
36
+ === wicket.markup.html.list.IncrementalTableNavigationPage : nextNext ===
37
+ === wicket.markup.html.list.IncrementalTableNavigationPage : prev ===
38
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.062 sec
39
+ Running wicket.markup.html.form.persistence.CookieValuePersisterTest
40
+ === wicket.markup.html.list.IncrementalTableNavigationPage ===
41
+ === wicket.markup.html.list.IncrementalTableNavigationPage : nextNext ===
42
+ Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.516 sec <<< FAILURE!
43
+ Running wicket.util.string.StringListTest
44
+ Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
45
+
46
+ Results :
47
+ Tests run: 449, Failures: 4, Errors: 9, Skipped: 0
48
+
49
+ [INFO] ------------------------------------------------------------------------
50
+ [ERROR] BUILD FAILURE
51
+ [INFO] ------------------------------------------------------------------------
52
+ [INFO] There are test failures.
53
+ END
54
+
55
+ SUREFIRE_CLASS_OUTPUT =<<-END
56
+ -------------------------------------------------------------------------------
57
+ Test set: wicket.markup.html.basic.SimplePageTest
58
+ -------------------------------------------------------------------------------
59
+ Tests run: 13, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.521 sec <<< FAILURE!
60
+ testRenderHomePage_3(wicket.markup.html.basic.SimplePageTest) Time elapsed: 0.06 sec <<< FAILURE!
61
+ junit.framework.AssertionFailedError
62
+ at junit.framework.Assert.fail(Assert.java:47)
63
+ at junit.framework.Assert.assertTrue(Assert.java:20)
64
+ at junit.framework.Assert.assertTrue(Assert.java:27)
65
+ at wicket.WicketTestCase.executeTest(WicketTestCase.java:78)
66
+ at wicket.markup.html.basic.SimplePageTest.testRenderHomePage_3(SimplePageTest.java:285)
67
+
68
+ END
@@ -0,0 +1,11 @@
1
+ class DummyManager
2
+ attr_reader :builder, :scm
3
+
4
+ DummyScm = Struct.new(:last_commit_message, :current_revision, :last_author)
5
+ DummyBuilder = Struct.new(:output)
6
+
7
+ def initialize(last_commit_message, output, current_revision, last_author)
8
+ @scm = DummyScm.new(last_commit_message, current_revision, last_author)
9
+ @builder = DummyBuilder.new(output)
10
+ end
11
+ end
@@ -1,14 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  require 'cerberus/publisher/rss'
4
- require 'mock/build'
4
+ require 'mock/manager'
5
5
  require 'tempfile'
6
6
 
7
7
  class RSSPublisherTest < Test::Unit::TestCase
8
8
  def test_publisher
9
9
  rss_file = tf = Tempfile.new('cerberus-rss')
10
10
  options = Cerberus::Config.new(nil, :publisher => {:rss => {:file => rss_file.path}}, :application_name => 'RSSApp')
11
- build = DummyBuild.new('last message', 'this is output', 1235, 'anatol')
11
+ build = DummyManager.new('last message', 'this is output', 1235, 'anatol')
12
12
 
13
13
  Cerberus::Publisher::RSS.publish(:setup, build, options)
14
14
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: cerberus
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2006-08-14 00:00:00 +04:00
6
+ version: 0.2.2
7
+ date: 2006-08-26 00:00:00 +04:00
8
8
  summary: Cerberus is a Continuous Integration tool that could be easily run from Cron.
9
9
  require_paths:
10
10
  - lib
@@ -60,13 +60,14 @@ files:
60
60
  - test/irc_publisher_test.rb
61
61
  - test/jabber_publisher_test.rb
62
62
  - test/mail_publisher_test.rb
63
+ - test/maven2_builer_test.rb
63
64
  - test/mock
64
65
  - test/rss_publisher_test.rb
65
66
  - test/test_helper.rb
66
67
  - test/data/application.dump
67
- - test/mock/build.rb
68
68
  - test/mock/irc.rb
69
69
  - test/mock/jabber4r.rb
70
+ - test/mock/manager.rb
70
71
  - LICENSE
71
72
  - README
72
73
  - CHANGES
@@ -95,7 +96,7 @@ dependencies:
95
96
  requirements:
96
97
  - - ">="
97
98
  - !ruby/object:Gem::Version
98
- version: 1.2.3
99
+ version: 1.2.5
99
100
  version:
100
101
  - !ruby/object:Gem::Dependency
101
102
  name: rake
data/test/mock/build.rb DELETED
@@ -1,10 +0,0 @@
1
- class DummyBuild
2
- attr_reader :output, :scm
3
- SCM = Struct.new(:last_commit_message, :current_revision, :last_author)
4
-
5
- def initialize(last_commit_message, output, current_revision, last_author)
6
- @output = output
7
-
8
- @scm = SCM.new(last_commit_message, current_revision, last_author)
9
- end
10
- end