simplecov 0.6.4 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +378 -12
  3. data/CONTRIBUTING.md +51 -0
  4. data/ISSUE_TEMPLATE.md +23 -0
  5. data/LICENSE +1 -1
  6. data/README.md +456 -252
  7. data/doc/alternate-formatters.md +56 -0
  8. data/doc/commercial-services.md +20 -0
  9. data/doc/editor-integration.md +18 -0
  10. data/lib/simplecov.rb +223 -44
  11. data/lib/simplecov/command_guesser.rb +47 -35
  12. data/lib/simplecov/configuration.rb +281 -191
  13. data/lib/simplecov/defaults.rb +38 -43
  14. data/lib/simplecov/exit_codes.rb +10 -0
  15. data/lib/simplecov/file_list.rb +51 -34
  16. data/lib/simplecov/filter.rb +50 -3
  17. data/lib/simplecov/formatter.rb +4 -1
  18. data/lib/simplecov/formatter/multi_formatter.rb +34 -0
  19. data/lib/simplecov/formatter/simple_formatter.rb +18 -12
  20. data/lib/simplecov/jruby_fix.rb +44 -0
  21. data/lib/simplecov/last_run.rb +26 -0
  22. data/lib/simplecov/lines_classifier.rb +48 -0
  23. data/lib/simplecov/load_global_config.rb +8 -0
  24. data/lib/simplecov/no_defaults.rb +4 -0
  25. data/lib/simplecov/profiles.rb +33 -0
  26. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  27. data/lib/simplecov/profiles/hidden_filter.rb +5 -0
  28. data/lib/simplecov/profiles/rails.rb +18 -0
  29. data/lib/simplecov/profiles/root_filter.rb +10 -0
  30. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  31. data/lib/simplecov/railtie.rb +3 -1
  32. data/lib/simplecov/railties/tasks.rake +9 -7
  33. data/lib/simplecov/raw_coverage.rb +41 -0
  34. data/lib/simplecov/result.rb +17 -55
  35. data/lib/simplecov/result_merger.rb +100 -67
  36. data/lib/simplecov/source_file.rb +82 -67
  37. data/lib/simplecov/version.rb +4 -2
  38. metadata +153 -222
  39. data/.gitignore +0 -31
  40. data/.travis.yml +0 -15
  41. data/Appraisals +0 -8
  42. data/Gemfile +0 -5
  43. data/Rakefile +0 -19
  44. data/cucumber.yml +0 -13
  45. data/features/config_adapters.feature +0 -44
  46. data/features/config_autoload.feature +0 -46
  47. data/features/config_command_name.feature +0 -33
  48. data/features/config_coverage_dir.feature +0 -20
  49. data/features/config_deactivate_merging.feature +0 -42
  50. data/features/config_merge_timeout.feature +0 -39
  51. data/features/config_nocov_token.feature +0 -79
  52. data/features/config_project_name.feature +0 -27
  53. data/features/config_styles.feature +0 -93
  54. data/features/cucumber_basic.feature +0 -29
  55. data/features/merging_test_unit_and_rspec.feature +0 -44
  56. data/features/rspec_basic.feature +0 -31
  57. data/features/rspec_fails_on_initialization.feature +0 -14
  58. data/features/rspec_groups_and_filters_basic.feature +0 -29
  59. data/features/rspec_groups_and_filters_complex.feature +0 -35
  60. data/features/rspec_groups_using_filter_class.feature +0 -40
  61. data/features/rspec_without_simplecov.feature +0 -20
  62. data/features/skipping_code_blocks_manually.feature +0 -70
  63. data/features/step_definitions/html_steps.rb +0 -45
  64. data/features/step_definitions/simplecov_steps.rb +0 -66
  65. data/features/step_definitions/transformers.rb +0 -13
  66. data/features/step_definitions/web_steps.rb +0 -64
  67. data/features/support/env.rb +0 -26
  68. data/features/test_unit_basic.feature +0 -34
  69. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  70. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  71. data/features/test_unit_groups_using_filter_class.feature +0 -40
  72. data/features/test_unit_without_simplecov.feature +0 -20
  73. data/features/unicode_compatiblity.feature +0 -67
  74. data/gemfiles/multi_json-legacy.gemfile +0 -7
  75. data/gemfiles/multi_json-legacy.gemfile.lock +0 -85
  76. data/gemfiles/multi_json-new.gemfile +0 -7
  77. data/gemfiles/multi_json-new.gemfile.lock +0 -85
  78. data/lib/simplecov/adapters.rb +0 -29
  79. data/lib/simplecov/merge_helpers.rb +0 -39
  80. data/simplecov.gemspec +0 -29
  81. data/test/faked_project/Gemfile +0 -6
  82. data/test/faked_project/Rakefile +0 -8
  83. data/test/faked_project/cucumber.yml +0 -13
  84. data/test/faked_project/features/step_definitions/my_steps.rb +0 -23
  85. data/test/faked_project/features/support/env.rb +0 -12
  86. data/test/faked_project/features/test_stuff.feature +0 -6
  87. data/test/faked_project/lib/faked_project.rb +0 -11
  88. data/test/faked_project/lib/faked_project/framework_specific.rb +0 -18
  89. data/test/faked_project/lib/faked_project/meta_magic.rb +0 -24
  90. data/test/faked_project/lib/faked_project/some_class.rb +0 -29
  91. data/test/faked_project/spec/faked_spec.rb +0 -11
  92. data/test/faked_project/spec/meta_magic_spec.rb +0 -10
  93. data/test/faked_project/spec/some_class_spec.rb +0 -10
  94. data/test/faked_project/spec/spec_helper.rb +0 -15
  95. data/test/faked_project/test/faked_test.rb +0 -11
  96. data/test/faked_project/test/meta_magic_test.rb +0 -13
  97. data/test/faked_project/test/some_class_test.rb +0 -15
  98. data/test/faked_project/test/test_helper.rb +0 -16
  99. data/test/fixtures/app/controllers/sample_controller.rb +0 -10
  100. data/test/fixtures/app/models/user.rb +0 -10
  101. data/test/fixtures/deleted_source_sample.rb +0 -15
  102. data/test/fixtures/frameworks/rspec_bad.rb +0 -9
  103. data/test/fixtures/frameworks/rspec_good.rb +0 -9
  104. data/test/fixtures/frameworks/testunit_bad.rb +0 -9
  105. data/test/fixtures/frameworks/testunit_good.rb +0 -9
  106. data/test/fixtures/iso-8859.rb +0 -3
  107. data/test/fixtures/resultset1.rb +0 -4
  108. data/test/fixtures/resultset2.rb +0 -5
  109. data/test/fixtures/sample.rb +0 -16
  110. data/test/fixtures/utf-8.rb +0 -3
  111. data/test/helper.rb +0 -35
  112. data/test/shoulda_macros.rb +0 -29
  113. data/test/test_1_8_fallbacks.rb +0 -33
  114. data/test/test_command_guesser.rb +0 -21
  115. data/test/test_deleted_source.rb +0 -16
  116. data/test/test_file_list.rb +0 -24
  117. data/test/test_filters.rb +0 -80
  118. data/test/test_merge_helpers.rb +0 -107
  119. data/test/test_result.rb +0 -147
  120. data/test/test_return_codes.rb +0 -39
  121. data/test/test_source_file.rb +0 -95
  122. data/test/test_source_file_line.rb +0 -110
