damagecontrol 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. data/README +75 -0
  2. data/README.license +5 -0
  3. data/Rakefile +111 -0
  4. data/app/controllers/admin_controller.rb +10 -0
  5. data/app/controllers/application.rb +163 -0
  6. data/app/controllers/files_controller.rb +19 -0
  7. data/app/controllers/project_controller.rb +284 -0
  8. data/app/controllers/scm_controller.rb +49 -0
  9. data/app/helpers/admin_helper.rb +2 -0
  10. data/app/helpers/application_helper.rb +3 -0
  11. data/app/helpers/project_helper.rb +2 -0
  12. data/app/views/dhtml_sites.txt +6 -0
  13. data/app/views/files/list.rhtml +4 -0
  14. data/app/views/layouts/rscm.rhtml +79 -0
  15. data/app/views/project/_bugzilla.rhtml +13 -0
  16. data/app/views/project/_changesets_list.rhtml +52 -0
  17. data/app/views/project/_cvs.rhtml +171 -0
  18. data/app/views/project/_jira.rhtml +19 -0
  19. data/app/views/project/_mooky.rhtml +23 -0
  20. data/app/views/project/_null.rhtml +0 -0
  21. data/app/views/project/_project.rhtml +36 -0
  22. data/app/views/project/_rubyforge.rhtml +19 -0
  23. data/app/views/project/_scarab.rhtml +19 -0
  24. data/app/views/project/_scms.rhtml +15 -0
  25. data/app/views/project/_sourceforge.rhtml +19 -0
  26. data/app/views/project/_starteam.rhtml +43 -0
  27. data/app/views/project/_svn.rhtml +22 -0
  28. data/app/views/project/_trac.rhtml +13 -0
  29. data/app/views/project/_trackers.rhtml +18 -0
  30. data/app/views/project/changesets.rhtml +31 -0
  31. data/app/views/project/index.rhtml +23 -0
  32. data/app/views/project/view.rhtml +70 -0
  33. data/app/views/scm/checkout_status.rhtml +44 -0
  34. data/app/views/scm/diff.rhtml +1 -0
  35. data/app/views/scm/scroll.html +27 -0
  36. data/bin/damagecontrol +7 -0
  37. data/bin/damagecontrol-webrick +2 -0
  38. data/config/database.yml +20 -0
  39. data/config/environment.rb +60 -0
  40. data/config/environments/development.rb +3 -0
  41. data/config/environments/production.rb +2 -0
  42. data/config/environments/test.rb +3 -0
  43. data/lib/damagecontrol/app.rb +74 -0
  44. data/lib/damagecontrol/build.rb +104 -0
  45. data/lib/damagecontrol/diff_htmlizer.rb +82 -0
  46. data/lib/damagecontrol/diff_parser.rb +153 -0
  47. data/lib/damagecontrol/directories.rb +126 -0
  48. data/lib/damagecontrol/poller.rb +72 -0
  49. data/lib/damagecontrol/project.rb +213 -0
  50. data/lib/damagecontrol/project_dependencies.rb +8 -0
  51. data/lib/damagecontrol/scm_web.rb +50 -0
  52. data/lib/damagecontrol/standard_persister.rb +49 -0
  53. data/lib/damagecontrol/tracker.rb +164 -0
  54. data/lib/damagecontrol/visitor/build_executor.rb +32 -0
  55. data/lib/damagecontrol/visitor/diff_persister.rb +41 -0
  56. data/lib/damagecontrol/visitor/rss_writer.rb +43 -0
  57. data/lib/damagecontrol/visitor/yaml_persister.rb +71 -0
  58. data/public/404.html +6 -0
  59. data/public/500.html +6 -0
  60. data/public/dispatch.cgi +10 -0
  61. data/public/dispatch.fcgi +7 -0
  62. data/public/dispatch.rb +10 -0
  63. data/public/images/16x16/about.png +0 -0
  64. data/public/images/16x16/bug_green.png +0 -0
  65. data/public/images/16x16/bug_red.png +0 -0
  66. data/public/images/16x16/bug_yellow.png +0 -0
  67. data/public/images/16x16/component.png +0 -0
  68. data/public/images/16x16/console.png +0 -0
  69. data/public/images/16x16/console_error.png +0 -0
  70. data/public/images/16x16/document_add.png +0 -0
  71. data/public/images/16x16/document_delete.png +0 -0
  72. data/public/images/16x16/document_edit.png +0 -0
  73. data/public/images/16x16/document_exchange.png +0 -0
  74. data/public/images/16x16/document_new.png +0 -0
  75. data/public/images/16x16/document_warning.png +0 -0
  76. data/public/images/16x16/safe.png +0 -0
  77. data/public/images/16x16/scroll_information.png +0 -0
  78. data/public/images/16x16/wrench.png +0 -0
  79. data/public/images/24x24/box_delete.png +0 -0
  80. data/public/images/24x24/box_into.png +0 -0
  81. data/public/images/24x24/box_new.png +0 -0
  82. data/public/images/24x24/console_network.png +0 -0
  83. data/public/images/24x24/document_edit.png +0 -0
  84. data/public/images/24x24/find.png +0 -0
  85. data/public/images/24x24/folders.png +0 -0
  86. data/public/images/24x24/garbage.png +0 -0
  87. data/public/images/24x24/gear_connection.png +0 -0
  88. data/public/images/24x24/gear_delete.png +0 -0
  89. data/public/images/24x24/gears_run.png +0 -0
  90. data/public/images/24x24/home.png +0 -0
  91. data/public/images/24x24/navigate_left.png +0 -0
  92. data/public/images/24x24/navigate_right.png +0 -0
  93. data/public/images/24x24/package_new.png +0 -0
  94. data/public/images/24x24/safe.png +0 -0
  95. data/public/images/24x24/safe_new.png +0 -0
  96. data/public/images/24x24/safe_out.png +0 -0
  97. data/public/images/24x24/scroll_information.png +0 -0
  98. data/public/images/24x24/stop.png +0 -0
  99. data/public/images/24x24/wrench.png +0 -0
  100. data/public/images/README.license +2 -0
  101. data/public/images/blue-16.gif +0 -0
  102. data/public/images/blue-32.gif +0 -0
  103. data/public/images/bugzilla.png +0 -0
  104. data/public/images/cvs.png +0 -0
  105. data/public/images/footer.gif +0 -0
  106. data/public/images/green-128.gif +0 -0
  107. data/public/images/green-16.gif +0 -0
  108. data/public/images/green-32.gif +0 -0
  109. data/public/images/grey-16.gif +0 -0
  110. data/public/images/grey-32.gif +0 -0
  111. data/public/images/jira.gif +0 -0
  112. data/public/images/red-16.gif +0 -0
  113. data/public/images/red-32.gif +0 -0
  114. data/public/images/red-pulse-32.gif +0 -0
  115. data/public/images/rss.gif +0 -0
  116. data/public/images/rubyforge.png +0 -0
  117. data/public/images/scarab.gif +0 -0
  118. data/public/images/sourceforge.gif +0 -0
  119. data/public/images/starteam.png +0 -0
  120. data/public/images/svnlogo64.png +0 -0
  121. data/public/images/trac.png +0 -0
  122. data/public/index.html +1 -0
  123. data/public/javascripts/dw_event.js +34 -0
  124. data/public/javascripts/dw_tooltip.js +86 -0
  125. data/public/javascripts/dw_viewport.js +55 -0
  126. data/public/javascripts/pngfix.js +29 -0
  127. data/public/javascripts/toggle_diff.js +25 -0
  128. data/public/licenses/DAMAGECONTROL.license +28 -0
  129. data/public/licenses/INCORS.license +32 -0
  130. data/public/stylesheets/diff.css +23 -0
  131. data/public/stylesheets/style.css +307 -0
  132. data/script/breakpointer +5 -0
  133. data/script/console +30 -0
  134. data/script/generate +70 -0
  135. data/script/server +61 -0
  136. data/test/damagecontrol/a_program.rb +3 -0
  137. data/test/damagecontrol/a_slow_program.rb +3 -0
  138. data/test/damagecontrol/build_test.rb +59 -0
  139. data/test/damagecontrol/diff_htmlizer_test.rb +31 -0
  140. data/test/damagecontrol/diff_parser_test.rb +61 -0
  141. data/test/damagecontrol/file_ext.rb +12 -0
  142. data/test/damagecontrol/poller_test.rb +56 -0
  143. data/test/damagecontrol/project_test.rb +144 -0
  144. data/test/damagecontrol/scm_web_test.rb +22 -0
  145. data/test/damagecontrol/test.diff +38 -0
  146. data/test/damagecontrol/test.html +40 -0
  147. data/test/damagecontrol/tracker_test.rb +48 -0
  148. data/test/damagecontrol/visitor/changesets.rss +34 -0
  149. data/test/damagecontrol/visitor/diff_persister_test.rb +49 -0
  150. data/test/damagecontrol/visitor/rss_writer_test.rb +40 -0
  151. data/test/damagecontrol/visitor/yaml_persister_test.rb +40 -0
  152. data/test/functional/admin_controller_test.rb +17 -0
  153. data/test/functional/project_controller_test.rb +17 -0
  154. data/test/test_helper.rb +14 -0
  155. metadata +245 -0
