reap 6.0.2 → 9.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/CHANGES +6 -0
  2. data/COPYING +666 -395
  3. data/MANIFEST +139 -0
  4. data/NOTES +12 -0
  5. data/README +19 -163
  6. data/bin/reap-announce +7 -0
  7. data/bin/reap-check-load +8 -0
  8. data/bin/reap-check-syntax +7 -0
  9. data/bin/reap-clean +7 -0
  10. data/bin/reap-clobber +7 -0
  11. data/bin/reap-doc +7 -0
  12. data/bin/reap-doc-rdoc +7 -0
  13. data/bin/reap-doc-ri +7 -0
  14. data/bin/reap-init +69 -0
  15. data/bin/reap-inspect +7 -0
  16. data/bin/reap-install +8 -0
  17. data/bin/reap-install-gem +8 -0
  18. data/bin/reap-log +7 -0
  19. data/bin/reap-log-changes +8 -0
  20. data/bin/reap-log-notes +8 -0
  21. data/bin/reap-make +7 -0
  22. data/bin/reap-make-clean +7 -0
  23. data/bin/reap-make-distclean +7 -0
  24. data/bin/reap-make-extconf +7 -0
  25. data/bin/reap-make-static +8 -0
  26. data/bin/reap-package +8 -0
  27. data/bin/reap-package-gem +7 -0
  28. data/bin/reap-package-tgz +7 -0
  29. data/bin/reap-package-zip +7 -0
  30. data/bin/reap-prepare +7 -0
  31. data/bin/reap-publish +7 -0
  32. data/bin/reap-release +7 -0
  33. data/bin/reap-scaffold +8 -0
  34. data/bin/reap-scm-branch +7 -0
  35. data/bin/reap-scm-tag +7 -0
  36. data/bin/reap-spec +7 -0
  37. data/bin/reap-spec-doc +8 -0
  38. data/bin/reap-stamp +7 -0
  39. data/bin/reap-stats +7 -0
  40. data/bin/reap-test +7 -0
  41. data/bin/reap-test-cross +7 -0
  42. data/bin/reap-test-load +9 -0
  43. data/bin/reap-test-solo +7 -0
  44. data/bin/reap-uninstall +7 -0
  45. data/bin/reap-uninstall-gem +7 -0
  46. data/data/reap/base/CHANGES +19 -0
  47. data/data/reap/base/COPYING +674 -0
  48. data/data/reap/base/NOTES +12 -0
  49. data/data/reap/base/README +8 -0
  50. data/data/reap/build/rake/Rakefile +130 -0
  51. data/{forge/reference/installers → data/reap/build/rake}/setup.rb +155 -97
  52. data/data/reap/build/rake-lite/install.rb +79 -0
  53. data/data/reap/build/tasks/task/rdoc +211 -0
  54. data/data/reap/{setup.rb → build/tasks/task/setup} +248 -200
  55. data/data/reap/build/tasks/task/test +38 -0
  56. data/data/reap/init/meta/project.yaml +21 -0
  57. data/demo/README +15 -0
  58. data/demo/lib/foo/foo.rb +7 -0
  59. data/demo/meta/VERSION +1 -0
  60. data/demo/meta/project.yaml +21 -0
  61. data/lib/reap/application.rb +80 -0
  62. data/lib/reap/default.yaml +77 -0
  63. data/lib/reap/extensions/array.rb +50 -0
  64. data/lib/reap/extensions/hash.rb +63 -0
  65. data/lib/reap/extensions/string.rb +31 -0
  66. data/lib/reap/extensions.rb +6 -0
  67. data/lib/reap/iobject.rb +264 -0
  68. data/lib/reap/manager/announce.rb +193 -0
  69. data/lib/reap/manager/check.rb +109 -0
  70. data/lib/reap/manager/clean.rb +58 -0
  71. data/lib/reap/manager/gem.rb +200 -0
  72. data/lib/reap/manager/html.rb +69 -0
  73. data/lib/reap/manager/log.rb +214 -0
  74. data/lib/reap/manager/make.rb +109 -0
  75. data/lib/reap/manager/pack.rb +232 -0
  76. data/lib/reap/manager/publish.rb +72 -0
  77. data/lib/reap/manager/rdoc.rb +194 -0
  78. data/lib/reap/manager/release.rb +78 -0
  79. data/lib/reap/manager/rubyforge.rb +44 -0
  80. data/lib/reap/manager/scaffold.rb +138 -0
  81. data/lib/reap/manager/scm.rb +66 -0
  82. data/lib/reap/manager/site.rb +27 -0
  83. data/lib/reap/manager/spec.rb +94 -0
  84. data/lib/reap/manager/stats.rb +145 -0
  85. data/lib/reap/manager/svn.rb +76 -0
  86. data/lib/reap/manager/test.rb +389 -0
  87. data/lib/reap/manager.rb +74 -0
  88. data/lib/reap/metadata.rb +603 -0
  89. data/lib/reap/project.rb +165 -0
  90. data/lib/reap/settings.rb +67 -0
  91. data/lib/reap/systems/rubyforge.rb +737 -0
  92. data/lib/reap/systems/subversion.rb +333 -0
  93. data/lib/reap/utilities/fileutils.rb +304 -0
  94. data/lib/reap/utilities/netutils.rb +221 -0
  95. data/lib/reap/utilities/setuputils.rb +124 -0
  96. data/lib/reap/utilities/shellutils.rb +175 -0
  97. data/log/Changelog.txt +107 -0
  98. data/log/FIXME.txt +25 -0
  99. data/log/TODO.txt +72 -0
  100. data/meta/VERSION +1 -0
  101. data/meta/description +4 -0
  102. data/meta/project.yaml +20 -0
  103. data/task/man +14 -0
  104. data/task/rdoc +20 -0
  105. data/{data/reap/scaffold/standard/setup.rb → task/setup} +248 -200
  106. metadata +225 -153
  107. data/ProjectInfo +0 -105
  108. data/bin/reap +0 -5
  109. data/bin/rubytest +0 -5
  110. data/data/reap/install.rb +0 -62
  111. data/data/reap/scaffold/standard/COPYING +0 -403
  112. data/data/reap/scaffold/standard/ChangeLog +0 -0
  113. data/data/reap/scaffold/standard/INSTALL +0 -14
  114. data/data/reap/scaffold/standard/ProjectInfo +0 -77
  115. data/data/reap/scaffold/standard/README +0 -3
  116. data/data/reap/scaffold/standard/Rakefile +0 -10
  117. data/data/reap/scaffold/standard/TODO +0 -0
  118. data/data/reap/scaffold/subversion/trunk/COPYING +0 -403
  119. data/data/reap/scaffold/subversion/trunk/ChangeLog +0 -0
  120. data/data/reap/scaffold/subversion/trunk/INSTALL +0 -14
  121. data/data/reap/scaffold/subversion/trunk/ProjectInfo +0 -76
  122. data/data/reap/scaffold/subversion/trunk/README +0 -3
  123. data/data/reap/scaffold/subversion/trunk/Rakefile +0 -10
  124. data/data/reap/scaffold/subversion/trunk/TODO +0 -0
  125. data/data/reap/scaffold/subversion/trunk/setup.rb +0 -1568
  126. data/forge/ProjectInfo +0 -38
  127. data/forge/ProjectInfo.rb +0 -76
  128. data/forge/TODO +0 -10
  129. data/forge/installer.rb +0 -250
  130. data/forge/reference/Rakefile +0 -124
  131. data/forge/reference/Rakefile.htm +0 -69
  132. data/forge/reference/aRakefile +0 -60
  133. data/forge/reference/compositepublisher.rb +0 -24
  134. data/forge/reference/ftptools.rb +0 -139
  135. data/forge/reference/installers/package.rb +0 -629
  136. data/forge/reference/license-each.rb +0 -85
  137. data/forge/reference/publisher.rb +0 -75
  138. data/forge/reference/rubyforge.rb +0 -247
  139. data/forge/reference/rubyforgepublisher.rb +0 -18
  140. data/forge/reference/sshpublisher.rb +0 -47
  141. data/forge/reference/suby-cvs.rb +0 -46
  142. data/forge/scaffold.rb +0 -126
  143. data/forge/unit_runner/README +0 -6
  144. data/forge/unit_runner/commentrunner.rb +0 -62
  145. data/forge/unit_runner/cunit.rb +0 -17
  146. data/forge/unit_runner/forkedrunner.rb +0 -91
  147. data/forge/unit_runner/sample.rb +0 -16
  148. data/lib/reap/bin/reap.rb +0 -230
  149. data/lib/reap/bin/rubytest.rb +0 -53
  150. data/lib/reap/class/announce.rb +0 -220
  151. data/lib/reap/class/doap.rb +0 -80
  152. data/lib/reap/class/extest.rb +0 -146
  153. data/lib/reap/class/filer.rb +0 -62
  154. data/lib/reap/class/manifest.rb +0 -68
  155. data/lib/reap/class/package.rb +0 -576
  156. data/lib/reap/class/publish.rb +0 -152
  157. data/lib/reap/class/rdoc.rb +0 -123
  158. data/lib/reap/class/test.rb +0 -264
  159. data/lib/reap/projectinfo.rb +0 -208
  160. data/lib/reap/rake.rb +0 -42
  161. data/lib/reap/reap.rb +0 -89
  162. data/lib/reap/tasks.rb +0 -756
  163. data/lib/reap/taskutils.rb +0 -122
  164. data/note/LATEST +0 -44
  165. data/note/doap.xml +0 -28
  166. data/note/history/Rakefile-0.1 +0 -308
  167. data/sample/ProjectInfo +0 -96
  168. data/sample/Rakefile +0 -9
  169. data/sample/Reapfile +0 -11
  170. data/sample/task/demo.rb +0 -15
  171. data/setup.rb +0 -1568
  172. data/web/ProjectInfo.html +0 -75
  173. data/web/images/grape.jpg +0 -0
  174. data/web/index.html +0 -312
