bashcov 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -3
- data/Gemfile +2 -0
- data/Guardfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +60 -5
- data/Rakefile +2 -0
- data/bashcov.gemspec +4 -3
- data/bin/bashcov +3 -2
- data/lib/bashcov/bash_info.rb +32 -0
- data/lib/bashcov/errors.rb +16 -0
- data/lib/bashcov/field_stream.rb +77 -0
- data/lib/bashcov/lexer.rb +13 -7
- data/lib/bashcov/line.rb +4 -2
- data/lib/bashcov/runner.rb +96 -21
- data/lib/bashcov/version.rb +4 -1
- data/lib/bashcov/xtrace.rb +150 -35
- data/lib/bashcov.rb +64 -31
- metadata +9 -58
- data/.gitignore +0 -19
- data/.rspec +0 -4
- data/.rubocop.yml +0 -27
- data/.travis.yml +0 -21
- data/spec/bashcov/lexer_spec.rb +0 -11
- data/spec/bashcov/runner_spec.rb +0 -98
- data/spec/bashcov_spec.rb +0 -82
- data/spec/spec_helper.rb +0 -25
- data/spec/support/common.rb +0 -7
- data/spec/support/test_app.rb +0 -35
- data/spec/test_app/.simplecov +0 -2
- data/spec/test_app/README.md +0 -1
- data/spec/test_app/never_called.sh +0 -4
- data/spec/test_app/scripts/README.md +0 -1
- data/spec/test_app/scripts/case.sh +0 -15
- data/spec/test_app/scripts/delete.sh +0 -9
- data/spec/test_app/scripts/executable +0 -4
- data/spec/test_app/scripts/exit_non_zero.sh +0 -3
- data/spec/test_app/scripts/function.sh +0 -20
- data/spec/test_app/scripts/long_line.sh +0 -7
- data/spec/test_app/scripts/multiline.sh +0 -24
- data/spec/test_app/scripts/nested/simple.sh +0 -13
- data/spec/test_app/scripts/one_liner.sh +0 -9
- data/spec/test_app/scripts/simple.sh +0 -13
- data/spec/test_app/scripts/source.sh +0 -6
- data/spec/test_app/scripts/sourced.txt +0 -4
- data/spec/test_app/scripts/unicode.sh +0 -4
- data/spec/test_app/test_suite.sh +0 -5
data/spec/bashcov_spec.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
shared_examples "a fatal error" do
|
4
|
-
it "outputs to stderr" do
|
5
|
-
expect($stderr).to receive(:write).at_least(:once)
|
6
|
-
ignore_exception(SystemExit) { subject }
|
7
|
-
end
|
8
|
-
|
9
|
-
it "exits with non-zero" do
|
10
|
-
expect { subject }.to raise_error { |error|
|
11
|
-
expect(error).to be_a SystemExit
|
12
|
-
expect(error.status).not_to eq(0)
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe Bashcov do
|
18
|
-
it "preserves the exit status" do
|
19
|
-
system("./bin/bashcov ./spec/test_app/scripts/exit_non_zero.sh")
|
20
|
-
expect($?.exitstatus).not_to eq(0)
|
21
|
-
end
|
22
|
-
|
23
|
-
describe ".parse_options!" do
|
24
|
-
before { @args = [] }
|
25
|
-
|
26
|
-
subject { Bashcov.parse_options! @args }
|
27
|
-
|
28
|
-
context "without any options" do
|
29
|
-
it_behaves_like "a fatal error"
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with a filename" do
|
33
|
-
before { @args << "script.sh" }
|
34
|
-
|
35
|
-
context "with the --skip-uncovered flag" do
|
36
|
-
before { @args << "--skip-uncovered" }
|
37
|
-
|
38
|
-
it "sets it properly" do
|
39
|
-
subject
|
40
|
-
expect(Bashcov.options.skip_uncovered).to be true
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with the --mute flag" do
|
45
|
-
before { @args << "--mute" }
|
46
|
-
|
47
|
-
it "sets it properly" do
|
48
|
-
subject
|
49
|
-
expect(Bashcov.options.mute).to be true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "with the --help flag" do
|
54
|
-
before { @args << "--help" }
|
55
|
-
|
56
|
-
it_behaves_like "a fatal error"
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with the --version flag" do
|
60
|
-
before { @args << "--version" }
|
61
|
-
|
62
|
-
it "outputs to stdout" do
|
63
|
-
expect($stdout).to receive(:write).at_least(:once)
|
64
|
-
ignore_exception(SystemExit) { subject }
|
65
|
-
end
|
66
|
-
|
67
|
-
it "exits with zero" do
|
68
|
-
expect { subject }.to raise_error { |error|
|
69
|
-
expect(error).to be_a SystemExit
|
70
|
-
expect(error.status).to eq(0)
|
71
|
-
}
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe ".name" do
|
78
|
-
it "includes the version" do
|
79
|
-
expect(Bashcov.name).to include Bashcov::VERSION
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
unless RUBY_ENGINE == "rbx" # coverage support is broken on rbx
|
2
|
-
require "simplecov"
|
3
|
-
require "coveralls"
|
4
|
-
|
5
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
-
SimpleCov::Formatter::HTMLFormatter,
|
7
|
-
Coveralls::SimpleCov::Formatter
|
8
|
-
]
|
9
|
-
SimpleCov.start do
|
10
|
-
minimum_coverage 100
|
11
|
-
add_group "Sources", "lib"
|
12
|
-
add_group "Tests", "spec"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
require "bashcov"
|
17
|
-
|
18
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |file| require file }
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
config.before(:each) do
|
22
|
-
Bashcov.set_default_options!
|
23
|
-
Bashcov.options.mute = true # don't print testsuite output
|
24
|
-
end
|
25
|
-
end
|
data/spec/support/common.rb
DELETED
data/spec/support/test_app.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
def test_app
|
2
|
-
File.expand_path("../../test_app", __FILE__)
|
3
|
-
end
|
4
|
-
|
5
|
-
def test_suite
|
6
|
-
"#{test_app}/test_suite.sh"
|
7
|
-
end
|
8
|
-
|
9
|
-
def uncovered_files
|
10
|
-
["#{test_app}/never_called.sh"]
|
11
|
-
end
|
12
|
-
|
13
|
-
def expected_coverage
|
14
|
-
{
|
15
|
-
"#{test_app}/never_called.sh" => [nil, nil, 0],
|
16
|
-
"#{test_app}/scripts/case.sh" => [nil, nil, nil, 6, 1, nil, 0, 0, 1, nil, nil, nil, 1, 1],
|
17
|
-
"#{test_app}/scripts/delete.sh" => [nil, nil, 1, nil, 0, 0, nil, 1, 1],
|
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
|
-
"#{test_app}/scripts/long_line.sh" => [nil, nil, 1, 1, 1, 0],
|
20
|
-
"#{test_app}/scripts/nested/simple.sh" => [nil, nil, nil, nil, 1, 1, nil, 0, nil, nil, 1],
|
21
|
-
"#{test_app}/scripts/one_liner.sh" => [nil, nil, 2, nil, 1, nil, 0],
|
22
|
-
"#{test_app}/scripts/simple.sh" => [nil, nil, nil, nil, 1, 1, nil, 0, nil, nil, 1],
|
23
|
-
"#{test_app}/scripts/source.sh" => [nil, nil, 1, nil, 2],
|
24
|
-
"#{test_app}/scripts/sourced.txt" => [nil, nil, 1],
|
25
|
-
"#{test_app}/scripts/unicode.sh" => [nil, nil, nil, 1],
|
26
|
-
"#{test_app}/scripts/multiline.sh" => [nil, nil, nil, 1, nil, 0, nil, 1, nil, 1, nil, 0, nil, nil, 1, 2, 1, 1, 0, nil, nil, 0, 1, 2],
|
27
|
-
"#{test_app}/scripts/executable" => [nil, nil, 1],
|
28
|
-
"#{test_app}/scripts/exit_non_zero.sh" => [nil, nil, 1],
|
29
|
-
"#{test_app}/test_suite.sh" => [nil, nil, 2, nil, 1],
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def correct_coverage
|
34
|
-
expected_coverage.merge!("#{test_app}/scripts/multiline.sh" => [nil, nil, 1, 2, 1, 1, 0, nil, nil, 1, 1, 1])
|
35
|
-
end
|
data/spec/test_app/.simplecov
DELETED
data/spec/test_app/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
I'm just a README, I shouldn't interfere with anything.
|
@@ -1 +0,0 @@
|
|
1
|
-
I'm just a README, I shouldn't interfere with anything.
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
if
|
4
|
-
[[ false = true ]]
|
5
|
-
then
|
6
|
-
echo 1
|
7
|
-
elif
|
8
|
-
[[ 2 ]]
|
9
|
-
then
|
10
|
-
echo 2
|
11
|
-
else
|
12
|
-
echo 3
|
13
|
-
fi
|
14
|
-
|
15
|
-
[ false = true ] || \
|
16
|
-
[[ 42 -eq 1337 ]] || [[ 1 -eq 1 ]] \
|
17
|
-
&& true && \
|
18
|
-
echo 'what?' || \
|
19
|
-
echo 'no!'
|
20
|
-
|
21
|
-
variable=($(
|
22
|
-
echo hi
|
23
|
-
))
|
24
|
-
echo after
|