ratch 0.4.1 → 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.
Files changed (107) hide show
  1. data/COPYING +17 -669
  2. data/HISTORY +6 -0
  3. data/MANIFEST +36 -0
  4. data/METADATA +14 -0
  5. data/NEWS +7 -0
  6. data/README +67 -17
  7. data/bin/ratch +5 -78
  8. data/demo/tryme-task.ratch +12 -0
  9. data/demo/tryme1.ratch +6 -0
  10. data/lib/ratch/core_ext.rb +6 -0
  11. data/lib/ratch/core_ext/facets.rb +1 -0
  12. data/lib/ratch/core_ext/filetest.rb +52 -0
  13. data/lib/ratch/core_ext/object.rb +8 -0
  14. data/lib/ratch/core_ext/pathname.rb +38 -0
  15. data/lib/ratch/core_ext/string.rb +44 -0
  16. data/lib/ratch/{dsl/console.rb → core_ext/to_console.rb} +2 -76
  17. data/lib/ratch/core_ext/to_list.rb +29 -0
  18. data/lib/ratch/dsl.rb +494 -49
  19. data/lib/ratch/index.rb +4 -0
  20. data/lib/ratch/io.rb +116 -0
  21. data/lib/ratch/pathglob.rb +73 -0
  22. data/lib/ratch/plugin.rb +55 -0
  23. data/lib/ratch/runmode.rb +69 -0
  24. data/lib/ratch/script.rb +52 -0
  25. data/lib/ratch/service.rb +33 -0
  26. data/lib/ratch/task.rb +249 -0
  27. data/lib/ratch/task2.rb +298 -0
  28. data/test/README +1 -0
  29. data/test/test_helper.rb +4 -0
  30. data/test/test_task.rb +46 -0
  31. metadata +90 -150
  32. data/CHANGES +0 -22
  33. data/TODO +0 -2
  34. data/bin/lt +0 -56
  35. data/bin/ludo +0 -14
  36. data/bin/manifest +0 -451
  37. data/bin/ratch-find +0 -21
  38. data/demo/WILMA +0 -1
  39. data/demo/XR +0 -9
  40. data/demo/lib/foo/foo.rb +0 -7
  41. data/demo/p.rb +0 -9
  42. data/demo/r.rb +0 -6
  43. data/demo/t.rb +0 -3
  44. data/demo/task/config.yaml +0 -4
  45. data/demo/task/one +0 -6
  46. data/demo/task/simplebuild +0 -15
  47. data/demo/task/stats +0 -4
  48. data/demo/task/task +0 -6
  49. data/demo/task/tryme +0 -10
  50. data/lib/ratch/dsl/argv.rb +0 -112
  51. data/lib/ratch/dsl/batch.rb +0 -232
  52. data/lib/ratch/dsl/build.rb +0 -174
  53. data/lib/ratch/dsl/email.rb +0 -108
  54. data/lib/ratch/dsl/file.rb +0 -205
  55. data/lib/ratch/dsl/meta.rb +0 -125
  56. data/lib/ratch/dsl/options.rb +0 -98
  57. data/lib/ratch/dsl/setup.rb +0 -124
  58. data/lib/ratch/dsl/sign.rb +0 -243
  59. data/lib/ratch/dsl/stage.rb +0 -147
  60. data/lib/ratch/dsl/task.rb +0 -139
  61. data/lib/ratch/dsl/upload.rb +0 -436
  62. data/lib/ratch/dsl/zip.rb +0 -59
  63. data/lib/ratch/extra/email.rb +0 -5
  64. data/lib/ratch/extra/stage.rb +0 -5
  65. data/lib/ratch/extra/zip.rb +0 -5
  66. data/lib/ratch/manager.rb +0 -53
  67. data/lib/ratch/manifest.rb +0 -540
  68. data/lib/ratch/metadata/information.rb +0 -258
  69. data/lib/ratch/metadata/package.rb +0 -108
  70. data/lib/ratch/metadata/project.rb +0 -523
  71. data/lib/ratch/metadata/release.rb +0 -108
  72. data/lib/ratch/support/errors.rb +0 -4
  73. data/lib/ratch/support/filename.rb +0 -18
  74. data/lib/ratch/support/filetest.rb +0 -29
  75. data/lib/ratch/toolset/ruby/announce +0 -224
  76. data/lib/ratch/toolset/ruby/compile +0 -49
  77. data/lib/ratch/toolset/ruby/install +0 -77
  78. data/lib/ratch/toolset/ruby/notes +0 -185
  79. data/lib/ratch/toolset/ruby/pack/gem +0 -93
  80. data/lib/ratch/toolset/ruby/pack/tgz +0 -46
  81. data/lib/ratch/toolset/ruby/pack/zip +0 -46
  82. data/lib/ratch/toolset/ruby/publish +0 -57
  83. data/lib/ratch/toolset/ruby/release +0 -8
  84. data/lib/ratch/toolset/ruby/setup +0 -1616
  85. data/lib/ratch/toolset/ruby/stamp +0 -33
  86. data/lib/ratch/toolset/ruby/stats +0 -138
  87. data/lib/ratch/toolset/ruby/test/crosstest +0 -305
  88. data/lib/ratch/toolset/ruby/test/extest +0 -129
  89. data/lib/ratch/toolset/ruby/test/isotest +0 -293
  90. data/lib/ratch/toolset/ruby/test/load +0 -39
  91. data/lib/ratch/toolset/ruby/test/loadtest +0 -28
  92. data/lib/ratch/toolset/ruby/test/syntax +0 -29
  93. data/lib/ratch/toolset/ruby/test/test +0 -26
  94. data/lib/ratch/toolset/sandbox/query +0 -11
  95. data/man/ratch.man +0 -73
  96. data/meta/MANIFEST +0 -130
  97. data/meta/config.yaml +0 -9
  98. data/meta/icli.yaml +0 -16
  99. data/meta/project.yaml +0 -20
  100. data/meta/ratch.roll +0 -2
  101. data/meta/xProjectInfo +0 -41
  102. data/task/clobber/package +0 -10
  103. data/task/man +0 -14
  104. data/task/publish +0 -57
  105. data/task/release +0 -9
  106. data/task/setup +0 -1616
  107. data/task/stats +0 -138
