I am writing a custom rake task for rcov. The intent is top produce
three variants of a test, each using slightly different options. This
is the basic code:
R_RCOV_AGGREG_FILE = ''coverage.data''
# Use single quotes here so that regexp argument is not munged.
R_RCOV_EXCLUDE_DIR = ''lib\/ruby,lib64\/ruby''
R_RCOV_OUTPUT_DIR = ''test_coverage''
R_RCOV_AGGREG_OPTS = "--aggregate #{R_RCOV_AGGREG_FILE} " +
"--text-summary --no-html "
R_RCOV_BASIC_OPTS = [ " --rails ", " --exclude
#{R_RCOV_EXCLUDE_DIR} " ]
R_RCOV_FINAL_OPTS = " --aggregate #{R_RCOV_AGGREG_FILE} "
R_RCOV_BROWSER = ''firefox''
# make the output directory an array.
r_rcov_dir = R_RCOV_OUTPUT_DIR.scan(/\w+/)
[ ''single'', ''aggregate'',
''final'' ].each do |reptype|
# Set the rcov options variables according to report type
r_rcov_opta = nil if reptype == ''single''
r_rcov_opta = R_RCOV_AGGREG_OPTS if reptype ==
''aggregate''
r_rcov_opta = R_RCOV_FINAL_OPTS if reptype == ''final''
# builds task int_testunit_X
Rcov::RcovTask.new("int_testunit_#{reptype}") do |t|
t.test_files = FileList[''test/**/test*.rb'']
t.libs << "test"
t.output_dir = r_rcov_dir
t.rcov_opts = R_RCOV_BASIC_OPTS
t.rcov_opts << r_rcov_opta
puts "testunit #{reptype} opts: #{R_RCOV_BASIC_OPTS} size " +
"#{R_RCOV_BASIC_OPTS.size}"
puts " "
puts "testunit #{reptype} opta: #{r_rcov_opta}"
puts " "
puts "testunit #{reptype} options: #{t.rcov_opts}"
puts " "
t.verbose = true
end
end
The problem is this. Somewhere the constant value R_RCOV_BASIC_OPTS is
being changed. A rake run using puts and displaying
R_RCOV_BASIC_OPTS.size gives this output:
testunit single opts: --rails --exclude lib\/ruby,lib64\/ruby size
5
testunit single opta:
testunit single options: --rails --exclude lib\/ruby,lib64\/ruby
testunit aggregate opts: --rails --exclude lib\/ruby,lib64\/ruby
--aggregate coverage.data --text-summary --no-html --aggregate
coverage.data --text-summary --no-html --aggregate coverage.data
--text-summary --no-html size 8
testunit aggregate opta: --aggregate coverage.data --text-summary
--no-html
testunit aggregate options: --rails --exclude lib\/ruby,lib64\/ruby
--aggregate coverage.data --text-summary --no-html --aggregate
coverage.data --text-summary --no-html --aggregate coverage.data
--text-summary --no-html
testunit final opts: --rails --exclude lib\/ruby,lib64\/ruby
--aggregate coverage.data --text-summary --no-html --aggregate
coverage.data --text-summary --no-html --aggregate coverage.data
--text-summary --no-html --aggregate coverage.data --aggregate
coverage.data --aggregate coverage.data size 11
testunit final opta: --aggregate coverage.data
testunit final options: --rails --exclude lib\/ruby,lib64\/ruby
--aggregate coverage.data --text-summary --no-html --aggregate
coverage.data --text-summary --no-html --aggregate coverage.data
--text-summary --no-html --aggregate coverage.data --aggregate
coverage.data --aggregate coverage.data
Checking my rake task lists only these places where R_RCOV_BASIC_OPTS is
referenced:
22 R_RCOV_BASIC_OPTS = [ " --rails ", " --exclude
#{R_RCOV_EXCLUDE_DIR} " ]
57 t.rcov_opts = R_RCOV_BASIC_OPTS
68 t.rcov_opts = R_RCOV_BASIC_OPTS
77 t.rcov_opts = R_RCOV_BASIC_OPTS
79 puts "testunit #{reptype} opts: #{R_RCOV_BASIC_OPTS} size
" +
80 "#{R_RCOV_BASIC_OPTS.size}"
Where and How is this constant getting its value changed? The evidence
indicates that the array R_RCOV_BASIC_OPTS has the contents of rcov_opta
appended each time that the factory method is called but I cannot see
where or how this is happening.
On a related note. I find that Rdebug does not support watch points, so
that I cannot trace where in the rake program the constant is changing.
Is there an alternative debugger for Ruby that does so?
--
Posted via http://www.ruby-forum.com/.