bashcov 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +24 -0
- data/.travis.yml +4 -2
- data/CHANGELOG.md +7 -1
- data/Gemfile +1 -1
- data/Guardfile +2 -3
- data/Rakefile +5 -3
- data/bashcov.gemspec +14 -13
- data/bin/bashcov +3 -4
- data/lib/bashcov/lexer.rb +12 -14
- data/lib/bashcov/runner.rb +9 -10
- data/lib/bashcov/version.rb +2 -2
- data/lib/bashcov/xtrace.rb +5 -4
- data/lib/bashcov.rb +12 -14
- data/spec/bashcov/lexer_spec.rb +4 -5
- data/spec/bashcov/runner_spec.rb +11 -12
- data/spec/bashcov_spec.rb +8 -9
- data/spec/spec_helper.rb +4 -5
- data/spec/support/common.rb +4 -7
- data/spec/support/test_app.rb +2 -5
- data/spec/test_app/test_suite.sh +1 -2
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e4f73a217009bf88f987dba5058c178ae1c9971
|
4
|
+
data.tar.gz: 2877c76c643179f05f0a453df690e11879f273b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77cd74423bb960f8afb99fa4ce7fd36f9c7751ae352dc23f88a1de077a07a9de29fbaa0dae1a5500d673f271c33bc3e10481642dbde24e7e174a3f967cfe14d4
|
7
|
+
data.tar.gz: ea991103cb285f83f74931c5a7ed1c867a72e86e4c6a8f16ec92506017e4053bd9666e4c12e9234d2b24ab5f1c0e43dee3c9d477223378d76299b6b41efc58cd
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Metrics/AbcSize:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Metrics/MethodLength:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 120
|
9
|
+
Exclude: [spec/**/*]
|
10
|
+
|
11
|
+
Style/AccessModifierIndentation:
|
12
|
+
EnforcedStyle: outdent
|
13
|
+
|
14
|
+
Style/AndOr:
|
15
|
+
EnforcedStyle: conditionals
|
16
|
+
|
17
|
+
Style/SignalException:
|
18
|
+
EnforcedStyle: only_raise
|
19
|
+
|
20
|
+
Style/SpecialGlobalVars:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Style/StringLiterals:
|
24
|
+
EnforcedStyle: double_quotes
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
## Unreleased ([changes](https://github.com/infertux/bashcov/compare/v1.
|
1
|
+
## Unreleased ([changes](https://github.com/infertux/bashcov/compare/v1.2.0...master))
|
2
2
|
|
3
3
|
* TBD
|
4
4
|
|
5
|
+
## v1.2.0, 2015-05-04 ([changes](https://github.com/infertux/bashcov/compare/v1.1.0...v1.2.0))
|
6
|
+
|
7
|
+
* [FEATURE] Enforce coherent coding style with Rubocop
|
8
|
+
* [FEATURE] Upgrade dependencies (#11)
|
9
|
+
* [FEATURE] Improve OS X compatibility (#10)
|
10
|
+
|
5
11
|
## v1.1.0, 2015-02-20 ([changes](https://github.com/infertux/bashcov/compare/v1.0.1...v1.1.0))
|
6
12
|
|
7
13
|
* [FEATURE] Upgrade dependencies
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# More info at https://github.com/guard/guard#readme
|
2
2
|
|
3
|
-
guard
|
3
|
+
guard "rspec", cli: "--tag ~speed:slow" do
|
4
4
|
watch(%r{^spec/.+_spec\.rb$})
|
5
5
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
6
6
|
watch(%r{^lib/(.+)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
|
7
|
-
watch(
|
7
|
+
watch("spec/spec_helper.rb") { "spec" }
|
8
8
|
watch(%r{^spec/support/.+\.rb$}) { "spec" }
|
9
9
|
end
|
10
|
-
|
data/Rakefile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
2
|
|
3
|
+
require "rspec/core/rake_task"
|
4
4
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
5
|
-
t.ruby_opts =
|
5
|
+
t.ruby_opts = "-w"
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
RuboCop::RakeTask.new
|
9
10
|
|
11
|
+
task default: [:rubocop, :spec]
|
data/bashcov.gemspec
CHANGED
@@ -1,30 +1,31 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "bashcov/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "bashcov"
|
8
8
|
gem.version = Bashcov::VERSION
|
9
9
|
gem.authors = ["Cédric Félizard"]
|
10
10
|
gem.email = ["cedric@felizard.fr"]
|
11
|
-
gem.description =
|
11
|
+
gem.description = "Code coverage tool for Bash"
|
12
12
|
gem.summary = gem.description
|
13
13
|
gem.homepage = "https://github.com/infertux/bashcov"
|
14
|
-
gem.license =
|
14
|
+
gem.license = "MIT"
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency
|
21
|
+
gem.add_dependency "simplecov", "~> 0.10.0"
|
22
22
|
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency
|
25
|
-
gem.add_development_dependency
|
26
|
-
gem.add_development_dependency
|
27
|
-
gem.add_development_dependency
|
28
|
-
gem.add_development_dependency
|
29
|
-
gem.add_development_dependency
|
23
|
+
gem.add_development_dependency "rake"
|
24
|
+
gem.add_development_dependency "rspec", "~> 3"
|
25
|
+
gem.add_development_dependency "guard-rspec"
|
26
|
+
gem.add_development_dependency "rb-inotify"
|
27
|
+
gem.add_development_dependency "cane"
|
28
|
+
gem.add_development_dependency "rubocop"
|
29
|
+
gem.add_development_dependency "yard"
|
30
|
+
gem.add_development_dependency "coveralls"
|
30
31
|
end
|
data/bin/bashcov
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("../../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
|
-
require
|
6
|
+
require "bashcov"
|
7
7
|
|
8
8
|
Bashcov.parse_options! ARGV
|
9
9
|
|
@@ -11,9 +11,8 @@ runner = Bashcov::Runner.new Bashcov.options.command
|
|
11
11
|
runner.run
|
12
12
|
coverage = runner.result
|
13
13
|
|
14
|
-
require
|
14
|
+
require "simplecov"
|
15
15
|
|
16
16
|
SimpleCov.command_name Bashcov.name
|
17
17
|
SimpleCov.root Bashcov.root_directory
|
18
18
|
SimpleCov::Result.new(coverage).format!
|
19
|
-
|
data/lib/bashcov/lexer.rb
CHANGED
@@ -3,24 +3,22 @@ module Bashcov
|
|
3
3
|
# coverage
|
4
4
|
class Lexer
|
5
5
|
# Lines starting with one of these tokens are irrelevant for coverage
|
6
|
-
IGNORE_START_WITH = %w
|
6
|
+
IGNORE_START_WITH = %w(# function)
|
7
7
|
|
8
8
|
# Lines ending with one of these tokens are irrelevant for coverage
|
9
9
|
IGNORE_END_WITH = %w|(|
|
10
10
|
|
11
11
|
# Lines containing only one of these keywords are irrelevant for coverage
|
12
|
-
IGNORE_IS = %w
|
12
|
+
IGNORE_IS = %w(esac if then else elif fi while do done { } ;;)
|
13
13
|
|
14
14
|
# @param [String] filename File to analyze
|
15
15
|
# @param [Hash] coverage Coverage with executed lines marked
|
16
16
|
# @raise [ArgumentError] if the given +filename+ is invalid.
|
17
|
-
def initialize
|
17
|
+
def initialize(filename, coverage)
|
18
18
|
@filename = File.expand_path(filename)
|
19
19
|
@coverage = coverage
|
20
20
|
|
21
|
-
unless File.file?(@filename)
|
22
|
-
raise ArgumentError, "#{@filename} is not a file"
|
23
|
-
end
|
21
|
+
raise ArgumentError, "#{@filename} is not a file" unless File.file?(@filename)
|
24
22
|
end
|
25
23
|
|
26
24
|
# Yields uncovered relevant lines.
|
@@ -28,24 +26,24 @@ module Bashcov
|
|
28
26
|
# @return [void]
|
29
27
|
def uncovered_relevant_lines
|
30
28
|
lineno = 0
|
31
|
-
File.open(@filename,
|
32
|
-
if @coverage[lineno] == Bashcov::Line::IGNORED
|
29
|
+
File.open(@filename, "rb").each_line do |line|
|
30
|
+
if @coverage[lineno] == Bashcov::Line::IGNORED && revelant?(line)
|
33
31
|
yield lineno
|
34
32
|
end
|
35
|
-
lineno +=1
|
33
|
+
lineno += 1
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
39
37
|
private
|
40
38
|
|
41
|
-
def
|
39
|
+
def revelant?(line)
|
42
40
|
line.strip!
|
43
41
|
|
44
42
|
!line.empty? and
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
!IGNORE_IS.include? line and
|
44
|
+
!line.start_with?(*IGNORE_START_WITH) and
|
45
|
+
!line.end_with?(*IGNORE_END_WITH) and
|
46
|
+
line !~ /\A\w+\(\)/ # function declared without the 'function' keyword
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
data/lib/bashcov/runner.rb
CHANGED
@@ -2,7 +2,7 @@ module Bashcov
|
|
2
2
|
# Runs a given command with xtrace enabled then computes code coverage.
|
3
3
|
class Runner
|
4
4
|
# @param [String] command Command to run
|
5
|
-
def initialize
|
5
|
+
def initialize(command)
|
6
6
|
@command = command
|
7
7
|
end
|
8
8
|
|
@@ -15,8 +15,8 @@ module Bashcov
|
|
15
15
|
@xtrace = Xtrace.new
|
16
16
|
fd = @xtrace.file_descriptor
|
17
17
|
@command = "BASH_XTRACEFD=#{fd} PS4='#{Xtrace::PS4}' #{@command}"
|
18
|
-
options = {:in => :in, fd => fd} # bind fds to the child process
|
19
|
-
options.merge!(
|
18
|
+
options = { :in => :in, fd => fd } # bind fds to the child process
|
19
|
+
options.merge!(out: "/dev/null", err: "/dev/null") if Bashcov.options.mute
|
20
20
|
|
21
21
|
command_pid = Process.spawn @command, options # spawn the command
|
22
22
|
xtrace_thread = Thread.new { @xtrace.read } # start processing the xtrace output
|
@@ -46,8 +46,8 @@ module Bashcov
|
|
46
46
|
# @note +SHELLOPTS+ must be exported so we use Ruby's {ENV} variable
|
47
47
|
# @return [void]
|
48
48
|
def inject_xtrace_flag!
|
49
|
-
existing_flags = (ENV[
|
50
|
-
ENV[
|
49
|
+
existing_flags = (ENV["SHELLOPTS"] || "").split(":")
|
50
|
+
ENV["SHELLOPTS"] = (existing_flags | ["xtrace"]).join(":")
|
51
51
|
end
|
52
52
|
|
53
53
|
# Add files which have not been executed at all (i.e. with no coverage)
|
@@ -63,10 +63,10 @@ module Bashcov
|
|
63
63
|
# @return [void]
|
64
64
|
def expunge_invalid_files!
|
65
65
|
@coverage.each_key do |file|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
next if File.file? file
|
67
|
+
|
68
|
+
@coverage.delete file
|
69
|
+
warn "Warning: #{file} was executed but has been deleted since then - it won't be reported in coverage."
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -82,4 +82,3 @@ module Bashcov
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
data/lib/bashcov/version.rb
CHANGED
data/lib/bashcov/xtrace.rb
CHANGED
@@ -6,17 +6,19 @@ module Bashcov
|
|
6
6
|
# Prefix used for PS4.
|
7
7
|
# @note The first caracter ('+') will be repeated to indicate the nesting
|
8
8
|
# level.
|
9
|
-
PREFIX =
|
9
|
+
PREFIX = "+BASHCOV> "
|
10
10
|
|
11
11
|
# [String] +PS4+ variable used for xtrace output
|
12
12
|
# @see http://www.gnu.org/software/bash/manual/bashref.html#index-PS4
|
13
13
|
# @see http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
|
14
14
|
# @note We use a forward slash as delimiter since it's the only forbidden
|
15
15
|
# character in filenames on Unix and Windows.
|
16
|
-
|
16
|
+
GET_ABS_DIR = "$(cd $(dirname ${BASH_SOURCE[0]}); pwd)"
|
17
|
+
GET_BASE = "$(basename ${BASH_SOURCE[0]})"
|
18
|
+
PS4 = %(#{PREFIX}#{GET_ABS_DIR}/#{GET_BASE}/${LINENO}: )
|
17
19
|
|
18
20
|
# Regexp to match xtrace elements.
|
19
|
-
LINE_REGEXP =
|
21
|
+
LINE_REGEXP = %r{\A#{Regexp.escape(PREFIX[0])}+#{PREFIX[1..-1]}(?<filename>.+)\/(?<lineno>\d+): }
|
20
22
|
|
21
23
|
# @return [Hash] Coverage of executed files
|
22
24
|
attr_reader :coverage
|
@@ -59,4 +61,3 @@ module Bashcov
|
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
62
|
-
|
data/lib/bashcov.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "optparse"
|
2
|
+
require "ostruct"
|
3
|
+
require "bashcov/version"
|
4
|
+
require "bashcov/lexer"
|
5
|
+
require "bashcov/line"
|
6
|
+
require "bashcov/runner"
|
7
|
+
require "bashcov/xtrace"
|
8
8
|
|
9
9
|
# Bashcov default module
|
10
10
|
# @note Keep it short!
|
11
11
|
module Bashcov
|
12
12
|
class << self
|
13
|
-
|
14
13
|
# @return [OpenStruct] Bashcov settings
|
15
14
|
attr_reader :options
|
16
15
|
|
@@ -31,13 +30,13 @@ module Bashcov
|
|
31
30
|
# @param [Array] args list of arguments
|
32
31
|
# @raise [SystemExit] if invalid arguments are given
|
33
32
|
# @return [void]
|
34
|
-
def parse_options!
|
33
|
+
def parse_options!(args)
|
35
34
|
option_parser.parse!(args)
|
36
35
|
|
37
36
|
if args.empty?
|
38
37
|
abort("You must give exactly one command to execute.")
|
39
38
|
else
|
40
|
-
@options.command = args.join(
|
39
|
+
@options.command = args.join(" ")
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -48,8 +47,8 @@ module Bashcov
|
|
48
47
|
|
49
48
|
private
|
50
49
|
|
51
|
-
def help
|
52
|
-
<<-HELP.gsub!(/^ +/,
|
50
|
+
def help(program_name)
|
51
|
+
<<-HELP.gsub!(/^ +/, "").gsub!("\t", " " * 4)
|
53
52
|
Usage: #{program_name} [options] [--] <command> [options]
|
54
53
|
Examples:
|
55
54
|
\t#{program_name} ./script.sh
|
@@ -61,7 +60,7 @@ module Bashcov
|
|
61
60
|
|
62
61
|
def option_parser
|
63
62
|
OptionParser.new do |opts|
|
64
|
-
opts.program_name =
|
63
|
+
opts.program_name = "bashcov"
|
65
64
|
opts.version = Bashcov::VERSION
|
66
65
|
opts.banner = help opts.program_name
|
67
66
|
|
@@ -90,4 +89,3 @@ end
|
|
90
89
|
|
91
90
|
# Make sure default options are set
|
92
91
|
Bashcov.set_default_options!
|
93
|
-
|
data/spec/bashcov/lexer_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Bashcov::Lexer do
|
4
4
|
describe "#initialize" do
|
5
5
|
it "raises if the file is invalid" do
|
6
|
-
expect
|
7
|
-
Bashcov::Lexer.new
|
8
|
-
|
6
|
+
expect do
|
7
|
+
Bashcov::Lexer.new "inexistent_file.exe", nil
|
8
|
+
end.to raise_error ArgumentError
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
data/spec/bashcov/runner_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "benchmark"
|
3
3
|
|
4
4
|
describe Bashcov::Runner do
|
5
|
-
let(:runner) { Bashcov::Runner.new test_suite }
|
5
|
+
let(:runner) { Bashcov::Runner.new "bash #{test_suite}" }
|
6
6
|
|
7
7
|
before :all do
|
8
8
|
Dir.chdir File.dirname(test_suite)
|
@@ -10,17 +10,17 @@ describe Bashcov::Runner do
|
|
10
10
|
|
11
11
|
describe "#run" do
|
12
12
|
it "finds commands in $PATH" do
|
13
|
-
expect(Bashcov::Runner.new(
|
13
|
+
expect(Bashcov::Runner.new("ls -l").run).to be_success
|
14
14
|
end
|
15
15
|
|
16
16
|
it "is fast", speed: :slow do
|
17
17
|
ratio = 0
|
18
18
|
|
19
19
|
3.times do |iteration|
|
20
|
-
t0 = Benchmark.realtime
|
21
|
-
pid = Process.spawn test_suite, out:
|
20
|
+
t0 = Benchmark.realtime do
|
21
|
+
pid = Process.spawn test_suite, out: "/dev/null", err: "/dev/null"
|
22
22
|
Process.wait pid
|
23
|
-
|
23
|
+
end
|
24
24
|
expect($?).to be_success
|
25
25
|
|
26
26
|
run = nil
|
@@ -36,23 +36,23 @@ describe Bashcov::Runner do
|
|
36
36
|
|
37
37
|
context "without a SHELLOPTS variable" do
|
38
38
|
before do
|
39
|
-
ENV[
|
39
|
+
ENV["SHELLOPTS"] = nil
|
40
40
|
end
|
41
41
|
|
42
42
|
it "adds the flags" do
|
43
43
|
runner.run
|
44
|
-
expect(ENV[
|
44
|
+
expect(ENV["SHELLOPTS"]).to eq("xtrace")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with an existing SHELLOPTS variable" do
|
49
49
|
before do
|
50
|
-
ENV[
|
50
|
+
ENV["SHELLOPTS"] = "posix"
|
51
51
|
end
|
52
52
|
|
53
53
|
it "merges the flags" do
|
54
54
|
runner.run
|
55
|
-
expect(ENV[
|
55
|
+
expect(ENV["SHELLOPTS"]).to eq("posix:xtrace")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -96,4 +96,3 @@ describe Bashcov::Runner do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
|
-
|
data/spec/bashcov_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
shared_examples "a fatal error" do
|
4
4
|
it "outputs to stderr" do
|
5
5
|
expect($stderr).to receive(:write).at_least(:once)
|
6
|
-
ignore_exception { subject }
|
6
|
+
ignore_exception(SystemExit) { subject }
|
7
7
|
end
|
8
8
|
|
9
9
|
it "exits with non-zero" do
|
@@ -25,10 +25,10 @@ describe Bashcov do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context "with a filename" do
|
28
|
-
before { @args <<
|
28
|
+
before { @args << "script.sh" }
|
29
29
|
|
30
30
|
context "with the --skip-uncovered flag" do
|
31
|
-
before { @args <<
|
31
|
+
before { @args << "--skip-uncovered" }
|
32
32
|
|
33
33
|
it "sets it properly" do
|
34
34
|
subject
|
@@ -37,7 +37,7 @@ describe Bashcov do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context "with the --mute flag" do
|
40
|
-
before { @args <<
|
40
|
+
before { @args << "--mute" }
|
41
41
|
|
42
42
|
it "sets it properly" do
|
43
43
|
subject
|
@@ -46,17 +46,17 @@ describe Bashcov do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with the --help flag" do
|
49
|
-
before { @args <<
|
49
|
+
before { @args << "--help" }
|
50
50
|
|
51
51
|
it_behaves_like "a fatal error"
|
52
52
|
end
|
53
53
|
|
54
54
|
context "with the --version flag" do
|
55
|
-
before { @args <<
|
55
|
+
before { @args << "--version" }
|
56
56
|
|
57
57
|
it "outputs to stdout" do
|
58
58
|
expect($stdout).to receive(:write).at_least(:once)
|
59
|
-
ignore_exception { subject }
|
59
|
+
ignore_exception(SystemExit) { subject }
|
60
60
|
end
|
61
61
|
|
62
62
|
it "exits with zero" do
|
@@ -75,4 +75,3 @@ describe Bashcov do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
unless RUBY_ENGINE ==
|
2
|
-
require
|
3
|
-
require
|
1
|
+
unless RUBY_ENGINE == "rbx" # coverage support is broken on rbx
|
2
|
+
require "simplecov"
|
3
|
+
require "coveralls"
|
4
4
|
|
5
5
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
6
|
SimpleCov::Formatter::HTMLFormatter,
|
@@ -13,7 +13,7 @@ unless RUBY_ENGINE == 'rbx' # coverage support is broken on rbx
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
require
|
16
|
+
require "bashcov"
|
17
17
|
|
18
18
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |file| require file }
|
19
19
|
|
@@ -23,4 +23,3 @@ RSpec.configure do |config|
|
|
23
23
|
Bashcov.options.mute = true # don't print testsuite output
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
data/spec/support/common.rb
CHANGED
data/spec/support/test_app.rb
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
def expected_coverage
|
14
14
|
{
|
15
15
|
"#{test_app}/never_called.sh" => [nil, nil, 0],
|
16
|
-
"#{test_app}/scripts/case.sh" => [nil, nil, nil,
|
16
|
+
"#{test_app}/scripts/case.sh" => [nil, nil, nil, 6, 1, nil, 0, 0, 1, nil, nil, nil, 1, 1],
|
17
17
|
"#{test_app}/scripts/delete.sh" => [nil, nil, 1, nil, 0, 0, nil, 1, 1],
|
18
18
|
"#{test_app}/scripts/function.sh" => [nil, nil, nil, 2, nil, nil, nil, 1, 1, nil, nil, nil, nil, 1, nil, nil, 1, 1, 1],
|
19
19
|
"#{test_app}/scripts/long_line.sh" => [nil, nil, 1, 1, 1, 0],
|
@@ -30,8 +30,5 @@ def expected_coverage
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def correct_coverage
|
33
|
-
expected_coverage.merge!({
|
34
|
-
"#{test_app}/scripts/multiline.sh" => [nil, nil, 1, 2, 1, 1, 0, nil, nil, 1, 1, 1]
|
35
|
-
})
|
33
|
+
expected_coverage.merge!("#{test_app}/scripts/multiline.sh" => [nil, nil, 1, 2, 1, 1, 0, nil, nil, 1, 1, 1])
|
36
34
|
end
|
37
|
-
|
data/spec/test_app/test_suite.sh
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bashcov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cédric Félizard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: yard
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +146,7 @@ extra_rdoc_files: []
|
|
132
146
|
files:
|
133
147
|
- ".gitignore"
|
134
148
|
- ".rspec"
|
149
|
+
- ".rubocop.yml"
|
135
150
|
- ".travis.yml"
|
136
151
|
- CHANGELOG.md
|
137
152
|
- CONTRIBUTING.md
|
@@ -191,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
206
|
version: '0'
|
192
207
|
requirements: []
|
193
208
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.4.
|
209
|
+
rubygems_version: 2.4.6
|
195
210
|
signing_key:
|
196
211
|
specification_version: 4
|
197
212
|
summary: Code coverage tool for Bash
|