@@ -1,129 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # Extract embedded tests.
4
-
5
- # Extract unit tests. This task scans every package script
6
- # looking for sections of the form:
7
- #
8
- # =begin test
9
- # ...
10
- # =end
11
- #
12
- # With appropriate headers, it copies these sections to files
13
- # in your project's test/ dir, which then can be run using the
14
- # Ratchet test task. The exact directory layout of the files to
15
- # be tested is reflected in the test directory. You can then
16
- # use project.rb's test task to run the tests.
17
- #
18
- # files Files to extract ['lib/**/*.rb']
19
- # output Test directory ['test/']
20
-
21
- main :extest do
22
- extract_tests # Deal with arg once rathc has better support fot it.
23
- end
24
-
25
- # Extract tests for scripts.
26
-
27
- def extract_tests(files=nil)
28
- output = 'test/embedded' # Don't think output should be setable.
29
-
30
- files = files || 'lib/**/*.rb'
31
- files = 'lib/**/*.rb' if TrueClass == files
32
- files = [files].flatten.compact
33
-
34
- filelist = files.collect{ |f| Dir.glob(f) }
35
- filelist.flatten!
36
- if filelist.empty?
37
- puts "No scripts found from which to extract tests."
38
- return
39
- end
40
-
41
- mkdir_p(output) unless directory?(output)
42
-
43
- #vrunner = VerbosityRunner.new("Extracting", verbosity?)
44
- #vrunner.setup(filelist.size)
45
-
46
- filelist.each do |file|
47
- #vrunner.prepare(file)
48
-
49
- testing = extract_test_from_file( file )
50
- if testing.strip.empty?
51
- status = "[NONE]"
52
- else
53
- complete_test = create_test(testing, file)
54
- libpath = File.dirname(file)
55
- testfile = "test_" + File.basename(file)
56
- fp = File.join(output, libpath, testfile)
57
- unless directory?( File.dirname(fp))
58
- mkdir_p(File.dirname(fp))
59
- end
60
- if dryrun?
61
- puts "write #{fp}"
62
- else
63
- File.open(fp, "w"){ |fw| fw << complete_test }
64
- end
65
- status = "[TEST]"
66
- end
67
-
68
- #vrunner.complete(file, status)
69
- end
70
-
71
- #vrunner.finish(
72
- # :normal => "#{filelist.size} files had tests extracted.",
73
- # :check => false
74
- #)
75
- end
76
-
77
- private
78
-
79
- # Extract test from a file's testing comments.
80
-
81
- def extract_test_from_file( file )
82
- return nil if ! File.file?( file )
83
- tests = ""; inside = false
84
- fstr = File.read( file )
85
- fstr.split(/\n/).each do |l|
86
- if l =~ /^=begin[ ]*test/i
87
- tests << "\n"
88
- inside = true
89
- next
90
- elsif inside and l =~ /^=[ ]*end/
91
- inside = false
92
- next
93
- end
94
- if inside
95
- tests << l << "\n"
96
- end
97
- end
98
- tests
99
- end
100
-
101
- # Generate the test.
102
-
103
- def create_test( testing, file )
104
- fp = file.split(/[\/]/)
105
- if fp[0] == 'lib'
106
- reqf = "require '#{fp[1..-1].join('/')}'"
107
- else
108
- reqf = ''
109
- end
110
- str = []
111
- str << " # _____ _"
112
- str << " # |_ _|__ ___| |_"
113
- str << " # | |/ _ \\/ __| __|"
114
- str << " # | | __/\\__ \\ |"
115
- str << " # |_|\\___||___/\\__|"
116
- str << " #"
117
- str << " # for #{file}"
118
- str << " #"
119
- str << " # Extracted #{Time.now}"
120
- str << " # w/ Test Extraction Ratchet"
121
- str << " #"
122
- str << ""
123
- str << " #{reqf}"
124
- str << ""
125
- str << testing
126
- str << "\n"
127
- str = str.join("\n")
128
- str
129
- end
@@ -1,293 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- #
4
- require 'facets/hash/rekey'
5
- require 'facets/string/tabs'
6
- require 'facets/progressbar'
7
-
8
- require 'test/unit/ui/testrunnermediator' #require 'test/unit'
9
- ::Test::Unit.run = true # Don't autorun tests!
10
-
11
- main :isotestsolid do
12
- run_isotests
13
- end
14
-
15
- # Run unit-tests. Each test is run in a separate interpretor
16
- # to prevent script clash. This makes for a more robust test
17
- # facility and prevents potential conflicts between test scripts.
18
- #
19
- # tests Test files (eg. test/tc_**/*.rb) [test/**/*]
20
- # libs Directories to include in load path.
21
- # ('./lib' is always included)
22
- # live Deactive use of local libs and test against install.
23
- # reqs List of files to require prior to running tests.
24
- # extract Extract embedded tests first? [false]
25
- #
26
- # To isolate tests this tool marshals test results across a
27
- # stdout->stdin shell pipe. This prevents interfence of one
28
- # script's tests on another. But consequently it is not always
29
- # possible to send debug info to stdout in the tests themselves
30
- # (eg. #p and #puts).
31
-
32
- def run_isotests
33
- info = configuration['test']
34
-
35
- tests = info['files'] || 'test/unit/**/test_*.rb'
36
- libs = info['libpath']
37
- reqs = info['require']
38
- live = info['live']
39
- #extract = info['extract']
40
-
41
- tests = [ tests ].flatten
42
- libs = [ libs ].flatten
43
-
44
- #files = [ @files ].flatten
45
- #extract_tests if extract
46
-
47
- results = TestResults.new #(style)
48
-
49
- # get test files
50
- test_libs = libs.join(':')
51
- test_files = Dir.multiglob( *tests )
52
- if test_files.empty?
53
- puts "Tests [NONE]"
54
- return
55
- end
56
-
57
- # run tests
58
-
59
- if trace?
60
- pbar = nil
61
- size = test_files.collect{|f| f.size}.max + 5
62
- dots = '.' * size
63
- else
64
- pbar = Console::ProgressBar.new( 'Testing', test_files.size )
65
- pbar.inc
66
- end
67
-
68
- test_files.each do |test_file|
69
- pbar.inc if pbar
70
- if ! File.file?(test_file)
71
- next #r = nil
72
- else
73
- unless pbar
74
- print test_file + dots[test_file.size..-1]
75
- $stdout.flush
76
- end
77
- r = fork_test( test_file, :libs=>libs, :reqs=>reqs, :live=>live )
78
- unless pbar
79
- puts r.passed? ? "[PASS]" : "[FAIL]"
80
- end
81
- end
82
- results << r
83
- end
84
-
85
- pbar.finish if pbar
86
-
87
- # display results
88
- puts results
89
-
90
- fails, errrs = results.failure_count, results.error_count
91
- #CHECKLIST << :test if fails > 0
92
- #CHECKLIST << :test if errrs > 0
93
- return (fails + errrs > 0)
94
- end
95
-
96
- # Run a test in a separate process.
97
- #
98
- # Currently send program output to null device.
99
- # Could send to a logger in future version.
100
- #
101
- # Key parameters are libs, reqs, live.
102
-
103
- def fork_test( file, keys )
104
- keys = keys.rekey(:to_s)
105
-
106
- libs = keys['lib'] || []
107
- reqs = keys['req'] || []
108
- live = keys['live']
109
-
110
- src = ''
111
-
112
- unless live
113
- l = File.join( Dir.pwd, 'lib' )
114
- if File.directory?( l )
115
- src << %{$:.unshift('#{l}')\n}
116
- end
117
- libs.each { |r| src << %{$:.unshift('#{r}')\n} }
118
- end
119
-
120
- src << %{
121
- #require 'test/unit'
122
- require 'test/unit/collector'
123
- require 'test/unit/collector/objectspace'
124
- require 'test/unit/ui/testrunnermediator'
125
- }
126
-
127
- reqs.each do |fix|
128
- src << %Q{
129
- require '#{fix}'
130
- }
131
- end
132
-
133
- src << %{
134
- def warn(*null); end # silence warnings
135
-
136
- output = STDOUT.dup
137
- STDOUT.reopen( PLATFORM =~ /mswin/ ? "NUL" : "/dev/null" )
138
-
139
- load('#{file}')
140
- tests = Test::Unit::Collector::ObjectSpace.new.collect
141
- runner = Test::Unit::UI::TestRunnerMediator.new( tests )
142
- result = runner.run_suite
143
-
144
- begin
145
- marshalled = Marshal.dump(result)
146
- rescue TypeError => e
147
- $stderr << "MARSHAL ERROR\n"
148
- $stderr << "TEST: #{file}\n"
149
- $stderr << "DATA:" << result.inspect
150
- exit -1
151
- end
152
- output << marshalled
153
-
154
- STDOUT.reopen(output)
155
- output.close
156
- }
157
-
158
- result = IO.popen("ruby","w+") do |ruby|
159
- ruby.puts src
160
- ruby.close_write
161
- ruby.read
162
- end
163
-
164
- begin
165
- marsh = Marshal.load(result)
166
- rescue ArgumentError
167
- $stderr << "\nCannot load marshalled test data.\n"
168
- $stderr << result << "\n"
169
- exit -1
170
- end
171
-
172
- return marsh
173
- end
174
-
175
- #
176
- # Support class for collecting test results.
177
- #
178
-
179
- class TestResults
180
- attr_reader :assertion_count,
181
- :run_count,
182
- :failure_count,
183
- :error_count
184
-
185
- attr_accessor :style
186
-
187
- def initialize( style=nil )
188
- @style = style
189
-
190
- @results = []
191
-
192
- @assertion_count = 0
193
- @run_count = 0
194
- @failure_count = 0
195
- @error_count = 0
196
- end
197
-
198
- # Add a result to the results collection.
199
-
200
- def <<( result )
201
- @results << result
202
-
203
- @assertion_count += result.assertion_count
204
- @run_count += result.run_count
205
- @failure_count += result.failure_count
206
- @error_count += result.error_count
207
- end
208
-
209
- #
210
-
211
- def errors
212
- errors = []
213
- @results.each do |r|
214
- unless r.passed?
215
- errors << r.instance_variable_get('@errors')
216
- end
217
- end
218
- errors.reject! { |e| e == [] }
219
- errors
220
- end
221
-
222
- #
223
-
224
- def failures
225
- failures = []
226
- @results.each do |r|
227
- unless r.passed?
228
- failures << r.instance_variable_get('@failures')
229
- end
230
- end
231
- failures.reject! { |e| e == [] }
232
- failures
233
- end
234
-
235
- # Output format for test results.
236
-
237
- def to_s
238
- return @results.to_s if style == 'pease'
239
-
240
- s = []
241
- # Display failures
242
- unless failures.empty?
243
- s << ''
244
- s << "FAILURES:"
245
- failures.reverse.each do |fails|
246
- fails.reverse.each do |failure|
247
- #puts
248
- s << %{ - test : #{failure.test_name}}
249
- s << %{ location : #{failure.location}}
250
- if failure.message.index("\n")
251
- s << %{ message : >}
252
- s << failure.message.tabto(6)
253
- else
254
- s << %{ message : #{failure.message}}
255
- end
256
- end
257
- end
258
- end
259
-
260
- # Display errors
261
- unless errors.empty?
262
- s << ''
263
- s << "ERRORS:"
264
- errors.reverse.each do |errs|
265
- errs.reverse.each do |err|
266
- s << ''
267
- s << %{ - test : #{err.test_name}}
268
- s << %{ message : #{err.exception.message}}
269
- s << %{ backtrace :}
270
- err.exception.backtrace[0...-1].each { |bt| s << %Q{ - #{bt}} }
271
- end
272
- end
273
- end
274
-
275
- # Display final results
276
- s << ''
277
- s << "Summary:"
278
- s << " Tests : #{@run_count}"
279
- s << " Assertions : #{@assertion_count}"
280
- s << " Failures : #{@failure_count}"
281
- s << " Errors : #{@error_count}"
282
- s << ''
283
- s << ''
284
-
285
- return s.join("\n")
286
- end
287
-
288
- # Delegate missing call to the results array.
289
-
290
- def method_missing(*a,&b)
291
- @results.send(*a,&b)
292
- end
293
- end
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ratch
2
-
3
- # Load check all libs.
4
-
5
- #
6
-
7
- require 'benchmark'
8
-
9
- $:.unshift('lib')
10
-
11
- scripts_core, scripts_more = [], []
12
- Dir.chdir('lib') do
13
- scripts_more = glob('facets/*.rb')
14
- scripts_more.collect!{ |s| File.expand_path(s) }
15
- scripts_more.uniq!
16
-
17
- scripts_core = glob('facets/*/*.rb')
18
- scripts_core.collect!{ |s| File.expand_path(s) }
19
- scripts_core.uniq!
20
- end
21
-
22
- $VERBOSE = nil
23
-
24
- def require_scripts(scripts)
25
- scripts.each do |file|
26
- begin
27
- require file
28
- rescue Exception => e
29
- puts file
30
- puts e.message
31
- end
32
- end
33
- end
34
-
35
- Benchmark.bm do |x|
36
- x.report("core"){ require_scripts(scripts_core) }
37
- x.report("more"){ require_scripts(scripts_more) }
38
- end
39
-