rscm-accurev 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,6 +6,8 @@ require 'rake/rdoctask'
6
6
  require 'rake/packagetask'
7
7
  require 'rake/gempackagetask'
8
8
  require 'tracer'
9
+ $: << "lib"
10
+ require 'test/rake/coveragetask'
9
11
 
10
12
  # this rakefile originally borrowed shamelessly from rscm
11
13
 
@@ -164,7 +166,8 @@ else
164
166
  s.version = PKG_VERSION
165
167
  s.summary = PKG_SUMMARY
166
168
  s.description = "RSCM::Accurev is an RSCM API for the SCM tool Accurev (http://www.accurev.com/)."
167
- s.add_dependency( 'rscm', '>= 0.3.0' )
169
+ # rscm-accurev <= 0.0.8 are incompatible with rscm 0.4.x
170
+ s.add_dependency( 'rscm', '~> 0.3' )
168
171
  s.files = PKG_FILES.to_a
169
172
  s.require_path = 'lib'
170
173
  s.autorequire = 'rscm/accurev'
@@ -188,21 +191,11 @@ task :realclean do
188
191
  rm_rf f
189
192
  end
190
193
 
191
- desc "Coverage! (still a big hack)"
192
- task :coverage => [ :test_coverage, :coverage_summary ]
193
-
194
- Rake::TestTask.new( :test_coverage ) do |t|
194
+ desc "Coverage! (still a hack)"
195
+ Rake::Coverage::Task.new( :coverage ) do |t|
195
196
  t.libs << "test"
196
197
  t.test_files = test_files
197
198
  t.verbose = true
198
- def t.rake_loader
199
- 'test/coverage/c_loader.rb'
200
- end
201
- end
202
-
203
- task :coverage_summary do
204
- # too many options!@
205
- ruby "test/coverage/analyzer.rb xxx.trace html/coverage test/coverage/template.html test/coverage/index_tmpl.html"
206
199
  end
207
200
 
208
201
  desc "Perform various prerelease verifications"
@@ -212,8 +205,10 @@ task :verify do
212
205
  if FileTest.directory?(path)
213
206
  next
214
207
  end
208
+ next if path =~ /^\.\/\.svn\// # ignore SVN base/control files
215
209
  next if path =~ /^.\/tmp\/cleaner.pl$/
216
- next if path =~ /^.\/Rakefile$/
210
+ next if path =~ /^.\/Rakefile$/ # this Rakefile contains the bad terms
211
+ next if path =~ /~$/ # backups might, who cares
217
212
  if File.read(path) =~ /orbitz|duncllc|gfast|fduncan/i
218
213
  fail "Cannot release #{path}, please clean up"
219
214
  end
data/STATUS CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  == Core RSCM API (RSCM::Accurev::API)
7
7
 
8
+ Written against RSCM version 0.3.x
9
+
8
10
  [checkout()] supported
9
11
 
10
12
  - basic checkouts work, with pop and with workspace stream
data/TODO CHANGED
@@ -1,5 +1,10 @@
1
1
  # todo for rscm/scm/accurev.rb
2
2
 
3
+ **** api - update to rscm 4.0 api
4
+ - numerous changes required
5
+
6
+ ** api - submit to rscm maintainers as stable(ish)
7
+
3
8
  #api - checkout
4
9
  # - there is no rscm-api update() (only checkout-to-existing-ws)
5
10
  # - `pop`, `update`
@@ -39,3 +44,22 @@ api - update: elements list should probably not include removed files
39
44
  # user *really* wants it
40
45
  # - yeargh... how does update work with pop? just nuke and/or overwrite?
41
46
 
47
+ * XXXs in api
48
+
49
+ * api.add() -> api.ac_add()
50
+ - `ac add` (does keep)
51
+
52
+ api.ac_keep() - as cli
53
+
54
+ api.ac_promote() - as cli
55
+
56
+ api.ac_update
57
+ - doesn't seem to do right
58
+
59
+ api.can_update?()
60
+ - `ac stat -n`
61
+
62
+ ? api.overlapped()
63
+ - list overlapped files
64
+
65
+
@@ -13,6 +13,6 @@ module RSCM
13
13
  # See RSCM::Accurev::API.
14
14
  #
15
15
  module Accurev
16
- VERSION = '0.0.7'
16
+ VERSION = '0.0.8'
17
17
  end
18
18
  end
@@ -48,25 +48,24 @@ module RSCM::Accurev
48
48
  # api.checkout() each{|f| ... }
49
49
  #
50
50
  class API < RSCM::Base
51
- register self
52
51
 
53
- ann :description => "Accurev Depot"
52
+ #ann :description => "Accurev Depot"
54
53
  attr_accessor :depot
55
54
 
56
- ann :description => "Backing Stream (autodetected)"
55
+ #ann :description => "Backing Stream (autodetected)"
57
56
  attr_accessor :backing_stream
58
57
 
59
58
  # If workspace stream is nil (the default), checkout/update will be
