File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 22# frozen_string_literal: true
33
44SimpleCov . start do
5- SimpleCov . formatter = SimpleCov ::Formatter ::SimpleFormatter if ENV [ 'SILENT_SIMPLECOV' ]
5+ SimpleCov . formatter = SimpleCov ::Formatter ::SimpleFormatter unless ENV [ 'CI' ] || ENV [ 'COVERAGE_REPORT' ] == 'true'
66 SimpleCov . command_name "Task##{ $PROCESS_ID} "
77 SimpleCov . merge_timeout 20
88 add_group 'Core' , %w[ lib/pagy.rb lib/pagy/countless.rb lib/pagy/backend.rb lib/pagy/frontend.rb lib/pagy/exceptions.rb ]
Original file line number Diff line number Diff line change 44require 'bundler/setup'
55require 'bundler/gem_tasks'
66require 'rake/testtask'
7+ require 'json'
78
89if ENV [ 'RUBOCOP' ] || !ENV [ 'CI' ]
910 require "rubocop/rake_task"
@@ -44,12 +45,20 @@ Rake::TestTask.new(:test_others) do |t|
4445 t . description = "Run tests in #{ test_files . join ( ', ' ) } "
4546end
4647
48+ desc 'Display SimpleCov coverage summary'
49+ task :coverage_summary do
50+ last_run = JSON . parse ( File . read ( 'coverage/.last_run.json' ) )
51+ result = last_run [ 'result' ] [ 'line' ]
52+ puts "\n >>> SimpleCov Coverage: #{ result } % <<<"
53+ if result < 100.0
54+ Warning . warn "!!!!! Missing #{ ( 100.0 - result ) . round ( 2 ) } % coverage !!!!!"
55+ puts "\n (run it again with COVERAGE_REPORT=true for a line-by-line HTML report @ coverage/index.html)" unless ENV [ 'COVERAGE_REPORT' ]
56+ end
57+ end
58+
59+ # get the full list of of all the test tasks (and test files that each task run) with:
60+ # rake -D test_*
4761desc "Run all the test tasks: #{ test_tasks . keys . join ( ', ' ) } "
4862task test : [ *test_tasks . keys , :test_others ]
4963
50- task default : [ :test , :rubocop ]
51-
52-
53- # get the full list of of all the test tasks
54- # (and test files that each task run) with:
55- # rake -D test_*
64+ task default : [ :test , :rubocop , :coverage_summary ]
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ services:
2727 environment :
2828 - ENABLE_OJ=${ENABLE_OJ:-true}
2929 - RUBOCOP=${RUBOCOP:-true}
30+ - COVERAGE_REPORT=${COVERAGE_REPORT:-false}
31+ ports :
32+ - " 1234:1234" # RubyMine debugger
3033 stdin_open : true
3134 tty : true
3235
You can’t perform that action at this time.
0 commit comments