test_diff 0.4.2 → 0.5.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/README.md +16 -4
- data/exe/test_diff +18 -8
- data/lib/test_diff/build_coverage.rb +5 -4
- data/lib/test_diff/coverage_runner.rb +13 -7
- data/lib/test_diff/logging.rb +6 -2
- data/lib/test_diff/timing_tracker.rb +7 -5
- data/lib/test_diff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c60bbb0ba468e66251ee6a5bc4640eb868daa0a2e19585e5f2036bd1867672b
|
4
|
+
data.tar.gz: 0abaa8178186abec9c3755195341db54c22e5787688c984659ed88c29d87b164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c268a1b15442b9df3c232a61d0220933e4831339b58e2194f88c4e878a976918be806f2490ef6880ab7d20bd71ee09b66cd5d7fd9b51bccc56b919c4e9f9f88
|
7
|
+
data.tar.gz: b7b5bb54b2c7870fdaeca86cd6eb04db8e871872ab3d782a9c82669f0e4529b3c4cd0a7251e48d96da4d9521f9b596c3a76315ccdd2d0fcaa8d1005e8f9d81bf
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ And then execute:
|
|
22
22
|
|
23
23
|
## Rails Setup
|
24
24
|
|
25
|
-
|
25
|
+
If `eager_load` is enabled in `config/environments/test.rb`, disable it based on `ENV['TEST_DIFF_COVERAGE']`
|
26
26
|
EG:
|
27
27
|
|
28
28
|
```ruby
|
@@ -41,15 +41,27 @@ end
|
|
41
41
|
|
42
42
|
## Usage
|
43
43
|
|
44
|
-
Building the test coverage index
|
44
|
+
Building the test coverage index (run once a day on your main branch)
|
45
45
|
|
46
|
-
|
46
|
+
```bash
|
47
|
+
$ test_diff build_coverage spec/spec_helper.rb
|
47
48
|
$ # part here to upload test_diff_coverage to a shared space, ie aws
|
49
|
+
```
|
48
50
|
|
49
|
-
Running a test difference
|
51
|
+
Running a test difference (after commit on your separate branch)
|
50
52
|
|
53
|
+
```bash
|
51
54
|
$ # part here to download test_diff_coverage from shared space, ie aws
|
52
55
|
$ test_diff rspec
|
56
|
+
```
|
57
|
+
|
58
|
+
Updating the test coverage index (after separate branch merge into main branch)
|
59
|
+
|
60
|
+
```bash
|
61
|
+
$ # part here to download test_diff_coverage from shared space, ie aws
|
62
|
+
$ test_diff build_coverage_diff spec/spec_helper.rb
|
63
|
+
$ # part here to upload test_diff_coverage to a shared space, ie aws
|
64
|
+
```
|
53
65
|
|
54
66
|
## Development
|
55
67
|
|
data/exe/test_diff
CHANGED
@@ -6,9 +6,16 @@ require 'test_diff'
|
|
6
6
|
|
7
7
|
# thor class to allow execution
|
8
8
|
class TestDiffBuilder < Thor
|
9
|
-
desc 'build_coverage spec', 'runs the specs and generates
|
10
|
-
|
11
|
-
|
9
|
+
desc 'build_coverage spec', 'runs the specs and generates coverage index'
|
10
|
+
method_option :spec_folder, desc: 'Folder where specs located', default: 'spec', type: :string, banner: 'spec'
|
11
|
+
method_option :stop_on_failure, desc: 'Stop building coverage if spec fails', default: false, type: :boolean
|
12
|
+
method_option :only_missing, desc: 'build coverage for missing specs', default: false, type: :boolean
|
13
|
+
def build_coverage(pre_load = nil)
|
14
|
+
TestDiff::BuildCoverage.new(options[:spec_folder],
|
15
|
+
pre_load,
|
16
|
+
options[:stop_on_failure],
|
17
|
+
options[:only_missing])
|
18
|
+
.run
|
12
19
|
track_build
|
13
20
|
end
|
14
21
|
|
@@ -18,13 +25,16 @@ class TestDiffBuilder < Thor
|
|
18
25
|
end
|
19
26
|
|
20
27
|
desc 'rspec', 'runs the specs difference between the branches'
|
21
|
-
|
22
|
-
|
28
|
+
method_option :spec_folder, desc: 'Folder where specs located', default: 'spec', type: :string, banner: 'spec'
|
29
|
+
def rspec(groups_of = nil, group = '0')
|
30
|
+
TestDiff::RunDiff.new(options[:spec_folder], groups_of, group).run
|
23
31
|
end
|
24
32
|
|
25
|
-
desc 'build_coverage_diff spec', 'runs the specs difference
|
26
|
-
|
27
|
-
|
33
|
+
desc 'build_coverage_diff spec', 'runs the specs difference and updates coverage index'
|
34
|
+
method_option :spec_folder, desc: 'Folder where specs located', default: 'spec', type: :string, banner: 'spec'
|
35
|
+
method_option :stop_on_failure, desc: 'Stop building coverage if spec fails', default: false, type: :boolean
|
36
|
+
def build_coverage_diff(pre_load = nil)
|
37
|
+
TestDiff::BuildCoverageDiff.new(options[:spec_folder], pre_load, options[:stop_on_failure]).run
|
28
38
|
track_build
|
29
39
|
end
|
30
40
|
end
|
@@ -2,16 +2,17 @@
|
|
2
2
|
module TestDiff
|
3
3
|
# class used to build the coverage file
|
4
4
|
class BuildCoverage
|
5
|
-
def initialize(spec_folder, pre_load,
|
5
|
+
def initialize(spec_folder, pre_load, stop_on_failure, only_missing)
|
6
6
|
@spec_folder = spec_folder
|
7
7
|
@pre_load = pre_load
|
8
8
|
@batch_queue = Queue.new
|
9
|
-
@
|
9
|
+
@stop_on_failure = stop_on_failure
|
10
|
+
@only_missing = only_missing
|
10
11
|
end
|
11
12
|
|
12
13
|
def run
|
13
|
-
RunableTests.add_all(@spec_folder, @batch_queue, @
|
14
|
-
CoverageRunner.run(@batch_queue, @pre_load,
|
14
|
+
RunableTests.add_all(@spec_folder, @batch_queue, @only_missing)
|
15
|
+
CoverageRunner.run(@batch_queue, @pre_load, !@stop_on_failure)
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -16,6 +16,8 @@ module TestDiff
|
|
16
16
|
require 'coverage.so'
|
17
17
|
Coverage.start
|
18
18
|
|
19
|
+
ENV['TEST_DIFF_COVERAGE'] = 'yes'
|
20
|
+
|
19
21
|
require_boot
|
20
22
|
require_rspec
|
21
23
|
require_pre_load
|
@@ -26,9 +28,14 @@ module TestDiff
|
|
26
28
|
private
|
27
29
|
|
28
30
|
def require_boot
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
if File.exist?('config/boot.rb')
|
32
|
+
puts 'Loading config/boot.rb'
|
33
|
+
require File.expand_path('config/boot.rb')
|
34
|
+
elsif File.exist?('Gemfile')
|
35
|
+
puts 'Bundler setup'
|
36
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile')
|
37
|
+
require 'bundler/setup'
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
41
|
def require_pre_load
|
@@ -39,8 +46,8 @@ module TestDiff
|
|
39
46
|
end
|
40
47
|
|
41
48
|
def require_rspec
|
42
|
-
puts 'Loading rspec'
|
43
|
-
require 'rspec'
|
49
|
+
puts 'Loading rspec/core'
|
50
|
+
require 'rspec/core'
|
44
51
|
end
|
45
52
|
|
46
53
|
def pre_run_checks
|
@@ -64,7 +71,6 @@ module TestDiff
|
|
64
71
|
|
65
72
|
def start_process_fork(main_spec_file)
|
66
73
|
Process.fork do
|
67
|
-
ENV['TEST_DIFF_COVERAGE'] = 'yes'
|
68
74
|
puts "running #{main_spec_file}"
|
69
75
|
ActiveRecord::Base.connection.reconnect! if defined?(ActiveRecord::Base)
|
70
76
|
Time.zone_default = (Time.zone = 'UTC') if Time.respond_to?(:zone_default) && Time.zone_default.nil?
|
@@ -78,7 +84,7 @@ module TestDiff
|
|
78
84
|
if result
|
79
85
|
save_coverage_data(main_spec_file, Time.now - s)
|
80
86
|
else
|
81
|
-
$stderr.puts(@last_output.
|
87
|
+
$stderr.puts(@last_output.string)
|
82
88
|
Coverage.result # disable coverage
|
83
89
|
exit!(false) unless @continue
|
84
90
|
end
|
data/lib/test_diff/logging.rb
CHANGED
@@ -7,9 +7,13 @@ module TestDiff
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def log_debug(*args)
|
10
|
-
Config.logger.
|
10
|
+
Config.logger.debug(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def log_error(*args)
|
14
|
+
Config.logger.error(*args)
|
11
15
|
end
|
12
16
|
|
13
|
-
module_function :log_debug, :log_info
|
17
|
+
module_function :log_debug, :log_info, :log_error
|
14
18
|
end
|
15
19
|
end
|
@@ -6,6 +6,8 @@ module TestDiff
|
|
6
6
|
new(queue).run(&block)
|
7
7
|
end
|
8
8
|
|
9
|
+
include Logging
|
10
|
+
|
9
11
|
def initialize(queue)
|
10
12
|
@queue = queue
|
11
13
|
@original_size = queue_size
|
@@ -33,14 +35,14 @@ module TestDiff
|
|
33
35
|
begin
|
34
36
|
do_timing
|
35
37
|
rescue => e
|
36
|
-
|
38
|
+
log_error "----- Timing failed: #{e.message} -----"
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def do_timing
|
42
|
-
|
43
|
-
sleep_time =
|
44
|
+
log_info "Timing #{@original_size} specs"
|
45
|
+
sleep_time = 90.0
|
44
46
|
until queue_empty?
|
45
47
|
last_current_size = queue_size
|
46
48
|
sleep(sleep_time)
|
@@ -48,9 +50,9 @@ module TestDiff
|
|
48
50
|
current_completed = last_current_size - current_size
|
49
51
|
if current_completed > 0
|
50
52
|
est_time_left = (sleep_time / current_completed.to_f) * current_size
|
51
|
-
|
53
|
+
log_info "specs left #{current_size}, est time_left: #{est_time_left.to_i}"
|
52
54
|
else
|
53
|
-
|
55
|
+
log_info "specs left #{current_size}, est time_left: N/A"
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
data/lib/test_diff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Speelman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|