60
59
  # done using `accurev pop`. This is faster and more appropriate for
61
60
  # read-only use; however a workspace is required for commits.
62
- ann :description => "Workspace Stream"
61
+ #ann :description => "Workspace Stream"
63
62
  attr_accessor :workspace_stream
64
63
 
65
64
  # [defined in Base]
66
- # ann :description => "Filesystem Path to Workspace"
65
+ # #ann :description => "Filesystem Path to Workspace"
67
66
  # attr_accessor :checkout_dir
68
67
 
69
- ann :description => "Overwrite Mode: if true, co overwrites existing"
68
+ #ann :description => "Overwrite Mode: if true, co overwrites existing"
70
69
  attr_accessor :overwrite
71
70
 
72
71
  def initialize(checkout_dir=nil, backing_stream=nil, workspace_stream=nil)
@@ -172,11 +171,11 @@ module RSCM::Accurev
172
171
 
173
172
  # yeilds the TransactionData objects for the given time period
174
173
  # (promotes only)
175
- def ac_hist( from, to=Time.infinite )
174
+ def ac_hist( from, to=Time.infinity )
176
175
  cmd = Command.instance
177
176
  lower = from.to_accurev
178
177
  upper = "now"
179
- unless to == Time.infinite
178
+ unless to == Time.infinity
180
179
  upper = to.to_accurev
181
180
  end
182
181
  with_working_dir( self.co_filepath ) do
@@ -267,7 +266,12 @@ module RSCM::Accurev
267
266
  # Current, ac_update returns both files and directories, including
268
267
  # deleted files.
269
268
  #
270
- def checkout( to_identifier=Time.infinite )
269
+ # @yield: +path+ for each file/directory updated
270
+ # See also #update().
271
+ #
272
+ # XXX doesn't yield
273
+ #
274
+ def checkout( to_identifier=Time.infinity )
271
275
  co = RSCM::PathConverter.nativepath_to_filepath( @checkout_dir )
272
276
  if @backing_stream.nil?
273
277
  self.attempt_init_from_info()
@@ -277,25 +281,29 @@ module RSCM::Accurev
277
281
  else
278
282
  unless File.exists?( co )
279
283
  # create new workspace
280
- self.checkout_workspace()
284
+ self.create_workspace()
281
285
  end
282
286
  # update workspace
283
- self.update( to_identifier )
287
+ ret = []
288
+ self.update( to_identifier ).each do |e|
289
+ ret << e
290
+ yield e if block_given?
291
+ end
284
292
  end
285
293
  end
286
294
 
287
295
  def checkout_pop()
288
296
  co = RSCM::PathConverter.nativepath_to_filepath( @checkout_dir )
289
- raise "A backing stream is required" if @backing_stream.nil?
290
- raise "A working stream may not be given" unless @working_stream.nil?
297
+ raise AccurevException.new("A backing stream is required") if @backing_stream.nil?
298
+ raise AccurevException.new("A working stream may not be given") unless @workspace_stream.nil?
291
299
  # for `accurev pop`: remove and re-pop the checkout copy
292
300
  if File.exists?( co )
293
301
  unless @overwrite
294
- raise "Checkout dir #{co} already exists (@overwrite=#@overwrite)"
302
+ raise AccurevException.new("Checkout dir #{co} already exists (@overwrite=#@overwrite)")
295
303
  end
296
304
  rm_rf( co )
297
305
  end
298
- mkdir(co)
306
+ Dir.mkdir(co) unless File.exists?(co)
299
307
  with_working_dir( co ) do
300
308
  cmd = Command.instance
