-
-
Notifications
You must be signed in to change notification settings - Fork 21
allow to redefine root directory, merge suites and report to external systems #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,33 @@ coverage = runner.result | |
|
||
require "simplecov" | ||
|
||
SimpleCov.command_name Bashcov.name | ||
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"]) if ENV["COVERAGE_DIR"] | ||
|
||
if ENV["COVERAGE_NAME"] | ||
SimpleCov.command_name ENV["COVERAGE_NAME"] | ||
else | ||
SimpleCov.command_name Bashcov.name | ||
end | ||
|
||
reports = Bashcov.options.reports | ||
unless reports.empty? | ||
formatters = [ | ||
SimpleCov::Formatter::HTMLFormatter | ||
] | ||
reports.each do |r| | ||
require r[:require] | ||
formatters.push(r[:formatter].split("::").inject(Object) { |a, e| a.const_get e }) | ||
end | ||
SimpleCov.formatters = formatters | ||
end | ||
SimpleCov.root Bashcov.root_directory | ||
SimpleCov::Result.new(coverage).format! | ||
|
||
result = SimpleCov::Result.new(coverage) | ||
if SimpleCov.use_merging | ||
SimpleCov::ResultMerger.store_result(result) if result | ||
result = SimpleCov::ResultMerger.merged_result | ||
end | ||
|
||
result.format! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should be able to add that into an |
||
|
||
exit status.exitstatus |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,9 @@ class << self | |
attr_reader :options | ||
|
||
# @return [String] The project's root directory | ||
def root_directory | ||
@root_directory ||= Dir.pwd | ||
def root_directory(root = nil) | ||
return @root_directory if defined?(@root_directory) && root.nil? | ||
@root_directory = root || Dir.pwd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm that seems overly complicated - what about |
||
end | ||
|
||
# Sets default options overriding any existing ones. | ||
|
@@ -24,6 +25,7 @@ def set_default_options! | |
@options ||= OpenStruct.new | ||
@options.skip_uncovered = false | ||
@options.mute = false | ||
@options.reports = [] | ||
end | ||
|
||
# Parses the given CLI arguments and sets +options+. | ||
|
@@ -72,6 +74,13 @@ def option_parser | |
opts.on("-m", "--mute", "Do not print script output") do |m| | ||
@options.mute = m | ||
end | ||
opts.on("-r rep", "--report rep", String, "Report system integration. <require>:<formatter>") do |rep| | ||
sp = rep.split(":", 2) | ||
report = {} | ||
report[:require] = sp[0] | ||
report[:formatter] = sp[1] | ||
@options.reports.push(report) | ||
end | ||
|
||
opts.separator "\nCommon options:" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,21 @@ def read | |
@files[filename] ||= [] | ||
@files[filename][lineno] ||= 0 | ||
@files[filename][lineno] += 1 | ||
line = File.readlines(filename)[lineno] | ||
ishere = line.match("cat.*<<-?\s*[\"']?\(.*\)[\"']?") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use heredoc with something else than |
||
next unless ishere | ||
lineno += 1 | ||
line = File.readlines(filename)[lineno] | ||
until line.nil? || line.match("^\s*#{ishere[1]}") | ||
@files[filename][lineno] ||= 0 | ||
@files[filename][lineno] += 1 | ||
lineno += 1 | ||
line = File.readlines(filename)[lineno] | ||
end | ||
unless line.nil? | ||
@files[filename][lineno] ||= 0 | ||
@files[filename][lineno] += 1 | ||
end | ||
end | ||
|
||
@files | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
cat << EOF | ||
Showing text | ||
EOF | ||
|
||
cat <<- END | ||
Another couple | ||
of lines | ||
- list 1 | ||
- list 2 | ||
END | ||
|
||
cat <<- FINISH | ||
Complex | ||
important | ||
message | ||
FINISH | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to reimplement that in Bashcov. I just tried this and it builds fine on Travis. However it doesn't seem to push coverage results even with your original code. So I must have misconfigured Coveralls somehow. Could you try something along the lines of this in your own repo and see if that works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think #13 (diff) redefine all formatters. That's why for example doesn't work. If it's possible I would like to have both approach. git-ignore needs .simplecov because of use of test suite sharness, but in general people should use bashcov as another bash script. Anyway, I can keep this on my own fork till it's mature. I understand your are reluctant to add this