data/.gitignore DELETED
@@ -1,31 +0,0 @@
1
- .bundle
2
- Gemfile.lock
3
-
4
- ## MAC OS
5
- .DS_Store
6
- .document
7
-
8
- ## TEXTMATE
9
- *.tmproj
10
- tmtags
11
-
12
- ## EMACS
13
- *~
14
- \#*
15
- .\#*
16
-
17
- ## VIM
18
- *.swp
19
-
20
- ## PROJECT::GENERAL
21
- coverage
22
- rdoc
23
- pkg
24
- tmp
25
- capybara*.html
26
- .rvmrc
27
-
28
- ## PROJECT::SPECIFIC
29
-
30
- .yardoc
31
- doc
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- script:
2
- - bundle
3
- - rake appraisal:install
4
- - rake appraisal
5
- rvm:
6
- - 1.8.7
7
- - 1.9.2
8
- - 1.9.3
9
- - ree
10
- - rbx
11
- - jruby
12
- notifications:
13
- email:
14
- on_success: always
15
- on_failure: always
data/Appraisals DELETED
@@ -1,8 +0,0 @@
1
- # See https://github.com/colszowka/simplecov/issues/132
2
- appraise "multi_json-new" do
3
- gem "multi_json", ">= 1.3.4"
4
- end
5
-
6
- appraise "multi_json-legacy" do
7
- gem "multi_json", "~> 1.0.0"
8
- end
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
- gemspec
3
-
4
- # Uncomment this to use local copy of simplecov-html in development when checked out
5
- # gem 'simplecov-html', :path => File.dirname(__FILE__) + '/../simplecov-html'
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env rake
2
-
3
- require 'rubygems'
4
- require 'bundler/setup'
5
- require 'appraisal'
6
- Bundler::GemHelper.install_tasks
7
-
8
- require 'rake/testtask'
9
- Rake::TestTask.new(:test) do |test|
10
- test.libs << 'lib' << 'test'
11
- test.test_files = FileList['test/test_*.rb']
12
- test.verbose = true
13
- test.warning = true
14
- end
15
-
16
- require 'cucumber/rake/task'
17
- Cucumber::Rake::Task.new
18
-
19
- task :default => [:test, :cucumber]
data/cucumber.yml DELETED
@@ -1,13 +0,0 @@
1
- <%
2
- rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
- rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
- std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
5
- interp_opts = if defined?(RUBY_ENGINE)
6
- " --tags ~@exclude-#{RUBY_ENGINE}"
7
- else
8
- ''
9
- end
10
- %>
11
- default: <%= std_opts %><%= interp_opts %> features
12
- wip: --tags @wip:30 --wip features<%= interp_opts %>
13
- rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip<%= interp_opts %>
@@ -1,44 +0,0 @@
1
- @test_unit @config @adapters
2
- Feature:
3
-
4
- In order to re-use SimpleCov settings across projects,
5
- adapters can be defined that hold configuration settings
6
- that can be loaded at once.
7
-
8
- Background:
9
- Given SimpleCov for Test/Unit is configured with:
10
- """
11
- require 'simplecov'
12
- """
13
-
14
- Scenario: Defining and using a custom adapter
15
- Given a file named ".simplecov" with:
16
- """
17
- SimpleCov.adapters.define 'custom_command' do
18
- command_name "Adapter Command"
19
- end
20
-
21
- SimpleCov.start do
22
- load_adapter 'test_frameworks'
23
- load_adapter 'custom_command'
24
- end
25
- """
26
-
27
- When I open the coverage report generated with `bundle exec rake test`
28
- Then I should see "4 files in total."
29
- And I should see "using Adapter Command" within "#footer"
30
-
31
- Scenario: Using existing adapter in custom adapter and supplying adapter to start command
32
- Given a file named ".simplecov" with:
33
- """
34
- SimpleCov.adapters.define 'my_adapter' do
35
- load_adapter 'test_frameworks'
36
- command_name "My Adapter"
37
- end
38
-
39
- SimpleCov.start 'my_adapter'
40
- """
41
-
42
- When I open the coverage report generated with `bundle exec rake test`
43
- Then I should see "4 files in total."
44
- And I should see "using My Adapter" within "#footer"
@@ -1,46 +0,0 @@
1
- @test_unit @rspec @config
2
- Feature:
3
-
4
- If you have multiple test suites, it can be a bit cumbersome
5
- to keep the configuration across them in sync. SimpleCov
6
- is able to find a config file called '.simplecov' that resides
7
- in your project's root and will automatically use it when
8
- loaded.
9
-
10
- This gives you the ability to configure SimpleCov just once
11
- and then use the same configuration on all test suites simply
12
- by doing a 'require "simplecov"'
13
-
14
- Scenario:
15
- Given a file named ".simplecov" with:
16
- """
17
- SimpleCov.start do
18
- add_filter 'test.rb'
19
- add_filter 'spec.rb'
20
- end
21
- """
22
- Given SimpleCov for Test/Unit is configured with:
23
- """
24
- require 'simplecov'
25
- """
26
- Given SimpleCov for RSpec is configured with:
27
- """
28
- require 'simplecov'
29
- """
30
-
31
- When I successfully run `bundle exec rake test`
32
- And I open the coverage report generated with `bundle exec rspec spec`
33
- Then the report should be based upon:
34
- | RSpec |
35
- | Unit Tests |
36
-
37
- And I should see the groups:
38
- | name | coverage | files |
39
- | All Files | 90.48% | 4 |
40
-
41
- And I should see the source files:
42
- | name | coverage |
43
- | lib/faked_project.rb | 100.0 % |
44
- | lib/faked_project/some_class.rb | 80.0 % |
45
- | lib/faked_project/framework_specific.rb | 87.5 % |
46
- | lib/faked_project/meta_magic.rb | 100.0 % |
@@ -1,33 +0,0 @@
1
- @test_unit @rspec @merging @config
2
- Feature: Custom names for individual test suites
3
-
4
- Each test suite needs a name it can be identified by. SimpleCov tries
5
- best to detect Rails' Unit, Functional, Integration tests as well as regular
6
- Test/Unit, RSpec and Cucumber, but if that is insufficient, each test suite
7
- config can be given a custom command name using SimpleCov.command_name.
8
-
9
- Scenario:
10
- Given SimpleCov for Test/Unit is configured with:
11
- """
12
- require 'simplecov'
13
- SimpleCov.start do
14
- command_name "I'm in UR Unitz"
15
- end
16
- """
17
- Given SimpleCov for RSpec is configured with:
18
- """
19
- require 'simplecov'
20
- SimpleCov.start do
21
- command_name "Dreck macht Speck"
22
- end
23
- """
24
-
25
- When I open the coverage report generated with `bundle exec rake test`
26
- Then the report should be based upon:
27
- | I'm in UR Unitz |
28
-
29
- When I open the coverage report generated with `bundle exec rspec spec`
30
- Then the report should be based upon:
31
- | Dreck macht Speck |
32
- | I'm in UR Unitz |
33
-
@@ -1,20 +0,0 @@
1
- @test_unit @config
2
- Feature:
3
-
4
- The output directory for test coverage can be customized
5
- with the SimpleCov.coverage_dir setting. All coverage reports
6
- will be put there instead of the default 'coverage' directory
7
- in your project's root.
8
-
9
- Scenario:
10
- Given SimpleCov for Test/Unit is configured with:
11
- """
12
- require 'simplecov'
13
- SimpleCov.start do
14
- coverage_dir 'test/simplecov'
15
- end
16
- """
17
-
18
- When I successfully run `bundle exec rake test`
19
- Then a coverage report should have been generated in "test/simplecov"
20
- And a directory named "coverage" should not exist
@@ -1,42 +0,0 @@
1
- @test_unit @rspec @merging @config
2
- Feature:
3
-
4
- If merging of test suite results is not desired, it can be deactivated,
5
- thus leading to the coverage report being overwritten with the latest results
6
- of a single test suite on each run of any suite.
7
-
8
- It's probably preferrable to generate the individual suite results into separate
9
- output directories instead (see SimpleCov.coverage_dir), but it is possible :)
10
-
11
- Scenario:
12
- Given SimpleCov for Test/Unit is configured with:
13
- """
14
- require 'simplecov'
15
- SimpleCov.start do
16
- use_merging false
17
- end
18
- """
19
- Given SimpleCov for RSpec is configured with:
20
- """
21
- require 'simplecov'
22
- SimpleCov.start do
23
- use_merging false
24
- end
25
- """
26
-
27
- When I successfully run `bundle exec rake test`
28
- Then a file named "coverage/index.html" should exist
29
- But a file named "coverage/.resultset.json" should not exist
30
-
31
- Given I open the coverage report
32
- Then the report should be based upon:
33
- | Unit Tests |
34
-
35
- When I successfully run `bundle exec rspec spec`
36
- Then a file named "coverage/index.html" should exist
37
- But a file named "coverage/.resultset.json" should not exist
38
-
39
- Given I open the coverage report
40
- Then the report should be based upon:
41
- | RSpec |
42
-
@@ -1,39 +0,0 @@
1
- @test_unit @rspec @merging @config
2
- Feature:
3
-
4
- The maximum time between resultset merges can be customized
5
- using SimpleCov.merge_timeout SECONDS. This can be helpful for
6
- long-running test-suites that fail to merge because of the time
7
- between individual suite finishes is more then the default timeout
8
- of 10 minutes.
9
-
10
- Here, for the sake of testing the opposite case is shown, choosing
11
- a merge timeout so short that the first test suite's results actually
12
- are out of date when the second suite finishes and thus does not end up
13
- in the report.
14
-
15
- Scenario:
16
- Given SimpleCov for Test/Unit is configured with:
17
- """
18
- require 'simplecov'
19
- SimpleCov.start do
20
- merge_timeout 1
21
- end
22
- """
23
- Given SimpleCov for RSpec is configured with:
24
- """
25
- require 'simplecov'
26
- SimpleCov.start do
27
- merge_timeout 1
28
- end
29
- """
30
-
31
- When I open the coverage report generated with `bundle exec rake test`
32
- Then the report should be based upon:
33
- | Unit Tests |
34
-
35
- When I wait for 2 seconds
36
- And I open the coverage report generated with `bundle exec rspec spec`
37
- Then the report should be based upon:
38
- | RSpec |
39
-
@@ -1,79 +0,0 @@
1
- @test_unit @nocov
2
- Feature:
3
-
4
- Code wrapped in # :nocov: will be ignored by coverage reports.
5
- The name of the token can be configured with SimpleCov.nocov_token or SimpleCov.skip_token
6
-
7
- Scenario: Custom nocov token using nocov_token
8
- Given SimpleCov for Test/Unit is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start 'test_frameworks' do
12
- nocov_token 'skippit'
13
- end
14
- """
15
-
16
- Given a file named "lib/faked_project/nocov.rb" with:
17
- """
18
- class SourceCodeWithNocov
19
- # :skippit:
20
- def some_weird_code
21
- never_reached
22
- rescue => err
23
- but no one cares about invalid ruby here
24
- end
25
- # :skippit:
26
- end
27
- """
28
-
29
- When I open the coverage report generated with `bundle exec rake test`
30
-
31
- Then I should see the source files:
32
- | name | coverage |
33
- | lib/faked_project.rb | 100.0 % |
34
- | lib/faked_project/some_class.rb | 80.0 % |
35
- | lib/faked_project/framework_specific.rb | 75.0 % |
36
- | lib/faked_project/meta_magic.rb | 100.0 % |
37
- | lib/faked_project/nocov.rb | 100.0 % |
38
-
39
- And there should be 5 skipped lines in the source files
40
-
41
- And the report should be based upon:
42
- | Unit Tests |
43
-
44
- Scenario: Custom nocov token using skip_token
45
- Given SimpleCov for Test/Unit is configured with:
46
- """
47
- require 'simplecov'
48
- SimpleCov.start 'test_frameworks' do
49
- skip_token 'skippit'
50
- end
51
- """
52
-
53
- Given a file named "lib/faked_project/nocov.rb" with:
54
- """
55
- class SourceCodeWithNocov
56
- # :skippit:
57
- def some_weird_code
58
- never_reached
59
- rescue => err
60
- but no one cares about invalid ruby here
61
- end
62
- # :skippit:
63
- end
64
- """
65
-
66
- When I open the coverage report generated with `bundle exec rake test`
67
-
68
- Then I should see the source files:
69
- | name | coverage |
70
- | lib/faked_project.rb | 100.0 % |
71
- | lib/faked_project/some_class.rb | 80.0 % |
72
- | lib/faked_project/framework_specific.rb | 75.0 % |
73
- | lib/faked_project/meta_magic.rb | 100.0 % |
74
- | lib/faked_project/nocov.rb | 100.0 % |
75
-
76
- And there should be 5 skipped lines in the source files
77
-
78
- And the report should be based upon:
79
- | Unit Tests |
@@ -1,27 +0,0 @@
1
- @test_unit @config
2
- Feature:
3
-
4
- SimpleCov guesses the project name from the project root dir's name.
5
- If this is not sufficient for you, you can specify a custom name using
6
- SimpleCov.project_name('xyz')
7
-
8
-
9
- Scenario: Guessed name
10
- Given SimpleCov for Test/Unit is configured with:
11
- """
12
- require 'simplecov'
13
- SimpleCov.start
14
- """
15
-
16
- When I open the coverage report generated with `bundle exec rake test`
17
- Then I should see "Code coverage for Project"
18
-
19
- Scenario: Custom name
20
- Given SimpleCov for Test/Unit is configured with:
21
- """
22
- require 'simplecov'
23
- SimpleCov.start { project_name "Superfancy 2.0" }
24
- """
25
-
26
- When I open the coverage report generated with `bundle exec rake test`
27
- Then I should see "Code coverage for Superfancy 2.0"