@@ -0,0 +1,145 @@
1
+ module Reap
2
+
3
+ class Manager
4
+
5
+ # DEFAULT['stats'] = {
6
+ # 'exclude' => ['ext']
7
+ # }
8
+
9
+ # Simple code count analysis.
10
+ #
11
+ # Scan source code counting files, lines of code and
12
+ # comments and presents a report of it's findings.
13
+ #
14
+ # loadpath Path to include in analysis. The default
15
+ # is the project's loadpath.
16
+ #
17
+ # exclude File globs to exclude from analysis. Default
18
+ # is 'ext' b/c this does not yet support C analysis.
19
+ #
20
+ # TODO: Add C support for ext/.
21
+
22
+ def stats(options=nil)
23
+ options = configure_options(options, 'stats')
24
+
25
+ loadpath = options['loadpath'] || metadata.loadpath
26
+ exclude = options['exclude'] || ['ext']
27
+
28
+ loadpath = list_option(loadpath)
29
+ exclude = list_option(exclude)
30
+
31
+ files = multiglob_r(*loadpath) - multiglob_r(*exclude)
32
+
33
+ #() #.inject([]){ |memo, find| memo.concat(glob(find)); memo }
34
+ #Dir.multiglob_with_default(DEFAULT_STATS_FILES)
35
+
36
+ fc, l, c, r, t, s = *line_count(*files)
37
+
38
+ fct, lt, ct, rt, tt, st = *([0]*6)
39
+ if File.directory?('test')
40
+ fct, lt, ct, rt, tt, st = *line_count('test/**/*')
41
+ t = lt if lt > 0
42
+ end
43
+
44
+ rat = lambda do |d,n|
45
+ if d > n and n != 0
46
+ "%.1f" % [ d.to_f / n ]
47
+ elsif n > d and d != 0
48
+ "-" #"%.1f:1" % [ n.to_f / d ]
49
+ elsif d == 0 or n == 0
50
+ "-"
51
+ else
52
+ "1.0"
53
+ end
54
+ end
55
+
56
+ per = lambda do |n,d|
57
+ if d != 0
58
+ (((n.to_f / d)*100).to_i).to_s + "%"
59
+ else
60
+ "-"
61
+ end
62
+ end
63
+
64
+ max = l.to_s.size + 4
65
+
66
+ puts
67
+ #puts "FILES:"
68
+ #puts " source: #{fc}"
69
+ #puts " test : #{fct}"
70
+ #puts " total : #{fc+fct}"
71
+ #puts
72
+ #puts "LINES:"
73
+ #puts " code : %#{max}s %4s" % [ c.to_s, per[c,l] ]
74
+ #puts " docs : %#{max}s %4s" % [ r.to_s, per[r,l] ]
75
+ #puts " space : %#{max}s %4s" % [ s.to_s, per[s,l] ]
76
+ #puts " test : %#{max}s %4s" % [ t.to_s, per[t,l] ]
77
+ #puts " total : %#{max}s %4s" % [ l.to_s, per[l,l] ]
78
+ #puts
79
+ #puts "Ratio to 1 :"
80
+ #puts " code to test : #{rat[c,t]} #{per[c,t]}"
81
+
82
+ head = ["Total", "Code", "-%-", "Docs", "-%-", "Blank", "-%-", "Files"]
83
+ prod = [l.to_s, c.to_s, per[c,l], r.to_s, per[r,l], s.to_s, per[s,l], fc]
84
+ test = [lt.to_s, ct.to_s, per[ct,l], rt.to_s, per[rt,l], st.to_s, per[st,l], fct]
85
+ totl = [(l+lt), (c+ct), per[c+ct,l+lt], (r+rt), per[r+rt,l+lt], (s+st), per[s+st,l+lt], (fc+fct)]
86
+
87
+ puts "TYPE %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % head
88
+ puts "Source %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % prod
89
+ puts "Test %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % test
90
+ puts "Total %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % totl
91
+ puts
92
+ puts "RATIO Code Docs Blank Test Total"
93
+ puts "Code %7s %7s %7s %7s %7s" % [ rat[c,c], rat[c,r], rat[c,s], rat[c,t], rat[c,l] ]
94
+ puts "Docs %7s %7s %7s %7s %7s" % [ rat[r,c], rat[r,r], rat[r,s], rat[r,t], rat[r,l] ]
95
+ puts "Blank %7s %7s %7s %7s %7s" % [ rat[s,c], rat[s,r], rat[s,s], rat[s,t], rat[s,l] ]
96
+ puts "Test %7s %7s %7s %7s %7s" % [ rat[t,c], rat[t,r], rat[t,s], rat[t,t], rat[t,l] ]
97
+ puts "Total %7s %7s %7s %7s %7s" % [ rat[l,c], rat[l,r], rat[l,s], rat[l,t], rat[l,l] ]
98
+ puts
99
+ end
100
+
101
+ private
102
+
103
+ # Return line counts for files.
104
+
105
+ def line_count(*files)
106
+ files = files.inject([]) do |memo, find|
107
+ memo.concat(Dir.glob(find)); memo
108
+ end
109
+
110
+ fc, l, c, t, r = 0, 0, 0, 0, 0
111
+ bt, rb = false, false
112
+
113
+ files.each do |fname|
114
+ next unless fname =~ /.*rb/ # TODO should this be done?
115
+ fc += 1
116
+ File.open( fname ) do |f|
117
+ while line = f.gets
118
+ l += 1
119
+ next if line =~ /^\s*$/
120
+ case line
121
+ when /^=begin\s+test/
122
+ tb = true; t+=1
123
+ when /^=begin/
124
+ rb = true; r+=1
125
+ when /^=end/
126
+ t+=1 if tb
127
+ r+=1 if rb
128
+ rb, tb = false, false
129
+ when /^\s*#/
130
+ r += 1
131
+ else
132
+ c+=1 if !(rb or tb)
133
+ r+=1 if rb
134
+ t+=1 if tb
135
+ end
136
+ end
137
+ end
138
+ end
139
+ s = l - c - r - t
140
+ return fc, l, c, r, t, s
141
+ end
142
+
143
+ end
144
+
145
+ end
@@ -0,0 +1,76 @@
1
+ require 'reap/systems/subversion'
2
+
3
+ module Reap
4
+
5
+ class Manager
6
+
7
+ # Branch current version.
8
+ #
9
+ # message Optional commit message. This is intended for commandline
10
+ # usage. (Use -m for shorthand).
11
+ #
12
+ # TODO: How should metadata.repository come into play here?
13
+
14
+ def svn_branch(options=nil)
15
+ options = configure_options(options, 'scm-branch', 'scm')
16
+ svn_system.branch(options)
17
+ end
18
+
19
+ # Tag current version.
20
+ #
21
+ # message Optional commit message. This is intended for commandline
22
+ # usage. (Use -m for shorthand).
23
+ #
24
+ # TODO: How should metadata.repository come into play here?
25
+
26
+ def svn_tag(options=nil)
27
+ options = configure_options(options, 'scm-tag', 'scm')
28
+ svn_system.tag(options)
29
+ end
30
+
31
+ # Create changelog.
32
+ #
33
+ # change File path to store rdoc formated changelog. Default is 'log/changelog.txt'.
34
+ # xmlchange File path to store XML formated changelog. Default is 'doc/log/changelog.xml'.
35
+ #
36
+ # Set either to false to supress creation.
37
+
38
+ def svn_log(options=nil)
39
+ txtlog = options['txtlog']
40
+ xmllog = options['xmllog']
41
+
42
+ svn_system.log(txtlog)
43
+ svn_system.log_xml(xmllog) if xmllog
44
+ end
45
+
46
+ private
47
+
48
+ # Branch current version.
49
+ #
50
+ # repository Developers URL to repository. Defaults to Rubyforge address.
51
+ # username Username. Defaults to ENV['RUBYFORGE_USERNAME'].
52
+ # protocol The URL protocol to use. Defaults to "svn+ssh".
53
+ # prefix Prefix to use on tag folder. Default is no prefix.
54
+ # tagpath Directory to store tags. Defaults to tags/.
55
+ # branchpath Directory to store branches. Defaults to branches/.
56
+ #
57
+ def svn_system
58
+ @svn_system ||= (
59
+ options = configuration['svn'] || {}
60
+
61
+ rubyforge = configuration['rubyforge'] || {}
62
+
63
+ options['repository'] ||= metadata.repository
64
+ options['dryrun'] ||= dryrun?
65
+ options['project'] ||= rubyforge['project'] || metadata.project
66
+
67
+ options['version'] = metadata.version
68
+
69
+ Subversion.new(options)
70
+ )
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
@@ -0,0 +1,389 @@
1
+ # TITLE:
2
+ #
3
+ # Test
4
+ #
5
+ # TODO:
6
+ # - Needs to be made DRY.
7
+ # - Perhaps simplifiy this, making it more like the load test.
8
+ # And simply collect that parse the output of each test.
9
+
10
+ require 'facets/hash/rekey'
11
+ require 'facets/string/tabs'
12
+ require 'facets/progressbar'
13
+
14
+ module Reap
15
+
16
+ class Manager
17
+
18
+ # DEFAULT['test'] = {
19
+ # 'tests' => 'test/**/{test,tc}_*.rb',
20
+ # 'loadpath' => ['lib'],
21
+ # 'require' => [],
22
+ # 'exclude' => ['ext'],
23
+ # 'live' => false
24
+ # }
25
+
26
+ private
27
+
28
+ # Collect test configuation.
29
+
30
+ def test_configuration(options=nil)
31
+ options = configure_options(options, 'test')
32
+
33
+ options['loadpath'] ||= metadata.loadpath
34
+
35
+ #options['tests'] ||= DEFAULT['test']['tests']
36
+ #options['loadpath'] ||= DEFAULT['test']['loadpath']
37
+ #options['exclude'] ||= DEFAULT['test']['exclude']
38
+ #options['require'] ||= DEFAULT['test']['require']
39
+ #options['live'] ||= DEFAULT['test']['live']
40
+
41
+ options['tests'] = list_option(options['tests'])
42
+ options['loadpath'] = list_option(options['loadpath'])
43
+ options['exclude'] = list_option(options['exclude'])
44
+ options['require'] = list_option(options['require'])
45
+
46
+ return options
47
+ end
48
+
49
+ public
50
+
51
+ # Run unit tests. Unlike test-solo and test-cross this loads
52
+ # all tests and runs them together in a single process.
53
+ #
54
+ # Note that this shells out to the testrb program.
55
+ #
56
+ # TODO: Generate a test log entry?
57
+
58
+ def test_unit(options={})
59
+ options = test_configuration(options)
60
+
61
+ tests = options['tests']
62
+ loadpath = options['loadpath']
63
+ requires = options['requires']
64
+ live = options['live']
65
+ exclude = options['exclude']
66
+ #log = options['log'] != false
67
+ #logfile = File.join('log', apply_naming_policy('test', 'log'))
68
+
69
+ # what about arguments for selecting specific tests?
70
+ tests = options['arguments'] if options['arguments']
71
+
72
+ unless live
73
+ loadpath.each do |lp|
74
+ $LOAD_PATH.unshift(File.expand_path(lp))
75
+ end
76
+ end
77
+
78
+ files = multiglob_r(*tests)
79
+
80
+ if files.empty?
81
+ puts "No tests."
82
+ return
83
+ end
84
+
85
+ filelist = files.select{|file| !File.directory?(file) }.join(' ')
86
+ command = %[testrb -I#{loadpath} #{filelist} 2>&1]
87
+ system command
88
+
89
+ #if log && !dryrun?
90
+ # command = %[testrb -I#{loadpath} #{filelist} > #{logfile} 2>&1] # /dev/null 2>&1
91
+ # system command
92
+ # puts "Updated #{logfile}"
93
+ #end
94
+ end
95
+
96
+ # Load each test independently to ensure there are no
97
+ # require dependency issues. This is actually a bit redundant
98
+ # as test-solo will also cover these results. So we may deprecate
99
+ # this in the future. This does not generate a test log entry.
100
+
101
+ def test_load(options=nil)
102
+ options = test_configuration(options)
103
+
104
+ tests = options['tests']
105
+ loadpath = options['loadpath']
106
+ requires = options['requires']
107
+ live = options['live']
108
+ exclude = options['exclude']
109
+
110
+ files = multiglob_r(*tests) - multiglob_r(*exclude)
111
+
112
+ return puts("No tests.") if files.empty?
113
+
114
+ max = files.collect{ |f| f.size }.max
115
+ list = []
116
+
117
+ files.each do |f|
118
+ next unless File.file?(f)
119
+ if r = system("ruby -I#{loadpath.join(':')} #{f} > /dev/null 2>&1")
120
+ puts "%-#{max}s [PASS]" % [f] #if verbose?
121
+ else
122
+ puts "%-#{max}s [FAIL]" % [f] #if verbose?
123
+ list << f
124
+ end
125
+ end
126
+
127
+ puts " #{list.size} Load Failures"
128
+
129
+ if verbose?
130
+ unless list.empty?
131
+ puts "\n-- Load Failures --\n"
132
+ list.each do |f|
133
+ print "* "
134
+ system "ruby -I#{loadpath} #{f} 2>&1"
135
+ #puts
136
+ end
137
+ puts
138
+ end
139
+ end
140
+ end
141
+
142
+ # Run unit-tests. Each test is run in a separate interpretor
143
+ # to prevent script clash. This makes for a more robust test
144
+ # facility and prevents potential conflicts between test scripts.
145
+ #
146
+ # tests Test files (eg. test/tc_**/*.rb) [test/**/*]
147
+ # loadpath Directories to include in load path [lib].
148
+ # require List of files to require prior to running tests.
149
+ # live Deactive use of local libs and test against install.
150
+
151
+ def test_solo(options=nil)
152
+ options = test_configuration(options)
153
+
154
+ tests = options['tests']
155
+ loadpath = options['loadpath']
156
+ requires = options['requires']
157
+ live = options['live']
158
+ exclude = options['exclude']
159
+ log = options['log'] != false
160
+
161
+ files = multiglob_r(*tests) - multiglob_r(*exclude)
162
+
163
+ return puts("No tests.") if files.empty?
164
+
165
+ files = files.select{ |f| File.extname(f) == '.rb' and File.file?(f) }
166
+ width = files.collect{ |f| f.size }.max
167
+
168
+ make if compiles?
169
+
170
+ cmd = %[ruby -I#{loadpath.join(':')} %s]
171
+ dis = "%-#{width}s"
172
+
173
+ testruns = files.collect do |file|
174
+ { 'files' => file,
175
+ 'command' => cmd % file,
176
+ 'display' => dis % file
177
+ }
178
+ end
179
+
180
+ report = test_loop_runner(testruns)
181
+
182
+ puts report
183
+
184
+ if log && !dryrun?
185
+ logfile = File.join('log', apply_naming_policy('testlog', 'txt'))
186
+ File.open(logfile, 'a') do |f|
187
+ f << "= Solo Test @ #{Time.now}\n"
188
+ f << report
189
+ f << "\n"
190
+ end
191
+ end
192
+ end
193
+
194
+ # Run cross comparison testing.
195
+ #
196
+ # This tool runs unit tests in pairs to make sure there is cross
197
+ # library compatibility. Each pari is run in a separate interpretor
198
+ # to prevent script clash. This makes for a more robust test
199
+ # facility and prevents potential conflicts between test scripts.
200
+ #
201
+ # tests Test files (eg. test/tc_**/*.rb) [test/**/*]
202
+ # loadpath Directories to include in load path.
203
+ # require List of files to require prior to running tests.
204
+ # live Deactive use of local libs and test against install.
205
+
206
+ def test_cross(options=nil)
207
+ options = test_configuration(options)
208
+
209
+ tests = options['tests']
210
+ loadpath = options['loadpath']
211
+ requires = options['requires']
212
+ live = options['live']
213
+ exclude = options['exclude']
214
+ log = options['log'] != false
215
+
216
+ files = multiglob_r(*tests) - multiglob_r(exclude)
217
+
218
+ return puts("No tests.") if files.empty?
219
+
220
+ files = files.select{ |f| File.extname(f) == '.rb' and File.file?(f) }
221
+ width = files.collect{ |f| f.size }.max
222
+ pairs = files.inject([]){ |m, f| files.collect{ |g| m << [f,g] }; m }
223
+
224
+ make if compiles?
225
+
226
+ cmd = %[ruby -I#{loadpath.join(':')} -e"load('./%s'); load('%s')"]
227
+ dis = "%-#{width}s %-#{width}s"
228
+
229
+ testruns = pairs.collect do |pair|
230
+ { 'file' => pair,
231
+ 'command' => cmd % pair,
232
+ 'display' => dis % pair
233
+ }
234
+ end
235
+
236
+ report = test_loop_runner(testruns)
237
+
238
+ puts report
239
+
240
+ if log && !dryrun?
241
+ logfile = File.join('log', apply_naming_policy('testlog', 'txt'))
242
+ File.open(logfile, 'a') do |f|
243
+ f << "= Cross Test @ #{Time.now}\n"
244
+ f << report
245
+ f << "\n"
246
+ end
247
+ end
248
+ end
249
+
250
+ private
251
+
252
+ # Runs the list of test calls passed to it.
253
+ # This is used by #test_solo and #test_cross.
254
+
255
+ def test_loop_runner(testruns)
256
+ width = testruns.collect{ |tr| tr['display'].size }.max
257
+
258
+ testruns = if trace?
259
+ test_loop_runner_trace(testruns)
260
+ elsif verbose?
261
+ test_loop_runner_verbose(testruns)
262
+ else
263
+ test_loop_runner_progress(testruns)
264
+ end
265
+
266
+ tally = test_tally(testruns)
267
+
268
+ report = ""
269
+ report << "\n%-#{width}s %10s %10s %10s %10s" % [ 'TEST FILE', ' TESTS ', 'ASSERTIONS', ' FAILURES ', ' ERRORS ' ]
270
+ report << "\n"
271
+
272
+ testruns.each do |testrun|
273
+ count = testrun['count']
274
+ pass = (count[2] == 0 and count[3] == 0)
275
+
276
+ report << "%-#{width}s " % [testrun['display']]
277
+ report << "%10s %10s %10s %10s" % count
278
+ report << " " * 8
279
+ report << (pass ? "[PASS]" : "[FAIL]")
280
+ report << "\n"
281
+ end
282
+
283
+ report << "%-#{width}s " % "TOTAL"
284
+ report << "%10s %10s %10s %10s" % tally
285
+
286
+ #puts("\n%i tests, %i assertions, %i failures, %i errors\n\n" % tally)
287
+
288
+ report << "\n\n"
289
+
290
+ fails = []
291
+
292
+ fails = testruns.select do |testrun|
293
+ count = testrun['count']
294
+ count[2] != 0 or count[3] != 0
295
+ end
296
+
297
+ if tally[2] != 0 or tally[3] != 0
298
+ unless fails.empty? # or verbose?
299
+ report << "-- Failures and Errors --\n\n"
300
+ fails.uniq.each do |testrun|
301
+ report << testrun['result']
302
+ end
303
+ report << "\n"
304
+ end
305
+ end
306
+
307
+ return report
308
+ end
309
+
310
+ #
311
+
312
+ def test_loop_runner_verbose(testruns)
313
+ testruns.each do |testrun|
314
+ result = `#{testrun['command']}`
315
+ count = test_parse_result(result)
316
+ testrun['count'] = count
317
+ testrun['result'] = result
318
+
319
+ puts "\n" * 3; puts result
320
+ end
321
+ puts "\n" * 3
322
+
323
+ return testruns
324
+ end
325
+
326
+ #
327
+
328
+ def test_loop_runner_progress(testruns)
329
+ pbar = Console::ProgressBar.new( 'Testing', testruns.size )
330
+ pbar.inc
331
+ testruns.each do |testrun|
332
+ pbar.inc
333
+
334
+ result = `#{testrun['command']}`
335
+ count = test_parse_result(result)
336
+ testrun['count'] = count
337
+ testrun['result'] = result
338
+ end
339
+ pbar.finish
340
+
341
+ return testruns
342
+ end
343
+
344
+ #
345
+
346
+ def test_loop_runner_trace(testruns)
347
+ width = testruns.collect{ |tr| tr['display'].size }.max
348
+
349
+ testruns.each do |testrun|
350
+ print "%-#{width}s " % [testrun['display']]
351
+
352
+ result = `#{testrun['command']}`
353
+ count = test_parse_result(result)
354
+ testrun['count'] = count
355
+ testrun['result'] = result
356
+
357
+ pass = (count[2] == 0 and count[3] == 0)
358
+ puts(pass ? "[PASS]" : "[FAIL]")
359
+ end
360
+
361
+ return testruns
362
+ end
363
+
364
+ #
365
+
366
+ def test_tally(testruns)
367
+ counts = testruns.collect{ |tr| tr['count'] }
368
+ tally = [0,0,0,0]
369
+ counts.each do |count|
370
+ 4.times{ |i| tally[i] += count[i] }
371
+ end
372
+ return tally
373
+ end
374
+
375
+ #
376
+
377
+ def test_parse_result(result)
378
+ if md = /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors/.match(result)
379
+ count = md[1..4].collect{|q| q.to_i}
380
+ else
381
+ count = [1, 0, 0, 1] # SHOULD NEVER HAPPEN
382
+ end
383
+ return count
384
+ end
385
+
386
+ end
387
+
388
+ end
389
+
@@ -0,0 +1,74 @@
1
+ require 'yaml'
2
+ require 'rbconfig' # replace with facets/system?
3
+
4
+ require 'reap/extensions'
5
+ require 'reap/utilities/fileutils'
6
+ require 'reap/utilities/shellutils'
7
+ require 'reap/utilities/netutils'
8
+
9
+ module Reap
10
+
11
+ class Manager
12
+ # Default constant is used my various tools
13
+ # to soter the defualts for options. By using this
14
+ # it easy to dump a complete list of built-in
15
+ # defaults. Defaults should be patterned after the
16
+ # configuration file agsint which they will be used.
17
+
18
+ DEFAULT = {}
19
+
20
+ include Utilities::ShellUtils
21
+ include Utilities::FileUtils
22
+ include Utilities::NetUtils
23
+ end
24
+
25
+ #class Project < Manager; end
26
+
27
+ end
28
+
29
+ # Load up all the tools
30
+ require "reap/manager/announce.rb"
31
+ require "reap/manager/check.rb"
32
+ require "reap/manager/clean.rb"
33
+ require "reap/manager/gem.rb"
34
+ require "reap/manager/html.rb"
35
+ require "reap/manager/log.rb"
36
+ require "reap/manager/make.rb"
37
+ require "reap/manager/pack.rb"
38
+ require "reap/manager/publish.rb"
39
+ require "reap/manager/rdoc.rb"
40
+ require "reap/manager/release.rb"
41
+ require "reap/manager/scaffold.rb"
42
+ require "reap/manager/site.rb"
43
+ require "reap/manager/spec.rb"
44
+ require "reap/manager/stats.rb"
45
+ require "reap/manager/scm.rb"
46
+ require "reap/manager/svn.rb"
47
+ require "reap/manager/test.rb"
48
+
49
+
50
+ #def html
51
+ # config = configuration['rd2html']
52
+ # webmaker = RD2Html.new(config)
53
+ # webmaker.rd2html
54
+ #end
55
+
56
+ # Update release "stamp" (.roll) file.
57
+
58
+ #def stamp
59
+ # # You can change these via the command line.
60
+ # version = commandline['version'] || release.version
61
+ # status = commandline['status'] || release.status
62
+ #
63
+ # if version != release.version or status != release.status
64
+ # Stamp.new(
65
+ # :version => version,
66
+ # :status => status,
67
+ # :file => release.file,
68
+ # :name => release.name,
69
+ # :default => release.default,
70
+ # :libpath => release.libpath
71
+ # ).stamp
72
+ # end
73
+ #end
74
+