Not very active here is it?

106 views
Skip to first unread message

byr...@harte-lyne.ca

unread,
Nov 25, 2013, 5:20:50 PM11/25/13
to simp...@googlegroups.com
I have a problem with using SimpleCov in a cucumber feature which uses in process testing for some code and Aruba for out-of-processing testing for other code. The Aruba tests do not appear to be added to the code coverage reports.

What is the correct way of getting this to work?

Christoph Olszowka

unread,
Nov 26, 2013, 1:33:35 AM11/26/13
to simp...@googlegroups.com
Hi there,

mostly people seem to open up new Github issues for this kind of thing :/

You will need to run SimpleCov inside your spawned Aruba subprocesses so
it can see the code covered there. Probably you will also need to come
up with a way to supply a `SimpleCov.command_name 'Aruba 123'` to the
subprocesses so each individual coverage report has it's own and will be
merged by SimpleCov's resultset merging when building the coverage report.

Cheers,
Christoph

byr...@harte-lyne.ca

unread,
Nov 26, 2013, 9:03:51 AM11/26/13
to simp...@googlegroups.com
On Tuesday, 26 November 2013 01:33:35 UTC-5, Christoph Olszowka wrote:

> You will need to run SimpleCov inside your spawned Aruba subprocesses so
> it can see the code covered there. Probably you will also need to come
> up with a way to supply a `SimpleCov.command_name 'Aruba 123'` to the
> subprocesses so each individual coverage report has it's own and will be
> merged by SimpleCov's resultset merging when building the coverage report.

This is the essence of my problem. I am not clear on what "You will need to run SimpleCov inside your spawned Aruba subprocesses" means from a coding standpoint. Must I include the SimpleCove startup at the top of my production scripts? Where does the invocation go?

We run these ruby programs as batch jobs using a bin/filename stub that looks like this:

#!/usr/bin/env ruby
require 'bundler/setup'
Bundler.require


# Executable for fetching Forex rate changes.
# invoke with: HLL_DB_ENV=production bin/hll_th_forex_rss_fetch
#
# 'Pathname' allows us to eliminate the ../../ construction from
# absolute file paths. It makes reading stack traces a little
# easier.
require 'pathname'
my_dir = Pathname.new(
File.join( File.dirname(
__FILE__ ), '../', 'lib/' ) ).realpath.to_s + '/'

# This loads in the actual program classes and modules for this script
# With Ruby-1.9+ we could use require_relative instead.

require my_dir + File.basename( __FILE__ )

# This invokes the program passing in the argument list from the
# command line.
HllThForexRssFetch::Main.new( ARGV ).execute

Where do I put the SimpleCov invocation? In the bin/file? Before or after the Bundler call? Somewhere else? Do I modify Aruba? Where?

Getting some specific data on this has been like trying to push on a blob of mercury. Every push simply creates more blobs.

byr...@harte-lyne.ca

unread,
Nov 26, 2013, 9:38:29 AM11/26/13
to simp...@googlegroups.com, byr...@harte-lyne.ca

From the advice I have read it seems to me that this is where the SimpleCov references should go but I am unable to hit upon either the correct location or the correct formulation of commands. I have tried this without success:


#!/usr/bin/env ruby
require 'bundler/setup'
Bundler.require

if ENV['ENV'] == 'test'
require 'simplecov'
SimpleCov.start do
add_filter "/features/"
add_filter "/libexec"
add_filter "/lib/hll_active_record/"
add_filter "/test/"
add_filter "/tmp/"
command_name "this script name"
end
end
. . .


But what I get is:

Coverage report generated for this script name to /home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/tmp/aruba/coverage. 0.0 / 0.0 LOC (100.0%) covered.

byr...@harte-lyne.ca

unread,
Nov 26, 2013, 10:18:24 AM11/26/13
to simp...@googlegroups.com, byr...@harte-lyne.ca
On Tuesday, 26 November 2013 09:38:29 UTC-5, byr...@harte-lyne.ca wrote:

>
> Coverage report generated for this script name to /home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/tmp/aruba/coverage. 0.0 / 0.0 LOC (100.0%) covered.

I discovered the problem in the above report: -> /tmp/aruba/coverage.

The root directory for the SimpleCov was incorrect as it was being inferred from the run conditions. Aruba moves things into a tmp directory for testing. I did this to fix the problem:

. . .

require 'pathname'

root_dir = Pathname.new(
File.join( File.dirname(
__FILE__ ), '../' ) ).realpath.to_s + '/'

lib_dir = root_dir + "lib/"

script_name = File.basename( __FILE__ ).to_s

# SimpleCov code coverage reporting


if ENV['ENV'] == 'test'

run_name = script_name + "-" + Time.now.strftime( "%Y%m%d%H%M%S%L" )


require 'simplecov'
SimpleCov.start do
add_filter "/features/"
add_filter "/libexec"
add_filter "/lib/hll_active_record/"
add_filter "/test/"
add_filter "/tmp/"

command_name run_name
root root_dir
end
end


# This loads in the actual program classes and modules for this script
# With Ruby-1.9+ we could use require_relative instead.

require lib_dir + script_name

# This invokes the program passing in the argument list from the
# command line.
HllThForexRssFetch::Main.new( ARGV ).execute


Which now appears to give the desired results.

Reply all
Reply to author
Forward
0 new messages