simplecov 0.8.0.pre2 → 0.18.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +368 -27
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +38 -7
  5. data/ISSUE_TEMPLATE.md +23 -0
  6. data/{MIT-LICENSE → LICENSE} +1 -1
  7. data/README.md +449 -230
  8. data/doc/alternate-formatters.md +61 -0
  9. data/doc/commercial-services.md +20 -0
  10. data/doc/editor-integration.md +18 -0
  11. data/lib/simplecov.rb +294 -59
  12. data/lib/simplecov/combine.rb +30 -0
  13. data/lib/simplecov/combine/branches_combiner.rb +32 -0
  14. data/lib/simplecov/combine/files_combiner.rb +25 -0
  15. data/lib/simplecov/combine/lines_combiner.rb +43 -0
  16. data/lib/simplecov/combine/results_combiner.rb +60 -0
  17. data/lib/simplecov/command_guesser.rb +46 -40
  18. data/lib/simplecov/configuration.rb +346 -221
  19. data/lib/simplecov/defaults.rb +35 -75
  20. data/lib/simplecov/exit_codes.rb +9 -4
  21. data/lib/simplecov/file_list.rb +80 -36
  22. data/lib/simplecov/filter.rb +51 -3
  23. data/lib/simplecov/formatter.rb +4 -2
  24. data/lib/simplecov/formatter/multi_formatter.rb +28 -19
  25. data/lib/simplecov/formatter/simple_formatter.rb +21 -15
  26. data/lib/simplecov/last_run.rb +21 -13
  27. data/lib/simplecov/lines_classifier.rb +48 -0
  28. data/lib/simplecov/load_global_config.rb +8 -0
  29. data/lib/simplecov/no_defaults.rb +4 -2
  30. data/lib/simplecov/profiles.rb +29 -23
  31. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  32. data/lib/simplecov/profiles/hidden_filter.rb +5 -0
  33. data/lib/simplecov/profiles/rails.rb +18 -0
  34. data/lib/simplecov/profiles/root_filter.rb +10 -0
  35. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  36. data/lib/simplecov/result.rb +39 -68
  37. data/lib/simplecov/result_adapter.rb +30 -0
  38. data/lib/simplecov/result_merger.rb +110 -60
  39. data/lib/simplecov/simulate_coverage.rb +29 -0
  40. data/lib/simplecov/source_file.rb +261 -135
  41. data/lib/simplecov/source_file/branch.rb +106 -0
  42. data/lib/simplecov/source_file/line.rb +72 -0
  43. data/lib/simplecov/useless_results_remover.rb +16 -0
  44. data/lib/simplecov/version.rb +4 -2
  45. metadata +48 -197
  46. data/.gitignore +0 -32
  47. data/.travis.yml +0 -28
  48. data/.yardopts +0 -1
  49. data/Appraisals +0 -8
  50. data/Gemfile +0 -16
  51. data/Rakefile +0 -32
  52. data/cucumber.yml +0 -13
  53. data/features/config_autoload.feature +0 -46
  54. data/features/config_command_name.feature +0 -45
  55. data/features/config_coverage_dir.feature +0 -33
  56. data/features/config_deactivate_merging.feature +0 -42
  57. data/features/config_formatters.feature +0 -52
  58. data/features/config_merge_timeout.feature +0 -39
  59. data/features/config_nocov_token.feature +0 -79
  60. data/features/config_profiles.feature +0 -44
  61. data/features/config_project_name.feature +0 -27
  62. data/features/config_styles.feature +0 -121
  63. data/features/cucumber_basic.feature +0 -29
  64. data/features/maximum_coverage_drop.feature +0 -36
  65. data/features/merging_test_unit_and_rspec.feature +0 -44
  66. data/features/minimum_coverage.feature +0 -59
  67. data/features/refuse_coverage_drop.feature +0 -35
  68. data/features/rspec_basic.feature +0 -31
  69. data/features/rspec_fails_on_initialization.feature +0 -14
  70. data/features/rspec_groups_and_filters_basic.feature +0 -29
  71. data/features/rspec_groups_and_filters_complex.feature +0 -35
  72. data/features/rspec_groups_using_filter_class.feature +0 -40
  73. data/features/rspec_without_simplecov.feature +0 -20
  74. data/features/skipping_code_blocks_manually.feature +0 -70
  75. data/features/step_definitions/html_steps.rb +0 -45
  76. data/features/step_definitions/simplecov_steps.rb +0 -66
  77. data/features/step_definitions/transformers.rb +0 -13
  78. data/features/step_definitions/web_steps.rb +0 -64
  79. data/features/support/env.rb +0 -44
  80. data/features/test_unit_basic.feature +0 -34
  81. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  82. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  83. data/features/test_unit_groups_using_filter_class.feature +0 -40
  84. data/features/test_unit_without_simplecov.feature +0 -20
  85. data/features/unicode_compatiblity.feature +0 -67
  86. data/gemfiles/multi_json_legacy.gemfile +0 -12
  87. data/gemfiles/multi_json_new.gemfile +0 -12
  88. data/lib/simplecov/jruby16_fix.rb +0 -43
  89. data/lib/simplecov/json.rb +0 -27
  90. data/lib/simplecov/merge_helpers.rb +0 -39
  91. data/lib/simplecov/railtie.rb +0 -7
  92. data/lib/simplecov/railties/tasks.rake +0 -11
  93. data/simplecov.gemspec +0 -30
  94. data/test/faked_project/Gemfile +0 -6
  95. data/test/faked_project/Rakefile +0 -8
  96. data/test/faked_project/cucumber.yml +0 -13
  97. data/test/faked_project/features/step_definitions/my_steps.rb +0 -23
  98. data/test/faked_project/features/support/env.rb +0 -12
  99. data/test/faked_project/features/test_stuff.feature +0 -6
  100. data/test/faked_project/lib/faked_project.rb +0 -11
  101. data/test/faked_project/lib/faked_project/framework_specific.rb +0 -18
  102. data/test/faked_project/lib/faked_project/meta_magic.rb +0 -24
  103. data/test/faked_project/lib/faked_project/some_class.rb +0 -29
  104. data/test/faked_project/spec/faked_spec.rb +0 -11
  105. data/test/faked_project/spec/meta_magic_spec.rb +0 -10
  106. data/test/faked_project/spec/some_class_spec.rb +0 -10
  107. data/test/faked_project/spec/spec_helper.rb +0 -15
  108. data/test/faked_project/test/faked_test.rb +0 -11
  109. data/test/faked_project/test/meta_magic_test.rb +0 -13
  110. data/test/faked_project/test/some_class_test.rb +0 -15
  111. data/test/faked_project/test/test_helper.rb +0 -16
  112. data/test/fixtures/app/controllers/sample_controller.rb +0 -10
  113. data/test/fixtures/app/models/user.rb +0 -10
  114. data/test/fixtures/deleted_source_sample.rb +0 -15
  115. data/test/fixtures/frameworks/rspec_bad.rb +0 -9
  116. data/test/fixtures/frameworks/rspec_good.rb +0 -9
  117. data/test/fixtures/frameworks/testunit_bad.rb +0 -9
  118. data/test/fixtures/frameworks/testunit_good.rb +0 -9
  119. data/test/fixtures/iso-8859.rb +0 -3
  120. data/test/fixtures/resultset1.rb +0 -4
  121. data/test/fixtures/resultset2.rb +0 -5
  122. data/test/fixtures/sample.rb +0 -16
  123. data/test/fixtures/utf-8.rb +0 -3
  124. data/test/helper.rb +0 -34
  125. data/test/shoulda_macros.rb +0 -19
  126. data/test/test_1_8_fallbacks.rb +0 -31
  127. data/test/test_command_guesser.rb +0 -19
  128. data/test/test_deleted_source.rb +0 -14
  129. data/test/test_file_list.rb +0 -22
  130. data/test/test_filters.rb +0 -78
  131. data/test/test_merge_helpers.rb +0 -105
  132. data/test/test_result.rb +0 -160
  133. data/test/test_return_codes.rb +0 -37
  134. data/test/test_source_file.rb +0 -106
  135. data/test/test_source_file_line.rb +0 -106
