Bizarr problem with rake


I hope that someone here can identify what is going on as I am
completely frustrated at the moment.

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:


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’

"–text-summary --no-html "

R_RCOV_BASIC_OPTS = [ " --rails ", " --exclude


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"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 " +
  puts " "
  puts "testunit #{reptype}    opta: #{r_rcov_opta}"
  puts " "
  puts "testunit #{reptype} options: #{t.rcov_opts}"
  puts " "
  t.verbose       =  true


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

testunit single opta:

testunit single options: --rails --exclude lib/ruby,lib64/ruby

testunit aggregate opts: --rails --exclude lib/ruby,lib64/ruby
–aggregate --text-summary --no-html --aggregate --text-summary --no-html --aggregate
–text-summary --no-html size 8

testunit aggregate opta: --aggregate --text-summary

testunit aggregate options: --rails --exclude lib/ruby,lib64/ruby
–aggregate --text-summary --no-html --aggregate --text-summary --no-html --aggregate
–text-summary --no-html

testunit final opts: --rails --exclude lib/ruby,lib64/ruby
–aggregate --text-summary --no-html --aggregate --text-summary --no-html --aggregate
–text-summary --no-html --aggregate --aggregate --aggregate size 11

testunit final opta: --aggregate

testunit final options: --rails --exclude lib/ruby,lib64/ruby
–aggregate --text-summary --no-html --aggregate --text-summary --no-html --aggregate
–text-summary --no-html --aggregate --aggregate --aggregate

Checking my rake task lists only these places where R-RCOV_BASIC_OPTS is

22 R_RCOV_BASIC_OPTS = [ " --rails ", " --exclude
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}”

How is constant getting its value changed?