data/script/server ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'webrick'
4
+ require 'optparse'
5
+
6
+ OPTIONS = {
7
+ :port => 4712,
8
+ :ip => "127.0.0.1",
9
+ :environment => "development",
10
+ :server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
11
+ :server_type => WEBrick::SimpleServer,
12
+ }
13
+
14
+ ARGV.options do |opts|
15
+ script_name = File.basename($0)
16
+ opts.banner = "Usage: ruby #{script_name} [options]"
17
+
18
+ opts.separator ""
19
+
20
+ opts.on("-p", "--port=port", Integer,
21
+ "Runs Rails on the specified port.",
22
+ "Default: 3000") { |OPTIONS[:port]| }
23
+ opts.on("-b", "--binding=ip", String,
24
+ "Binds Rails to the specified ip.",
25
+ "Default: 127.0.0.1") { |OPTIONS[:ip]| }
26
+ opts.on("-i", "--index=controller", String,
27
+ "Specifies an index controller that requests for root will go to (instead of congratulations screen)."
28
+ ) { |OPTIONS[:index_controller]| }
29
+ opts.on("-e", "--environment=name", String,
30
+ "Specifies the environment to run this server under (test/development/production).",
31
+ "Default: development") { |OPTIONS[:environment]| }
32
+ opts.on("-d", "--daemon",
33
+ "Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
34
+ ) { OPTIONS[:server_type] = WEBrick::Daemon }
35
+
36
+ opts.separator ""
37
+
38
+ opts.on("-h", "--help",
39
+ "Show this help message.") { puts opts; exit }
40
+
41
+ opts.parse!
42
+ end
43
+
44
+ ENV["RAILS_ENV"] = OPTIONS[:environment]
45
+ require File.dirname(__FILE__) + "/../config/environment"
46
+ require 'webrick_server'
47
+
48
+ # Get rid of annoying trailing slash in original webrick_server's impl.
49
+ class DispatchServlet
50
+ def handle_index(req, res)
51
+ if req.request_uri.path == "/"
52
+ res.set_redirect WEBrick::HTTPStatus::MovedPermanently, "/project"
53
+ return true
54
+ else
55
+ return false
56
+ end
57
+ end
58
+ end
59
+
60
+ puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
61
+ DispatchServlet.dispatch(OPTIONS)
@@ -0,0 +1,3 @@
1
+ $stderr.write("this\nis\nstderr\n#{ENV['foo']}")
2
+ $stdout.write("this\nis\nstdout\n#{ARGV[0]}")
3
+ exit(ARGV[0].to_i)
@@ -0,0 +1,3 @@
1
+ $stderr.write("this\nis\nstderr")
2
+ $stdout.write("this\nis\nstdout\n#{ARGV[0]}")
3
+ sleep(20)
@@ -0,0 +1,59 @@
1
+ require 'test/unit'
2
+ require 'rscm/mockit'
3
+ require 'rscm/tempdir'
4
+ require 'damagecontrol/build'
5
+
6
+ module DamageControl
7
+ class BuildTest < Test::Unit::TestCase
8
+ include MockIt
9
+
10
+ def test_should_write_stderr_and_stdout_to_files_on_execute
11
+ home = RSCM.new_temp_dir("successful_execute")
12
+
13
+ ENV["DAMAGECONTROL_HOME"] = home
14
+ t = Time.utc(1971, 2, 28, 23, 45, 00)
15
+ build = Build.new("mooky", "some_rev", t)
16
+ a_program = File.expand_path(File.dirname(__FILE__) + "/a_program.rb")
17
+ build.execute("ruby #{a_program} 0", {'foo' => 'zap'})
18
+ stderr = "#{home}/mooky/changesets/some_rev/builds/19710228234500/stderr.log"
19
+ assert_equal("this\nis\nstderr\nzap", File.read(stderr))
20
+ stdout = "#{home}/mooky/changesets/some_rev/builds/19710228234500/stdout.log"
21
+ assert_equal("this\nis\nstdout\n0", File.read(stdout))
22
+ assert_equal(0, build.exit_code)
23
+ end
24
+
25
+ def test_should_persist_failure
26
+ home = RSCM.new_temp_dir("failed_execute")
27
+
28
+ ENV["DAMAGECONTROL_HOME"] = home
29
+ t = Time.utc(1971, 2, 28, 23, 45, 00)
30
+ build = Build.new("mooky", "some_rev", t)
31
+ a_program = File.expand_path(File.dirname(__FILE__) + "/a_program.rb")
32
+ build.execute("ruby #{a_program} 44", {'foo' => 'bar'})
33
+ stderr = "#{home}/mooky/changesets/some_rev/builds/19710228234500/stderr.log"
34
+ assert_equal("this\nis\nstderr\nbar", File.read(stderr))
35
+ stdout = "#{home}/mooky/changesets/some_rev/builds/19710228234500/stdout.log"
36
+ assert_equal("this\nis\nstdout\n44", File.read(stdout))
37
+ assert_equal(44, build.exit_code)
38
+ end
39
+
40
+ def Xtest_should_kill_long_running_build
41
+ home = RSCM.new_temp_dir("killing")
42
+
43
+ ENV["DAMAGECONTROL_HOME"] = home
44
+ t = Time.utc(1971, 2, 28, 23, 45, 00)
45
+ build = Build.new("mooky", "some_rev", t)
46
+ a_program = File.expand_path(File.dirname(__FILE__) + "/a_slow_program.rb")
47
+ t = Thread.new do
48
+ build.execute("ruby #{a_program} 55", {'foo' => 'mooky'})
49
+ end
50
+ # make sure it's running
51
+ sleep(2)
52
+ build.kill
53
+ stdout = "#{home}/mooky/changesets/some_rev/builds/19710228234500/stdout.log"
54
+ assert_equal("this\nis\nstdout\n44", File.read(stdout))
55
+ assert_equal(nil, build.exit_code)
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,31 @@
1
+ require 'test/unit'
2
+ require 'rscm/tempdir'
3
+ require 'damagecontrol/diff_parser'
4
+ require 'damagecontrol/diff_htmlizer'
5
+ require 'damagecontrol/file_ext.rb'
6
+
7
+ module DamageControl
8
+ class DiffHtmlizerTest < Test::Unit::TestCase
9
+ def test_should_parse_diff_to_object_model
10
+ p = DiffParser.new
11
+
12
+ html_file = "#{RSCM.new_temp_dir}/diff.html"
13
+ File.open(File.dirname(__FILE__) + "/test.diff") do |diff|
14
+ diffs = p.parse_diffs(diff)
15
+ File.open(html_file,"w") do |html|
16
+ hd = DiffHtmlizer.new(html)
17
+ html << "<html>\n"
18
+ html << "<head>\n"
19
+ html << "<link type='text/css' rel='stylesheet' href='../../public/stylesheets/diff.css'>\n"
20
+ html << "</head>\n"
21
+ html << "<body>\n"
22
+ diffs.accept(hd)
23
+ html << "</body>\n"
24
+ html << "</html>\n"
25
+ end
26
+ end
27
+ expected = File.open(File.dirname(__FILE__) + "/test.html")
28
+ assert_equal(expected.read_fix_nl, File.open(html_file).read_fix_nl)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,61 @@
1
+ require 'test/unit'
2
+ require 'rscm/tempdir'
3
+ require 'rscm/path_converter'
4
+ require 'damagecontrol/diff_parser'
5
+
6
+ # TODO: how do we make this work cross platform in a nicer way?
7
+ # Play more with $/, $\ and such
8
+ if(WINDOWS)
9
+ NL = "\n"
10
+ else
11
+ NL = "\r\n"
12
+ end
13
+
14
+ module DamageControl
15
+ class DiffParserTest < Test::Unit::TestCase
16
+ def test_should_parse_diff_to_object_model
17
+ p = DiffParser.new
18
+
19
+ File.open(File.dirname(__FILE__) + "/test.diff") do |diff|
20
+ diffs = p.parse_diffs(diff)
21
+ assert_equal(3, diffs.length)
22
+ assert_equal(7, diffs[1].nplus)
23
+
24
+ assert_equal(10, diffs[0].line_count)
25
+ assert_equal(8, diffs[1].line_count)
26
+ assert_equal(9, diffs[2].line_count)
27
+
28
+ assert(!diffs[0][0].removed?)
29
+ assert(!diffs[0][0].added?)
30
+ assert(!diffs[0][1].removed?)
31
+ assert(!diffs[0][1].added?)
32
+ assert( diffs[0][2].removed?)
33
+ assert(!diffs[0][2].added?)
34
+ assert(!diffs[0][3].removed?)
35
+ assert( diffs[0][3].added?)
36
+
37
+ assert_equal(" package org.picocontainer.sample.tulip;#{NL}", diffs[0][0])
38
+ assert_equal("#{NL}", diffs[0][1])
39
+ # 0 0 0 6 0 6 0
40
+ assert_equal("-import org.picocontainer.lifecycle.Startable;#{NL}", diffs[0][2])
41
+ assert_equal(26..35, diffs[0][2].removed_range)
42
+ assert_equal(nil, diffs[0][2].added_range)
43
+ assert_equal("+import org.picocontainer.Startable;#{NL}", diffs[0][3])
44
+ assert_equal("#{NL}", diffs[0][4])
45
+ assert_equal("-import org.boo.Fillable;#{NL}", diffs[0][5])
46
+ assert_equal(nil, diffs[0][5].removed_range)
47
+ assert_equal(nil, diffs[0][5].added_range)
48
+ assert_equal("+import org.boo.foooooo.Fillable;#{NL}", diffs[0][6])
49
+ assert_equal(nil, diffs[0][6].removed_range)
50
+ assert_equal(16..23, diffs[0][6].added_range)
51
+
52
+ assert_equal("- * @version $Revision: 1.1 $#{NL}", diffs[1][3])
53
+ assert_equal(26..26, diffs[1][3].removed_range)
54
+ assert_equal(nil, diffs[1][3].added_range)
55
+ assert_equal("+ * @version $Revision: 1.2 $#{NL}", diffs[1][4])
56
+ assert_equal(nil, diffs[1][4].removed_range)
57
+ assert_equal(26..26, diffs[1][4].added_range)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,12 @@
1
+ class File
2
+ def read_fix_nl
3
+ result = ""
4
+ self.each_line do |line|
5
+ chomped = line.chomp
6
+ result << chomped
7
+ result << "\n" if chomped != line
8
+ end
9
+ result
10
+ end
11
+ end
12
+
@@ -0,0 +1,56 @@
1
+ require 'test/unit'
2
+ require 'rscm/mockit'
3
+ require 'damagecontrol/project'
4
+ require 'damagecontrol/poller'
5
+
6
+ module DamageControl
7
+ class PollerTest < Test::Unit::TestCase
8
+ include MockIt
9
+
10
+ def test_should_not_add_projects_twice
11
+ s = Poller.new
12
+ a1 = Project.new; a1.name = "jalla"
13
+ s.add_project(a1)
14
+ assert_equal([a1], s.projects)
15
+
16
+ a2 = Project.new; a2.name = "jalla"
17
+ s.add_project(a2)
18
+ assert_equal([a2], s.projects)
19
+
20
+ b = Project.new; b.name = "mooky"
21
+ s.add_project(b)
22
+ assert_equal([a2, b], s.projects)
23
+ end
24
+
25
+ def test_yields_project_and_changesets_for_each_project_with_changesets
26
+ p1 = Project.new; p1.name = "p2"
27
+ p1.scm = new_mock
28
+ p1.scm.__expect(:exists?) {true}
29
+ p1.scm.__expect(:changesets) {"some fake changesets"}
30
+ p1.scm.__expect(:transactional?) {true}
31
+
32
+ p2 = Project.new; p2.name = "p1"
33
+ p2.scm = new_mock
34
+ p2.scm.__expect(:exists?) {true}
35
+ p2.scm.__expect(:changesets) {"some other fake changesets"}
36
+ p2.scm.__expect(:transactional?) {true}
37
+
38
+ projects = []
39
+ changesets_ = []
40
+ s = Poller.new do |project, changesets|
41
+ projects << project
42
+ changesets_ << changesets
43
+ end
44
+ s.add_project(p1)
45
+ s.add_project(p2)
46
+
47
+ s.poll
48
+
49
+ assert_same(p1, projects[0])
50
+ assert_same(p2, projects[1])
51
+ assert_equal("some fake changesets", changesets_[0])
52
+ assert_equal("some other fake changesets", changesets_[1])
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,144 @@
1
+ require 'test/unit'
2
+ require 'rscm/tempdir'
3
+ require 'rscm/mockit'
4
+ require 'rscm/changes'
5
+ require 'damagecontrol/project'
6
+
7
+ module DamageControl
8
+ class ProjectTest < Test::Unit::TestCase
9
+ include MockIt
10
+
11
+ def setup
12
+ MockIt::setup
13
+ @p = Project.new
14
+ @p.description = "bla bla"
15
+ @p.name = "blabla"
16
+ end
17
+
18
+ def test_poll_should_get_changesets_from_epoch_if_last_change_time_unknown
19
+ ENV["DAMAGECONTROL_HOME"] = RSCM.new_temp_dir("epoch")
20
+ @p.scm = new_mock
21
+ changesets = new_mock
22
+ changesets.__expect(:empty?) {true}
23
+ @p.scm.__expect(:changesets) do |checkout_dir, from|
24
+ assert_equal(Time.epoch, from)
25
+ changesets
26
+ end
27
+ @p.poll do |cs|
28
+ assert_equal(changesets, cs)
29
+ end
30
+ end
31
+
32
+ def test_poll_should_poll_until_quiet_period_elapsed
33
+ ENV["DAMAGECONTROL_HOME"] = RSCM.new_temp_dir("quiet_period")
34
+
35
+ @p.quiet_period = 0
36
+ @p.scm = new_mock
37
+ @p.scm.__setup(:name) {"mooky"}
38
+ @p.scm.__expect(:changesets) do |checkout_dir, from|
39
+ assert_equal(Time.epoch, from)
40
+ "foo"
41
+ end
42
+ @p.scm.__expect(:transactional?) {false}
43
+ @p.scm.__expect(:changesets) do |checkout_dir, from|
44
+ assert_equal(Time.epoch, from)
45
+ "bar"
46
+ end
47
+ @p.scm.__expect(:changesets) do |checkout_dir, from|
48
+ assert_equal(Time.epoch, from)
49
+ "bar"
50
+ end
51
+ @p.poll do |cs|
52
+ assert_equal("bar", cs)
53
+ end
54
+ end
55
+
56
+ def test_poll_should_get_changesets_from_last_change_time_if_known
57
+ ENV["DAMAGECONTROL_HOME"] = RSCM.new_temp_dir("last")
58
+
59
+ a = Time.new.utc
60
+ FileUtils.mkdir_p("#{@p.changesets_dir}/#{a.ymdHMS}")
61
+ File.open("#{@p.changesets_dir}/#{a.ymdHMS}/changeset.yaml", "w") do |io|
62
+ cs = RSCM::ChangeSet.new
63
+ cs << RSCM::Change.new("path", "aslak", "hello", "55", Time.new.utc)
64
+ YAML::dump(cs, io)
65
+ end
66
+ @p.scm = new_mock
67
+ changesets = new_mock
68
+ changesets.__expect(:empty?) {false}
69
+ @p.scm.__expect(:changesets) do |checkout_dir, from|
70
+ assert_equal(a+1, from)
71
+ changesets
72
+ end
73
+ @p.scm.__expect(:transactional?) {true}
74
+ @p.poll do |cs|
75
+ assert_equal(changesets, cs)
76
+ end
77
+ end
78
+
79
+ def test_should_look_at_folders_to_determine_next_changeset_time
80
+ changesets_dir = RSCM.new_temp_dir("folders")
81
+ ENV["DAMAGECONTROL_HOME"] = changesets_dir
82
+
83
+ a = Time.new.utc
84
+ b = a + 1
85
+ c = b + 1
86
+ FileUtils.mkdir_p("#{changesets_dir}/#{a.ymdHMS}")
87
+ FileUtils.touch("#{changesets_dir}/#{a.ymdHMS}/changeset.yaml")
88
+ FileUtils.mkdir_p("#{changesets_dir}/#{c.ymdHMS}")
89
+ FileUtils.touch("#{changesets_dir}/#{c.ymdHMS}/changeset.yaml")
90
+ FileUtils.mkdir_p("#{changesets_dir}/#{b.ymdHMS}")
91
+ FileUtils.touch("#{changesets_dir}/#{b.ymdHMS}/changeset.yaml")
92
+
93
+ assert_equal(c+1, @p.next_changeset_identifier(changesets_dir))
94
+ end
95
+
96
+ def test_should_checkout_from_changeset_identifier_and_execute_build
97
+ home = RSCM.new_temp_dir("execute")
98
+ ENV["DAMAGECONTROL_HOME"] = home
99
+
100
+ p = Project.new("mooky")
101
+ p.scm = new_mock
102
+ p.scm.__expect(:checkout) do |checkout_dir, changeset_identifier|
103
+ assert_equal("boo", changeset_identifier)
104
+ end
105
+
106
+ before = Time.new
107
+ p.build("boo") do |build|
108
+ now = Time.new
109
+ assert(before <= build.time)
110
+ assert(build.time <= now)
111
+ build.execute("some command")
112
+
113
+ assert_equal("some command", File.open("#{home}/mooky/changesets/boo/builds/#{build.time.to_s}/command").read)
114
+ end
115
+
116
+ end
117
+
118
+ def test_should_load_persisted_builds_that_are_frozen
119
+ p = Project.new("mooky")
120
+ home = RSCM.new_temp_dir("load_builds")
121
+ ENV["DAMAGECONTROL_HOME"] = home
122
+
123
+ changeset_identifier = Time.new.utc
124
+ build_1_time = changeset_identifier + 10
125
+ build_2_time = changeset_identifier + 20
126
+ FileUtils.mkdir_p("#{home}/mooky/changesets/#{changeset_identifier.ymdHMS}/builds/#{build_1_time.ymdHMS}")
127
+ FileUtils.touch("#{home}/mooky/changesets/#{changeset_identifier.ymdHMS}/builds/#{build_1_time.ymdHMS}/command")
128
+ FileUtils.mkdir_p("#{home}/mooky/changesets/#{changeset_identifier.ymdHMS}/builds/#{build_2_time.ymdHMS}")
129
+
130
+ builds = p.builds(changeset_identifier)
131
+ assert_equal(2, builds.length)
132
+ assert_equal(build_1_time, builds[0].time)
133
+ assert_equal(build_2_time, builds[1].time)
134
+ assert_raises(BuildException, "shouldn't be able to execute persisted build") do
135
+ builds[0].execute("this should fail because command file exists")
136
+ end
137
+ builds[1].execute("this should pass since command doesn't exist")
138
+ assert_raises(BuildException, "shouldn't be able to execute persisted build") do
139
+ builds[1].execute("this should fail because command file exists")
140
+ end
141
+ end
142
+
143
+ end
144
+ end
@@ -0,0 +1,22 @@
1
+ require 'yaml'
2
+ require 'test/unit'
3
+ require 'rscm/changes'
4
+ require 'damagecontrol/scm_web'
5
+
6
+ module DamageControl
7
+ module SCMWeb
8
+
9
+ class SCMWebTest < Test::Unit::TestCase
10
+
11
+ def setup
12
+ @change = RSCM::Change.new("path/one", "aslak", "Fixed CATCH-22", "2.4", Time.utc(2004,7,5,12,0,2))
13
+ end
14
+
15
+ def test_view_cvs
16
+ view_cvs = ViewCVS.new("http://cvs.damagecontrol.codehaus.org/")
17
+ assert_equal("http://cvs.damagecontrol.codehaus.org/path/one?rev=2.4&r=2.4", view_cvs.change_url(@change))
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,38 @@
1
+ Index: src/test/org/picocontainer/sample/tulip/FlowerMarketGui.java
2
+ ===================================================================
3
+ RCS file: /home/projects/picocontainer/scm/sample/src/test/org/picocontainer/sample/tulip/FlowerMarketGui.java,v
4
+ retrieving revision 1.1
5
+ retrieving revision 1.2
6
+ diff -u -r1.1 -r1.2
7
+ --- src/test/org/picocontainer/sample/tulip/FlowerMarketGui.java 25 Nov 2003 22:07:59 -0000 1.1
8
+ +++ src/test/org/picocontainer/sample/tulip/FlowerMarketGui.java 5 Jun 2004 19:27:45 -0000 1.2
9
+ @@ -1,6 +1,6 @@
10
+ package org.picocontainer.sample.tulip;
11
+
12
+ -import org.picocontainer.lifecycle.Startable;
13
+ +import org.picocontainer.Startable;
14
+
15
+ -import org.boo.Fillable;
16
+ +import org.boo.foooooo.Fillable;
17
+
18
+ import javax.swing.*;
19
+ import javax.swing.table.DefaultTableModel;
20
+ @@ -9,7 +9,7 @@
21
+ /**
22
+ * @author Aslak Helles&oslash;y
23
+ * @author Jon Tirs&eacute;n
24
+ - * @version $Revision: 1.1 $
25
+ + * @version $Revision: 1.2 $
26
+ */
27
+ public class FlowerMarketGui extends FlowerMarketStub implements Startable {
28
+ private DefaultTableModel bidsTableModel;
29
+ @@ -26,6 +26,9 @@
30
+ frame.pack();
31
+ frame.setBounds(700, 100, 300, 600);
32
+ frame.show();
33
+ + }
34
+ +
35
+ + public void stop() {
36
+ }
37
+
38
+ public void sellBid(String flower) {
@@ -0,0 +1,40 @@
1
+ <html>
2
+ <head>
3
+ <link type='text/css' rel='stylesheet' href='../../public/stylesheets/diff.css'>
4
+ </head>
5
+ <body>
6
+ <div>
7
+ <pre class='diff' id='context'> package org.picocontainer.sample.tulip;
8
+ </pre><pre class='diff' id='context'>
9
+ </pre><pre class='diff' id='removed'>-import org.picocontainer.<span id='removedchars'>lifecycle.</span>Startable;
10
+ </pre><pre class='diff' id='added'>+import org.picocontainer.Startable;
11
+ </pre><pre class='diff' id='context'>
12
+ </pre><pre class='diff' id='removed'>-import org.boo.Fillable;
13
+ </pre><pre class='diff' id='added'>+import org.boo.<span id='addedchars'>foooooo.</span>Fillable;
14
+ </pre><pre class='diff' id='context'>
15
+ </pre><pre class='diff' id='context'> import javax.swing.*;
16
+ </pre><pre class='diff' id='context'> import javax.swing.table.DefaultTableModel;
17
+ </pre></div>
18
+ <div>
19
+ <pre class='diff' id='context'> /**
20
+ </pre><pre class='diff' id='context'> * @author Aslak Helles&amp;oslash;y
21
+ </pre><pre class='diff' id='context'> * @author Jon Tirs&amp;eacute;n
22
+ </pre><pre class='diff' id='removed'>- * @version $Revision: 1.<span id='removedchars'>1</span> $
23
+ </pre><pre class='diff' id='added'>+ * @version $Revision: 1.<span id='addedchars'>2</span> $
24
+ </pre><pre class='diff' id='context'> */
25
+ </pre><pre class='diff' id='context'> public class FlowerMarketGui extends FlowerMarketStub implements Startable {
26
+ </pre><pre class='diff' id='context'> private DefaultTableModel bidsTableModel;
27
+ </pre></div>
28
+ <div>
29
+ <pre class='diff' id='context'> frame.pack();
30
+ </pre><pre class='diff' id='context'> frame.setBounds(700, 100, 300, 600);
31
+ </pre><pre class='diff' id='context'> frame.show();
32
+ </pre><pre class='diff' id='added'>+ }
33
+ </pre><pre class='diff' id='added'>+
34
+ </pre><pre class='diff' id='added'>+ public void stop() {
35
+ </pre><pre class='diff' id='context'> }
36
+ </pre><pre class='diff' id='context'>
37
+ </pre><pre class='diff' id='context'> public void sellBid(String flower) {
38
+ </pre></div>
39
+ </body>
40
+ </html>
@@ -0,0 +1,48 @@
1
+ require 'test/unit'
2
+ require 'damagecontrol/tracker'
3
+
4
+ module DamageControl
5
+ module Tracker
6
+ class TrackerTest < Test::Unit::TestCase
7
+
8
+ def test_bugzilla
9
+ bugzilla = Bugzilla.new("http://bugzilla.org")
10
+ assert_equal('', bugzilla.highlight(''))
11
+ assert_equal('catch <a href="http://bugzilla.org/show_bug.cgi?id=22">#22</a>', bugzilla.highlight('catch #22'))
12
+ end
13
+
14
+ def test_jira
15
+ jira = JIRA.new("http://jira.codehaus.org", "DC")
16
+
17
+ assert_equal('', jira.highlight(''))
18
+ assert_equal('<a href="http://jira.codehaus.org/browse/DC-148">DC-148</a>', jira.highlight('DC-148'))
19
+ assert_equal('x<a href="http://jira.codehaus.org/browse/DC-148">DC-148</a>', jira.highlight('xDC-148'))
20
+ assert_equal('<a href="http://jira.codehaus.org/browse/DC-148">DC-148</a>:bla', jira.highlight('DC-148:bla'))
21
+ assert_equal('fixed <a href="http://jira.codehaus.org/browse/DC-148">DC-148</a>.', jira.highlight('fixed DC-148.'))
22
+ assert_equal('Fixed <a href="http://jira.codehaus.org/browse/CATCH-22">CATCH-22</a>', jira.highlight('Fixed CATCH-22'))
23
+ assert_equal('blahblah\nblah\nblah <a href="http://jira.codehaus.org/browse/DC-148">DC-148</a>', jira.highlight('blahblah\nblah\nblah DC-148'))
24
+ assert_equal('ABCABCABCABCABCABCABCABCABCABCABCABC <a href="http://jira.codehaus.org/browse/DC-148">DC-148</a> ABCABCABCABCABCABCABCABCABCABCABCABC', jira.highlight('ABCABCABCABCABCABCABCABCABCABCABCABC DC-148 ABCABCABCABCABCABCABCABCABCABCABCABC'))
25
+ end
26
+
27
+ def test_ruby_forge
28
+ rf = RubyForge.new("333", "444")
29
+
30
+ assert_equal('catch <a href="http://rubyforge.org/tracker/index.php?func=detail&aid=22&group_id=333&atid=444">#22</a>', rf.highlight('catch #22'))
31
+ end
32
+
33
+ def test_source_forge
34
+ sf = SourceForge.new("333", "444")
35
+
36
+ assert_equal('catch <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=22&group_id=333&atid=444">#22</a>', sf.highlight('catch #22'))
37
+ end
38
+
39
+ def test_scarab
40
+ scarab = Scarab.new("http://scarab.org", "dc")
41
+
42
+ assert_equal('catch #22', scarab.highlight('catch #22'))
43
+ assert_equal('catch <a href="http://scarab.org/issues/id/dc22">dc22</a>', scarab.highlight('catch dc22'))
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rss version="2.0"
3
+ xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
4
+ <channel>
5
+ <title>Mooky</title>
6
+ <link>http://damagecontrol.codehaus.org/</link>
7
+ <description>This feed contains SCM changes for the DamageControl project</description>
8
+ <item>
9
+ <title>Fixed CATCH-22</title>
10
+ <link>http://cvs.damagecontrol.codehaus.org/</link>
11
+ <description>&lt;b&gt;jon&lt;/b&gt;&lt;br/&gt;
12
+ Fixed &lt;a href=&quot;http://jira.codehaus.org/browse/CATCH-22&quot;&gt;CATCH-22&lt;/a&gt;&lt;p/&gt;
13
+ &lt;a href=&quot;http://cvs.damagecontrol.codehaus.org/path/one?rev=1.1&amp;r=1.1&quot;&gt;path/one&lt;/a&gt;&lt;br/&gt;
14
+ &lt;a href=&quot;http://cvs.damagecontrol.codehaus.org/path/two?rev=1.2&amp;r=1.2&quot;&gt;path/two&lt;/a&gt;&lt;br/&gt;
15
+ </description>
16
+ <author>jon</author>
17
+ <pubDate>Mon, 05 Jul 2004 12:00:04 -0000</pubDate>
18
+ </item>
19
+ <item>
20
+ <title>hipp hurra</title>
21
+ <link>http://cvs.damagecontrol.codehaus.org/</link>
22
+ <description>&lt;b&gt;jon&lt;/b&gt;&lt;br/&gt;
23
+ hipp hurra&lt;p/&gt;
24
+ &lt;a href=&quot;http://cvs.damagecontrol.codehaus.org/path/three?rev=1.3&amp;r=1.3&quot;&gt;path/three&lt;/a&gt;&lt;br/&gt;
25
+ </description>
26
+ <author>jon</author>
27
+ <pubDate>Mon, 05 Jul 2004 12:00:06 -0000</pubDate>
28
+ </item>
29
+
30
+ <generator>RSCM - Ruby Source Control Management</generator>
31
+
32
+
33
+ </channel>
34
+ </rss>