@@ -1,12 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- # We're injecting simplecov_config via aruba in cucumber here
4
- # depending on what the test case is...
5
- begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
8
- $stderr.puts "No SimpleCov config file found!"
9
- end
10
-
11
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../../lib'))
12
- require 'faked_project'
@@ -1,6 +0,0 @@
1
- Feature: Foo
2
-
3
- Scenario: Test stuff
4
- Given I want to keep stuff simple
5
- When I write my cukes for the fake project
6
- Then I make all neccessary tests in a single step
@@ -1,11 +0,0 @@
1
- class FakedProject
2
- def self.foo
3
- "bar"
4
- end
5
- end
6
-
7
- Dir[File.join(File.dirname(__FILE__), 'faked_project/*.rb')].each do |file|
8
- require file # Require all source files in project dynamically so we can inject some stuff depending on test situation
9
- end
10
-
11
- FakedProject.send :include, MetaMagic
@@ -1,18 +0,0 @@
1
- # A pile of methods that only get tested in their frameworks
2
- # and thus make this file only 100% covered when all framework test
3
- # results are merged
4
- module FrameworkSpecific
5
- class << self
6
- def cucumber
7
- "Only tested in Cucumber"
8
- end
9
-
10
- def rspec
11
- "Only tested in RSpec"
12
- end
13
-
14
- def test_unit
15
- "Only tested in Test/Unit"
16
- end
17
- end
18
- end
@@ -1,24 +0,0 @@
1
- module MetaMagic
2
- module ClassMethods
3
- def a_class_method
4
- "this is a mixed-in class method"
5
- end
6
- end
7
-
8
- module InstanceMethods
9
- def an_instance_method
10
- "this is a mixed-in instance method"
11
- end
12
- end
13
-
14
- def self.included(base)
15
- base.send :extend, ClassMethods
16
- base.send :include, InstanceMethods
17
-
18
- base.class_eval do
19
- define_method :dynamic do
20
- "A dynamically defined instance method"
21
- end
22
- end
23
- end
24
- end
@@ -1,29 +0,0 @@
1
- class SomeClass
2
- attr_reader :label
3
- attr_accessor :some_attr
4
-
5
- def initialize(label)
6
- @label = label
7
- end
8
-
9
- def reverse
10
- label.reverse
11
- end
12
-
13
- def compare_with(item)
14
- if item == label
15
- return true
16
- else
17
- raise "Item does not match label"
18
- end
19
-
20
- rescue => err
21
- false
22
- end
23
-
24
- private
25
-
26
- def uncovered
27
- "private method"
28
- end
29
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FakedProject do
4
- it "should return proper foo" do
5
- FakedProject.foo.should == 'bar'
6
- end
7
-
8
- it "should test it's framework specific method" do
9
- FrameworkSpecific.rspec.should == "Only tested in RSpec"
10
- end
11
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FakedProject do
4
- it "should have added a class method to FakedProject" do
5
- FakedProject.a_class_method.should == "this is a mixed-in class method"
6
- end
7
-
8
- its(:an_instance_method) { should == "this is a mixed-in instance method" }
9
- its(:dynamic) { should == "A dynamically defined instance method" }
10
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe SomeClass do
4
- subject { SomeClass.new("foo") }
5
-
6
- its(:reverse) { should == 'oof' }
7
- it "should compare with 'foo'" do
8
- subject.compare_with('foo').should be_true
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- # We're injecting simplecov_config via aruba in cucumber here
4
- # depending on what the test case is...
5
- begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
8
- $stderr.puts "No SimpleCov config file found!"
9
- end
10
-
11
- require 'faked_project'
12
-
13
- RSpec.configure do |config|
14
- # some (optional) config here
15
- end
@@ -1,11 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FakedTest < Test::Unit::TestCase
4
- def test_something
5
- assert_equal 'bar', FakedProject.foo
6
- end
7
-
8
- def test_framework_specific
9
- assert_equal "Only tested in Test/Unit", FrameworkSpecific.test_unit
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MetaMagicTest < Test::Unit::TestCase
4
- def test_class_methods
5
- assert_equal "this is a mixed-in class method", FakedProject.a_class_method
6
- end
7
-
8
- def test_instance_methods
9
- p = FakedProject.new
10
- assert_equal "this is a mixed-in instance method", p.an_instance_method
11
- assert_equal "A dynamically defined instance method", p.dynamic
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SomeClassTest < Test::Unit::TestCase
4
- def setup
5
- @instance = SomeClass.new("foo")
6
- end
7
-
8
- def test_reverse
9
- assert_equal 'oof', @instance.reverse
10
- end
11
-
12
- def test_comparison
13
- assert @instance.compare_with('foo')
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- # We're injecting simplecov_config via aruba in cucumber here
4
- # depending on what the test case is...
5
- begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
8
- $stderr.puts "No SimpleCov config file found!"
9
- end
10
-
11
- require 'faked_project'
12
-
13
- require 'test/unit'
14
-
15
- class Test::Unit::TestCase
16
- end
@@ -1,10 +0,0 @@
1
- # Foo class
2
- class Foo
3
- def initialize
4
- @foo = 'baz'
5
- end
6
-
7
- def bar
8
- @foo
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # Foo class
2
- class Foo
3
- def initialize
4
- @foo = 'baz'
5
- end
6
-
7
- def bar
8
- @foo
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
2
- require 'lib/simplecov'
3
- SimpleCov.start { command_name "Test" }
4
-
5
- dir = File.expand_path(File.dirname(__FILE__))
6
- file = File.join(dir, "generated_buddha.rb")
7
- code = %{
8
- def kill_the_buddha(z)
9
- z**z
10
- end
11
- }
12
- File.open(file, "w") { |f| f.print code }
13
- load file
14
- File.unlink file
15
- raise unless kill_the_buddha(3) == 27
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- require 'rspec'
4
- SimpleCov.start
5
- describe 'exit status' do
6
- it "should exit with a non-zero exit status when assertion fails" do
7
- 1.should == 2
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- require 'rspec'
4
- SimpleCov.start
5
- describe 'exit status' do
6
- it "should exit with a zero exit status when assertion fails" do
7
- 1.should == 1
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- SimpleCov.start
4
- require 'test/unit'
5
- class FooTest < Test::Unit::TestCase
6
- def test_foo
7
- assert false
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- SimpleCov.start
4
- require 'test/unit'
5
- class FooTest < Test::Unit::TestCase
6
- def test_foo
7
- assert true
8
- end
9
- end
@@ -1,3 +0,0 @@
1
-
2
- # localized to Espa�ol thus:
3
-
@@ -1,4 +0,0 @@
1
- puts "foo"
2
- puts "foo"
3
- puts "foo"
4
- puts "foo"
@@ -1,5 +0,0 @@
1
-
2
- class Resultset
3
- VERSION = 2
4
- end
5
-
@@ -1,16 +0,0 @@
1
- # Foo class
2
- class Foo
3
- def initialize
4
- @foo = 'baz'
5
- end
6
-
7
- def bar
8
- @foo
9
- end
10
-
11
- #:nocov:
12
- def skipped
13
- @foo * 2
14
- end
15
- #:nocov:
16
- end
@@ -1,3 +0,0 @@
1
- # encoding: utf-8
2
-
3
- puts '135°C'
@@ -1,34 +0,0 @@
1
- require 'bundler/setup'
2
- require 'simplecov'
3
- require 'test/unit'
4
- require 'shoulda'
5
-
6
- SimpleCov.coverage_dir('tmp/coverage')
7
-
8
- class Test::Unit::TestCase
9
- def source_fixture(filename)
10
- File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
11
- end
12
-
13
- # Keep 1.8-rubies from complaining about missing tests in each file that covers only 1.9 functionality
14
- def default_test
15
- end
16
- end
17
-
18
- require 'shoulda_macros'
19
- Test::Unit::TestCase.send :extend, ShouldaMacros
20
-
21
- # Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
22
- require "stringio"
23
-
24
- def capture_stderr
25
- # The output stream must be an IO-like object. In this case we capture it in
26
- # an in-memory IO object so we can return the string value. You can assign any
27
- # IO object here.
28
- previous_stderr, $stderr = $stderr, StringIO.new
29
- yield
30
- $stderr.string
31
- ensure
32
- # Restore the previous value of stderr (typically equal to STDERR).
33
- $stderr = previous_stderr
34
- end
@@ -1,19 +0,0 @@
1
- module ShouldaMacros
2
- def should_be(boolean_flag)
3
- should "be #{boolean_flag}" do
4
- assert_equal true, subject.send(boolean_flag)
5
- end
6
- end
7
-
8
- def should_not_be(boolean_flag)
9
- should "not be #{boolean_flag}" do
10
- assert_equal false, subject.send(boolean_flag)
11
- end
12
- end
13
-
14
- def should_have(attr_name, expectation)
15
- should "have #{attr_name} == #{expectation.inspect}" do
16
- assert_equal expectation, subject.send(attr_name)
17
- end
18
- end
19
- end
@@ -1,31 +0,0 @@
1
- require 'helper'
2
-
3
- # Tests that verify that on 1.8 versions of ruby, simplecov simply
4
- # does not launch and does not cause errors on the way
5
- #
6
- # TODO: This should be expanded upon all methods that could potentially
7
- # be called in a test/spec-helper simplecov config block
8
- #
9
- class Test18FallBacks < Test::Unit::TestCase
10
- should "return false when calling SimpleCov.start" do
11
- assert_equal false, SimpleCov.start
12
- end
13
-
14
- should "return false when calling SimpleCov.start with a block" do
15
- assert_equal false, SimpleCov.start { raise "Shouldn't reach this!?" }
16
- end
17
-
18
- should "return false when calling SimpleCov.configure with a block" do
19
- assert_equal false, SimpleCov.configure { raise "Shouldn't reach this!?" }
20
- end
21
-
22
- should "allow to define a profile" do
23
- begin
24
- SimpleCov.profiles.define 'testprofile' do
25
- add_filter '/config/'
26
- end
27
- rescue => err
28
- assert false, "Profile definition should have been fine, but raised #{err}"
29
- end
30
- end
31
- end if RUBY_VERSION.start_with? '1.8'
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- class TestCommandGuesser < Test::Unit::TestCase
4
- def self.should_guess_command_name(expectation, *argv)
5
- argv.each do |args|
6
- should "return '#{expectation}' for '#{args}'" do
7
- SimpleCov::CommandGuesser.original_run_command = args
8
- assert_equal expectation, SimpleCov::CommandGuesser.guess
9
- end
10
- end
11
- end
12
-
13
- should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb', 'test/{models,helpers,unit}/**/*_test.rb'
14
- should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb', 'test/{controllers,mailers,functional}/**/*_test.rb'
15
- should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb', 'test/integration/**/*_test.rb'
16
- should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
17
- should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
18
- should_guess_command_name "Unit Tests", 'some_arbitrary_command with arguments' # Because Test::Unit const is defined!
19
- end if SimpleCov.usable?