301
309
  pop_out = cmd.accurev_nofx("pop",
@@ -315,12 +323,12 @@ module RSCM::Accurev
315
323
  end
316
324
  end
317
325
 
318
- def checkout_workspace()
326
+ def create_workspace()
319
327
  co = RSCM::PathConverter.nativepath_to_filepath( @checkout_dir )
320
- raise "A backing stream is required" if @backing_stream.nil?
321
- raise "A workspace is required" if @working_stream.nil?
328
+ raise AccurevException.new("A backing stream is required") if @backing_stream.nil?
329
+ raise AccurevException.new("A workspace is required") if @workspace_stream.nil?
322
330
  if File.exist?( co ) and !@overwrite
323
- raise "Checkout dir #{co} already exists (@overwrite=#@overwrite)"
331
+ raise AccurevException.new("Checkout dir #{co} already exists (@overwrite=#@overwrite)")
324
332
  end
325
333
  cmd = Command.instance
326
334
  mkws_out = cmd.accurev_nofx( "mkws",
@@ -336,7 +344,7 @@ module RSCM::Accurev
336
344
  #
337
345
  # Updates an existing workspace stream checked out to @checkout_dir
338
346
  #
339
- def update( to_identifier=Time.infinite )
347
+ def update( to_identifier=Time.infinity )
340
348
  co = RSCM::PathConverter.nativepath_to_filepath( @checkout_dir )
341
349
  unless File.exists?( co )
342
350
  raise AccurevException.new( "Workspace does not exist!" )
@@ -409,9 +417,11 @@ module RSCM::Accurev
409
417
  end
410
418
 
411
419
  # Takes a status flags line (eg, "(modified)(kept)")
412
- # and returns a list of status flags.
420
+ # and returns a list of status flags (eg, ["modified", "kept"]).
413
421
  def map_status( status_line )
414
- l = status_line.split( " " ).map {|x| x.trim}
422
+ s = status_line.split( /\W/ ).delete_if do |x|
423
+ x.nil? or x.length==0
424
+ end
415
425
  end
416
426
 
417
427
  end
@@ -12,13 +12,17 @@
12
12
  #
13
13
  module RSCM
14
14
  module Accurev
15
+
16
+ # XXX - i'm using StandardError as the base class, rather than
17
+ # Exception, because test::unit only catches that.
18
+ # i'd like to have a better reason...
15
19
 
16
20
  #
17
21
  # General exception class for errors processing commands.
18
22
  #
19
23
  # @attr error_msg Error message output by accurev.
20
24
  #
21
- class AccurevException < Exception
25
+ class AccurevException < StandardError
22
26
  attr_reader :error_msg
23
27
  def initialize( msg, error_msg=nil )
24
28
  super( "#{msg}: #{error_msg}" )
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/ruby
2
+ require 'erb'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ module Rake
7
+ module Coverage
8
+
9
+ class Summarizer
10
+ attr_accessor :trace_log, :output_dir, :index_template, :page_template
11
+
12
+ def initialize( trace_log, output_dir, index_template, page_template )
13
+ @trace_log = trace_log
14
+ @output_dir = output_dir
15
+ @index_template = index_template
16
+ @page_template = page_template
17
+ end
18
+
19
+ def summarize()
20
+ raise "@trace_log must be set" if @trace_log.nil?
21
+ raise "@output_dir must be set" if @output_dir.nil?
22
+
23
+ # stdout.printf("#%d:%s:%d:%s:%s: %s",
24
+ # get_thread_no,
25
+ # file,
26
+ # line,
27
+ # klass || '',
28
+ # EVENT_SYMBOL[event],
29
+ # get_line(file, line))
30
+
31
+ puts "Reading trace data #{@trace_log}..."
32
+ files = {}
33
+ File.open( @trace_log, "r" ).each_line do |line|
34
+ data, linedump = line.split(/ /)
35
+ threadno, file, n, classname, eventsym = data.split(/:/)
36
+ files[file] ||= []
37
+ files[file][n.to_i] ||= 0
38
+ files[file][n.to_i] += 1
39
+ end
40
+
41
+ page_tmpl = File.read( @page_template )
42
+ index_tmpl = File.read( @index_template )
43
+
44
+ puts "Outputting to #{@output_dir}..."
45
+ mkdir_p( @output_dir )
46
+ summary = {}
47
+ files.each do |file, linelist|
48
+ s = Summary.new( file )
49
+ lineno = 0
50
+ File.open( file ).each_line do |line|
51
+ lineno += 1
52
+ seen_this = false
53
+ # basic: line was traced
54
+ unless linelist[lineno].nil?
55
+ seen_this = true
56
+ end
57
+ # misc: various comments, blank lines, other "untraceables"
58
+ # mark them as seen
59
+ if line =~ /^\s*$/
60
+ seen_this = true
61
+ end
62
+ if line =~ /^\s*#/
63
+ seen_this = true
64
+ end
65
+ if line =~ /^\s*(require|class|module|end|else|include|def)/
66
+ seen_this = true
67
+ end
68
+ if line =~ /^\s*(attr_)/
69
+ seen_this = true
70
+ end
71
+ if line =~ /^\s*(private|protected|public)*\s$/
72
+ seen_this = true
73
+ end
74
+ s.seen << seen_this
75
+ if seen_this
76
+ s.covered_lines += 1
77
+ end
78
+ s.total_lines +=1
79
+ s.lines << line
80
+ end
81
+ summary[file] = s
82
+ raise "XXX" if s.nil?
83
+ pretty( page_tmpl, summary[file] )
84
+ end
85
+ index( index_tmpl, summary )
86
+ end
87
+
88
+ private # --------------------------------------------------------
89
+
90
+ def pretty( page_tmpl, s )
91
+ htmlfile = "#{@output_dir}/#{s.htmlfile}"
92
+ puts htmlfile
93
+ File.open( htmlfile, "w" ) do |out|
94
+ rhtml = ERB.new( page_tmpl )
95
+ out.print( rhtml.result( s.get_binding ) )
96
+ end
97
+ end
98
+
99
+ def index( index_tmpl, summaries )
100
+ idx = IndexSummary.new
101
+ idx.summary = summaries
102
+ puts "#{@output_dir}/index.html"
103
+ File.open( "#{@output_dir}/index.html", "w" ) do |out|
104
+ rhtml = ERB.new( index_tmpl )
105
+ out.print( rhtml.result( idx.get_binding ) )
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ # data objects for erb binding -----------------------------------
112
+
113
+ class Summary
114
+ attr_accessor :filename, :total_lines, :covered_lines
115
+ attr_accessor :lines, :seen
116
+ def initialize( filename )
117
+ @filename = filename
118
+ @total_lines = 0
119
+ @covered_lines = 0
120
+ @lines = []
121
+ @seen = []
122
+ end
123
+ def pct
124
+ @covered_lines.to_f / @total_lines.to_f
125
+ end
126
+ def htmlfile
127
+ @filename.gsub(/[\.\/]/, '_') + ".html"
128
+ end
129
+ def get_binding
130
+ binding
131
+ end
132
+ end
133
+
134
+ class IndexSummary
135
+ attr_accessor :summary
136
+ def get_binding
137
+ binding
138
+ end
139
+ end
140
+
141
+ end
142
+ end
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'test/rake/coverage_summary'
6
+
7
+ module Rake
8
+ module Coverage
9
+
10
+ class Task < TestTask
11
+
12
+ @@loader = "test/rake/coverage_loader.rb"
13
+
14
+ attr_accessor :trace_log
15
+
16
+ # set @name to "test_$name"
17
+ # will define two tasks, and a $name task depending on both of those
18
+ def initialize( name=:coverage )
19
+ @name = "#{name}__testtask".intern
20
+ @real_name = name
21
+ @summary_name = "#{name}__summarytask".intern
22
+ @trace_log = "xxx.trace"
23
+ @output_dir = "html/coverage"
24
+ # super.initialize() calls define()
25
+ super( @name )
26
+ end
27
+
28
+ # create tasks defined by this task object
29
+ # called from constructor
30
+ def define
31
+ task @real_name => [ @name, @summary_name ]
32
+ super # the testing task with trace logging turned on
33
+ desc "Generate coverage summary report"
34
+ task @summary_name do
35
+ s = Rake::Coverage::Summarizer.new(
36
+ @trace_log, @output_dir,
37
+ self.summary_index_template, self.summary_page_template )
38
+ s.summarize()
39
+ end
40
+ return self
41
+ end
42
+
43
+ # mod of testtask.rb's find_file:
44
+ # - fails if resource not found
45
+ # - takes descr of resource for fail message
46
+ # - does not append ".rb" to resource name
47
+ def find_file_or_die( resource, desc=nil ) # :nodoc:
48
+ desc="resource" if desc.nil?
49
+ $LOAD_PATH.each do |path|
50
+ file_path = File.join( path, resource )
51
+ return file_path if File.exist?( file_path )
52
+ end
53
+ fail "unable to find #{desc} (#{resource}) in load path"
54
+ end
55
+
56
+ # XXX loader assumes output to xxx.trace
57
+ # XXX should have the loader print to a pipe object in here,
58
+ # which can be stream-processed by Summarizer
59
+ def rake_loader # :nodoc:
60
+ find_file_or_die( @@loader, "coverage test loader" )
61
+ end
62
+
63
+ def summary_page_template # :nodoc:
64
+ find_file_or_die( "test/rake/page_template.html", "summary page template" )
65
+ end
66
+
67
+ def summary_index_template # :nodoc:
68
+ find_file_or_die( "test/rake/index_template.html", "summary index template" )
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+ end
75
+
@@ -26,8 +26,9 @@
26
26
  <td>Covered</td>
27
27
  <td>% Covered</td>
28
28
  </tr>
29
-
30
- <% summary.each do |filename,s| %>
29
+
30
+ <% summary.keys.sort.each do |filename| %>
31
+ <% s = summary[filename] %>
31
32
  <tr>
32
33
  <td><a href="<%= s.htmlfile %>"><%= filename %></a></td>
33
34
  <td><%= s.total_lines %></td>
@@ -9,14 +9,25 @@ include RSCM::Accurev
9
9
 
10
10
  class AccurevAPITest < Test::Unit::TestCase
11
11
 
12
+ @@tmpdir_count = 0
13
+
14
+ def setup
15
+ @pwd = FileUtils.pwd
16
+ @acreplay = "#@pwd/test/acreplay.rb"
17
+ # give each fixture a distinct tmpdir to use
18
+ @tmpdir = "#{Dir.tmpdir}/#{$$}-#{@@tmpdir_count}.test"
19
+ @@tmpdir_count += 1
20
+ end
21
+
12
22
  #def test_deduce_backing_workspace_streams()
13
23
  # flunk( "XXX implement me" )
14
24
  #end
15
25
 
16
26
  def test_ac_hist()
17
27
  Command.instance do |cmd|
18
- cmd.accurev_bin = "./acreplay.rb eg/hist-oneweek-promotes.xml"
28
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/hist-oneweek-promotes.xml"
19
29
  end
30
+ # no backing/ws streams given: update-only workspace
20
31
  api = API.new( "test" )
21
32
  # test array returns
22
33
  txns = api.ac_hist( Time.utc(1980) ) # bound don't matter for this test
@@ -35,9 +46,9 @@ class AccurevAPITest < Test::Unit::TestCase
35
46
 
36
47
  def test_ac_files()
37
48
  Command.instance do |cmd|
38
- cmd.accurev_bin = "./acreplay.rb eg/ac-files.xml"
49
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/ac-files.xml"
39
50
  end
40
- api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
51
+ api = API.new( "test", "backing-stream", "workspace-stream" )
41
52
  # test array returns
42
53
  files = api.ac_files( "." )
43
54
  assert( files.length > 0, "Should get some stat-ed files" )
@@ -56,9 +67,9 @@ class AccurevAPITest < Test::Unit::TestCase
56
67
 
57
68
  def test_update_stale()
58
69
  Command.instance do |cmd|
59
- cmd.accurev_bin = "./acreplay.rb eg/update-stale.xml"
70
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/update-stale.xml"
60
71
  end
61
- api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
72
+ api = API.new( "test", "backing-stream", "workspace-stream" )
62
73
  begin
63
74
  u_elements = api.update()
64
75
  flunk( "Simulated update with stale data should throw exception" )
@@ -70,9 +81,9 @@ class AccurevAPITest < Test::Unit::TestCase
70
81
 
71
82
  def test_update_nochanges()
72
83
  Command.instance do |cmd|
73
- cmd.accurev_bin = "./acreplay.rb eg/update-nochanges.xml"
84
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/update-nochanges.xml"
74
85
  end
75
- api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
86
+ api = API.new( "test", "backing-stream", "workspace-stream" )
76
87
  u_elements = api.update()
77
88
  assert_not_nil( u_elements )
78
89
  assert( u_elements.size == 0 )
@@ -80,9 +91,9 @@ class AccurevAPITest < Test::Unit::TestCase
80
91
 
81
92
  def test_update_newwksp()
82
93
  Command.instance do |cmd|
83
- cmd.accurev_bin = "./acreplay.rb eg/update-newwksp.xml"
94
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/update-newwksp.xml"
84
95
  end
85
- api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
96
+ api = API.new( "test", "backing-stream", "workspace-stream" )
86
97
  u_elements = api.update()
87
98
  assert_not_nil( u_elements )
88
99
  assert_equal( 44, u_elements.length )
@@ -102,9 +113,9 @@ class AccurevAPITest < Test::Unit::TestCase
102
113
  # update-updates.xml - update with updated files
103
114
  def test_update_updates()
104
115
  Command.instance do |cmd|
105
- cmd.accurev_bin = "./acreplay.rb eg/update-updates.xml"
116
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/update-updates.xml"
106
117
  end
107
- api = API.new( "test", "test-bogus-depot", "test-bogus-depot-0-impl" )
118
+ api = API.new( "test", "backing-stream", "workspace-stream" )
108
119
  # XXX elements in elements list are just "modified" -
109
120
  # may have been removed!
110
121
  # XXX update() should return only filenames, right? eliminate dirs
@@ -125,9 +136,9 @@ class AccurevAPITest < Test::Unit::TestCase
125
136
 
126
137
  def test_info()
127
138
  Command.instance do |cmd|
128
- cmd.accurev_bin = "./acreplay.rb eg/info.txt"
139
+ cmd.accurev_bin = "#@acreplay #@pwd/test/eg/info.txt"
129
140
  end
130
- api = API.new( "test", "depot", "stream" )
141
+ api = API.new( "test", "backing-stream", "workspace-stream" )
131
142
  info = api.ac_info()
132
143
  assert( info.size == 13 )
133
144
  # some crap
@@ -146,13 +157,13 @@ class AccurevAPITest < Test::Unit::TestCase
146
157
  end
147
158
 
148
159
  def test_pop()
149
- pwd = FileUtils.pwd
150
160
  # want to use a tempdir since checkout_pop does a mkdir
151
- tmpdir = "#{Dir.tmpdir}/#{$$}.test"
152
161
  Command.instance do |cmd|
153
- cmd.accurev_bin = "#{pwd}/test/acreplay.rb #{pwd}/test/eg/ac-pop.txt"
162
+ cmd.accurev_bin = "#@acreplay #{@pwd}/test/eg/ac-pop.txt"
154
163
  end
155
- api = API.new( tmpdir, "depot" )
164
+ # pops, because api obj is constructed with backing stream but
165
+ # no workspace stream
166
+ api = API.new( @tmpdir, "backing-stream" )
156
167
  files = api.checkout_pop()
157
168
  assert_equal( 162, files.size() )
158
169
  files.each do |f|
@@ -160,4 +171,55 @@ class AccurevAPITest < Test::Unit::TestCase
160
171
  end
161
172
  end
162
173
 
174
+ #XXX; commented out tests for not-yet-implemented functionality
175
+ #XXX; def test_pop_bug()
176
+ #XXX; Command.instance do |cmd|
177
+ #XXX; cmd.accurev_bin = "/usr/bin/xyzzy-fool" # won't exist
178
+ #XXX; end
179
+ #XXX; api = API.new( @tmpdir, "backing-stream", "workspace-stream" )
180
+ #XXX; begin
181
+ #XXX; api.checkout_pop()
182
+ #XXX; fail( "checkout_pop should have failed" )
183
+ #XXX; rescue AccurevException => e
184
+ #XXX; assert( (e.error_msg =~ /may not be given/), "Unexpected error: #{$!}" )
185
+ #XXX; end
186
+ #XXX; end
187
+ #XXX;
188
+ #XXX; def test_checkout()
189
+ #XXX; # check that checkout yields modded files XXX
190
+ #XXX; # need mock output for mkws; update
191
+ #XXX; Command.instance do |cmd|
192
+ #XXX; cmd.accurev_bin = "#@acreplay #{@pwd}/test/eg/update-updates.xml"
193
+ #XXX; end
194
+ #XXX; api = API.new( @tmpdir, "backing-stream", "workspace-stream" )
195
+ #XXX; paths = []
196
+ #XXX; api.checkout() do |path|
197
+ #XXX; paths << path
198
+ #XXX; end
199
+ #XXX; assert( paths.length == 251 ) # XXX
200
+ #XXX; end
201
+ #XXX:
202
+ #XXX: # XXX should support checking out an existing workspace (by reparenting?)
203
+ #XXX: # XXX should not create workspace with ac mkws unless ws does not exist
204
+ #XXX: # XXX should recover from name collision in mkws (eg, if ws is deleted)
205
+ #XXX: def test_checkout_workspace()
206
+ #XXX: raise "XXX implement me!"
207
+ #XXX: end
208
+
209
+ def test_name()
210
+ api = API.new( @tmpdir, "depot" )
211
+ name = api.name()
212
+ assert( name == 'Accurev' )
213
+ end
214
+
215
+ def test_transactional_p()
216
+ api = API.new( @tmpdir, "depot" )
217
+ assert( api.transactional? )
218
+ end
219
+
220
+ def test_supports_trigger_p()
221
+ api = API.new( @tmpdir, "depot" )
222
+ assert( ! api.supports_trigger? )
223
+ end
224
+
163
225
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rscm-accurev
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.7
7
- date: 2005-09-06 00:00:00 -05:00
6
+ version: 0.0.8
7
+ date: 2006-01-24 00:00:00 -06:00
8
8
  summary: "RSCM::Accurev - RSCM API for Accurev"
9
9
  require_paths:
10
10
  - lib
@@ -32,7 +32,6 @@ files:
32
32
  - bumprelease.sh
33
33
  - doc
34
34
  - eg
35
- - html
36
35
  - lib
37
36
  - LICENSE
38
37
  - Rakefile
@@ -51,16 +50,19 @@ files:
51
50
  - lib/rscm/scm/accurev/exception.rb
52
51
  - lib/rscm/scm/accurev/filterio.rb
53
52
  - lib/rscm/scm/accurev/xml.rb
53
+ - lib/test/rake
54
54
  - lib/test/unit
55
+ - lib/test/rake/coverage_loader.rb
56
+ - lib/test/rake/coverage_summary.rb
57
+ - lib/test/rake/coveragetask.rb
58
+ - lib/test/rake/index_template.html
59
+ - lib/test/rake/page_template.html
55
60
  - lib/test/unit/ui
56
61
  - lib/test/unit/ui/xml
57
62
  - lib/test/unit/ui/xml/testrunner.rb
58
63
  - lib/test/unit/ui/xml/xmltestrunner.xslt
59
64
  - test/acreplay.rb
60
- - test/coverage
61
65
  - test/eg
62
- - test/fl
63
- - test/suite_all.rb
64
66
  - test/t_api.rb
65
67
  - test/t_command.rb
66
68
  - test/t_filterio.rb
@@ -68,13 +70,6 @@ files:
68
70
  - test/t_rscm.rb
69
71
  - test/t_scrubio.rb
70
72
  - test/t_xmlmapper.rb
71
- - test/coverage/analyzer.rb
72
- - test/coverage/c_loader.rb
73
- - test/coverage/cover.rb
74
- - test/coverage/coverage_loader.rb
75
- - test/coverage/coveragetask.rb
76
- - test/coverage/index_tmpl.html
77
- - test/coverage/template.html
78
73
  - test/eg/ac-files.xml
79
74
  - test/eg/ac-pop.txt
80
75
  - test/eg/files-various-states.xml
@@ -108,7 +103,7 @@ dependencies:
108
103
  version_requirements: !ruby/object:Gem::Version::Requirement
109
104
  requirements:
110
105
  -
111
- - ">="
106
+ - "~>"
112
107
  - !ruby/object:Gem::Version
113
- version: 0.3.0
108
+ version: "0.3"
114
109
  version:
@@ -1,127 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'erb'
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- #
7
- # usage:
8
- # rake coverage
9
- #
10
- #
11
-
12
- trace_file = ARGV.shift
13
- output_dir = ARGV.shift
14
- template_file = ARGV.shift
15
- template_index = ARGV.shift
16
-
17
- if trace_file.nil? or output_dir.nil?
18
- raise "Usage: $0 <tracefile> <output_dir> <template> <index_template>"
19
- end
20
-
21
- # stdout.printf("#%d:%s:%d:%s:%s: %s",
22
- # get_thread_no,
23
- # file,
24
- # line,
25
- # klass || '',
26
- # EVENT_SYMBOL[event],
27
- # get_line(file, line))
28
-
29
- puts "Reading trace data #{trace_file}..."
30
- files = {}
31
- File.open( trace_file, "r" ).each_line do |line|
32
- data, linedump = line.split(/ /)
33
- threadno, file, n, classname, eventsym = data.split(/:/)
34
- files[file] ||= []
35
- files[file][n.to_i] ||= 0
36
- files[file][n.to_i] += 1
37
- end
38
-
39
- class Summary
40
- attr_accessor :filename, :total_lines, :covered_lines
41
- attr_accessor :lines, :seen
42
- def initialize( filename )
43
- @filename = filename
44
- @total_lines = 0
45
- @covered_lines = 0
46
- @lines = []
47
- @seen = []
48
- end
49
- def pct
50
- @covered_lines.to_f / @total_lines.to_f
51
- end
52
- def htmlfile
53
- @filename.gsub(/[\.\/]/, '_') + ".html"
54
- end
55
- def get_binding
56
- binding
57
- end
58
- end
59
-
60
- class IndexSummary
61
- attr_accessor :summary
62
- def get_binding
63
- binding
64
- end
65
- end
66
-
67
- def pretty( template, output_dir, s )
68
- htmlfile = "#{output_dir}/#{s.htmlfile}"
69
- puts htmlfile
70
- File.open( htmlfile, "w" ) do |out|
71
- rhtml = ERB.new( template )
72
- out.print( rhtml.result( s.get_binding ) )
73
- end
74
- end
75
-
76
- def index( template, output_dir, summaries )
77
- idx = IndexSummary.new
78
- idx.summary = summaries
79
- puts "#{output_dir}/index.html"
80
- File.open( "#{output_dir}/index.html", "w" ) do |out|
81
- rhtml = ERB.new( template )
82
- out.print( rhtml.result( idx.get_binding ) )
83
- end
84
- end
85
-
86
- template = File.read( template_file )
87
- index_tmpl = File.read( template_index )
88
-
89
- puts "Outputting to #{output_dir}..."
90
- mkdir_p( output_dir )
91
- summary = {}
92
- files.each do |file, linelist|
93
- s = Summary.new( file )
94
- lineno = 0
95
- File.open( file ).each_line do |line|
96
- lineno += 1
97
- seen_this = false
98
- # basic: line was traced
99
- unless linelist[lineno].nil?
100
- seen_this = true
101
- end
102
- # misc: various comments, blank lines, other "untraceables"
103
- # mark them as seen
104
- if line =~ /^\s*$/
105
- seen_this = true
106
- end
107
- if line =~ /^\s*#/
108
- seen_this = true
109
- end
110
- if line =~ /^\s*(require|class|module|end|else|include|def)/
111
- seen_this = true
112
- end
113
- s.seen << seen_this
114
- if seen_this
115
- s.covered_lines += 1
116
- end
117
- s.total_lines +=1
118
- s.lines << line
119
- end
120
- summary[file] = s
121
- pretty( template, output_dir, summary[file] )
122
- end
123
- index( index_tmpl, output_dir, summary )
124
-
125
-
126
-
127
-
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # set_trace_func proc do |event,file,line,id,binding,classname|
4
- # 'c-call' # call into clib - file:line -> caller
5
- # 'c-return' # return out of clib - file:line -> caller
6
- # 'call' # call into ruby fn - file:line -> fn def
7
- # 'class' # start class/mod def (only for dyn classes?)
8
- # 'end' # end class/mod def
9
- # 'line' # exec line
10
- # 'raise' # exception
11
- # 'return' # return from ruby fn - file:line -> returning stmt
12
- # end
13
-
14
- require 'rexml/document'
15
- include REXML
16
-
17
- # defining script_lines make ruby dump all scripts into this hash
18
- SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
19
-
20
-
21
- module Test
22
-
23
- class Cover
24
-
25
- attr_accessor :codebase_files
26
-
27
- def initialize()
28
- @codebase_files = []
29
- # seen_lines is a hash of hashes
30
- @seen_lines = {}
31
- end
32
-
33
- def trace_func( event, file, line, id, binding, classname )
34
- return if event == 'c-call'
35
- return if event == 'c-return'
36
- return if event == 'class'
37
- @seen_lines[file] ||= {}
38
- @seen_lines[file][line] ||= 0
39
- @seen_lines[file][line] += 1
40
- end
41
-
42
- def coverage()
43
- set_trace_func( self.method(:trace_func).to_proc )
44
- yield self
45
- set_trace_func( nil )
46
- end
47
-
48
- def coverage_all()
49
- set_trace_func( self.method(:trace_func).to_proc )
50
- end
51
-
52
- def coverage_clear()
53
- set_trace_func( nil )
54
- end
55
-
56
- def to_xml
57
- doc = Document.new()
58
- doc << XMLDecl.new()
59
- root = Element.new( "coverage" )
60
- doc << root
61
- root.attributes['timestamp'] = Time.now
62
- codebase = Element.new( "codebase" )
63
- root << codebase
64
- @codebase_files.each do |file|
65
- e = Element.new( "file" )
66
- e.attributes['name'] = file
67
- codebase << e
68
- if @seen_lines.has_key?( file )
69
- seen = Element.new( "seen" )
70
- e << seen
71
- linehash = @seen_lines[file]
72
- next unless SCRIPT_LINES__.has_key?( file )
73
- linehash.each do |n,occur|
74
- le = Element.new( "line" )
75
- le.attributes['n'] = n
76
- le.attributes['occur'] = occur
77
- seen << le
78
- end
79
- ce = Element.new( "coverage" )
80
- ce.attributes['seen'] = linehash.size
81
- ce.attributes['total'] = SCRIPT_LINES__[file].size
82
- ce.attributes['pct'] = linehash.size.to_f / SCRIPT_LINES__[file].size.to_f
83
- seen << ce
84
- end
85
- end
86
- return doc
87
- end
88
-
89
- end
90
-
91
- end
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems'
3
- #require 'tracer'
4
- require 'test/cover'
5
-
6
- cover = Test::Cover.new()
7
- cover.coverage_all
8
- cover.codebase_files << "./lib/rscm/accurev.rb"
9
- cover.codebase_files << "./lib/rscm/scm/accurev/command.rb"
10
-
11
- #Tracer.on
12
- ARGV.each do |f|
13
- load f unless f =~ /^-/
14
- end
15
-
16
- END {
17
- cover.coverage_clear
18
- File.open( "xxx.xml", "w" ) do |f|
19
- f.puts( cover.to_xml )
20
- end
21
- }
@@ -1,38 +0,0 @@
1
- #/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'rake'
4
- require 'rake/tasklib'
5
-
6
- module Rake
7
-
8
- class CoverageTask < TaskLib
9
- attr_accessor :name
10
- attr_accessor :libs
11
- attr_accessor :test_files
12
- attr_accessor :ruby_opts
13
-
14
- def initialize( name=:coverage )
15
- @name = name
16
- @libs = ["lib"]
17
- @test_files = nil
18
- @ruby_opts = []
19
- yield self if block_given?
20
- define
21
- end
22
-
23
- def define
24
- lib_path = @libs.join( File::PATH_SEPARATOR )
25
- @ruby_opts.unshift( "-I#{lib_path}" )
26
- task @name do
27
- ruby @ruby_opts.join(" ") +
28
- "test/coverage_loader.rb " +
29
- file_list.collect {|fn| "\"#{fn}\"".join(" ")
30
- end
31
- end
32
-
33
- def test_loader()
34
- find_file( 'test/coverage_loader' ) or fail "I DIE"
35
- end
36
-
37
- end
38
- end
data/test/fl DELETED
@@ -1,18 +0,0 @@
1
- ac-files.xml
2
- ac-pop.txt
3
- files-various-states.xml
4
- hist-oneweek-all.xml
5
- hist-oneweek-external.xml
6
- hist-oneweek-promotes.xml
7
- info.txt
8
- stat-a-various.xml
9
- stat-m.xml
10
- stat-overlap.xml
11
- stat-x.xml
12
- update-i-mods-and-updates-and-overlap.xml
13
- update-i-nochanges.xml
14
- update-i-updates.xml
15
- update-newwksp.xml
16
- update-nochanges.xml
17
- update-stale.xml
18
- update-updates.xml
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'test/unit/ui/console/testrunner'
5
- require 'rubygems'
6
- #require 'coverage'
7
-
8
- class SuiteCrap
9
- def self.suite
10
- suite = Test::Unit::TestSuite.new
11
- Dir.glob( 'test/t_*.rb' ) do |t|
12
- require t
13
- end
14
- ObjectSpace.each_object( Test::Unit::TestCase ) do |k|
15
- puts ">Adding #{k}"
16
- suite << k.suite
17
- end
18
- return suite
19
- end
20
- end
21
-
22
- class SuiteAll
23
- def self.suite
24
- suite = Test::Unit::TestSuite.new
25
- require 'test/t_api.rb'
26
- suite << AccurevAPITest
27
- return suite
28
- end
29
- end
30
-
31
- if $0 == __FILE__
32
- Test::Unit::UI::Console::TestRunner.run( SuiteAll )
33
- end
34
-