flutter 0.2.1 → 0.2.3
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/.yardopts +2 -0
- data/CHANGELOG.md +15 -2
- data/Gemfile +5 -0
- data/README.md +31 -27
- data/Rakefile +5 -4
- data/lib/flutter/minitest.rb +3 -1
- data/lib/flutter/parser.rb +11 -5
- data/lib/flutter/rspec.rb +4 -1
- data/lib/flutter/tracker.rb +6 -2
- data/lib/flutter/version.rb +3 -1
- data/lib/flutter.rb +0 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0daff4637dd21ecf8d1b03a3a63462f8a4d2cdabd36323348093e4d94dbba057
|
4
|
+
data.tar.gz: 6245d89c2e32a14c419dd888822766c2e99e9423d38d57280c6586a357649023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc30fd26343a5668793299c43a7361edb635f45f62693a8cbb9383d2eb910dd021cb738746cca92cd56b24a6fecbabb002e4d0e4f2476624aa8d5965ab9271b8
|
7
|
+
data.tar.gz: 572a637813788adb8ef674b97381976e3b4e56adc75ba70aa903e20f38bd564b956f092b8e8a1388844f139bf96cea868d18c188d5eb5333dd0f7e4bdeb3c2e1
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -5,9 +5,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## Unreleased
|
8
|
-
##
|
9
|
-
|
8
|
+
## 0.2.3 - 2022-10-04
|
9
|
+
### Fixed
|
10
|
+
- Disable filtering when Flutter.enabled=false
|
11
|
+
|
12
|
+
## 0.2.2 - 2022-10-03
|
13
|
+
### Added
|
14
|
+
- Document configuration options in README
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Delay requiring source files explicitely and only in the case where the constant cannot be found
|
18
|
+
- Ensure the previous test->coverage mapping is merged with current one when the test fails.
|
19
|
+
|
10
20
|
## 0.2.1
|
21
|
+
### Fixed
|
22
|
+
- Corrected integration examples for guard in README
|
23
|
+
|
11
24
|
## 0.2.0
|
12
25
|
### Added
|
13
26
|
- CI Recipe in README
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[](https://github.com/indydevs/flutter/actions/workflows/main.yml)
|
4
4
|
[](https://codecov.io/github/indydevs/flutter)
|
5
5
|
[](https://rubygems.org/gems/flutter)
|
6
|
-
[](
|
6
|
+
[](https://flutter.indydevs.org)
|
7
7
|
|
8
8
|
```
|
9
9
|
__ __
|
@@ -23,7 +23,7 @@ or in continuous integration environments to only run the subset of tests affect
|
|
23
23
|
## How?
|
24
24
|
Flutter tracks each method call within the context of each test case in your test suite and persists this mapping along with
|
25
25
|
a signature for all the methods that were exercised. On subsequent runs Flutter intercepts test enumeration and skips any test if
|
26
|
-
|
26
|
+
**ALL** the following conditions are true:
|
27
27
|
|
28
28
|
- The test was seen before
|
29
29
|
- The source of the test has not changed
|
@@ -43,23 +43,17 @@ all the following conditions are true:
|
|
43
43
|
```ruby
|
44
44
|
require 'flutter'
|
45
45
|
```
|
46
|
-
- Enable & configure it in your `test_helper.rb
|
46
|
+
- Enable & configure it in your `test_helper.rb` (See [Configuration options](#configuration-options) for available options):
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
Flutter.configure do |config|
|
50
50
|
config.enabled = true
|
51
|
-
# Paths to consider when tracking test -> source mappings. Default: Dir.pwd/*
|
52
|
-
config.sources = ["./app/*", "./test/*"]
|
53
|
-
# Paths to ignore for tracking test -> source. Default: ./vendor
|
54
|
-
config.exclusions = ["./vendor/*"]
|
55
|
-
# Storage type. Default: Flutter::Persistence::Marshal
|
56
|
-
config.storage_class = Flutter::Persistence::Marshal
|
57
|
-
# Where to store the state. Default: ./.flutter
|
58
|
-
config.storage_options = {path: "./.flutter"}
|
59
|
-
# Whether to reset the stored state before the test run. Default: false
|
60
|
-
config.reset_storage = false
|
61
51
|
end
|
62
52
|
```
|
53
|
+
- Run your test suite the way you normally would (for example: `bundle exec rake test`). The first run will run all
|
54
|
+
tests. After the test run has completed the mapping of test cases to exercised code will be persisted in the `./.flutter`
|
55
|
+
folder.
|
56
|
+
- Now make changes and run the test suite again. Only the relevant tests will be executed.
|
63
57
|
|
64
58
|
#### With guard
|
65
59
|
Using the same configuration as above (and assuming that the application
|
@@ -84,23 +78,18 @@ end
|
|
84
78
|
```ruby
|
85
79
|
require 'flutter'
|
86
80
|
```
|
87
|
-
- Enable & configure it in your `spec_helper.rb
|
81
|
+
- Enable & configure it in your `spec_helper.rb` (See [Configuration options](#configuration-options) for available options):
|
88
82
|
|
89
83
|
```ruby
|
90
84
|
Flutter.configure do |config|
|
91
85
|
config.enabled = true
|
92
|
-
# Paths to consider when tracking test -> source mappings. Default: Dir.pwd/*
|
93
|
-
config.sources = ["./app/*", "./lib/*", "./spec/*"]
|
94
|
-
# Paths to ignore for tracking test -> source. Default: ./vendor
|
95
|
-
config.exclusions = ["./vendor/*"]
|
96
|
-
# Storage type. Default: Flutter::Persistence::Marshal
|
97
|
-
config.storage_class = Flutter::Persistence::Marshal
|
98
|
-
# Where to store the state. Default: ./.flutter
|
99
|
-
config.storage_options = {path: "./.flutter"}
|
100
|
-
# Whether to reset the stored state before the test run. Default: false
|
101
|
-
config.reset_storage = false
|
102
86
|
end
|
103
87
|
```
|
88
|
+
- Run your specs the way you normally would (for example: `bundle exec rspec`). The first run will run all
|
89
|
+
tests. After the test run has completed the mapping of test cases to exercised code will be persisted in the `./.flutter`
|
90
|
+
folder.
|
91
|
+
- Now make changes and run rspec again. Only the relevant examples will be executed.
|
92
|
+
|
104
93
|
#### With guard
|
105
94
|
Using the same configuration as above (and assuming that the application
|
106
95
|
sources are in the `./app` & `./lib` folders while the specs are in the `./spec` folder)
|
@@ -111,6 +100,21 @@ guard :rspec, cmd: "rspec" do
|
|
111
100
|
watch(%r{^(spec|app|lib)/(.*/)?([^/]+)\.rb$}) { "spec" }
|
112
101
|
end
|
113
102
|
```
|
103
|
+
|
104
|
+
### Configuration options
|
105
|
+
| option | Description | Type | Default |
|
106
|
+
|:-----------------:|:---------------------------------------------------------------|:---------------------------------------:|:-------------------------------:|
|
107
|
+
| `enabled` | Whether flutter is enabled | `TrueClass, FalseClass` | `true` |
|
108
|
+
| `sources` | List of glob style expressions to select source files to track | `Set` | `["#{Dir.pwd}/*"]` |
|
109
|
+
| `exclusions` | List of glob style expressions to exclude sources files | `Set` | `["#{Dir.pwd}/vendor}/*"]` |
|
110
|
+
| `storage_class` | The storage class to use for persisting the state | `Flutter::Persistence::AbstractStorage` | `Flutter::Persistence::Marshal` |
|
111
|
+
| `storage_options` | Additional options to pass to the storage class | `Hash` | `{path: './.flutter'}` |
|
112
|
+
| `reset_storage` | Whether to clear the persisted state on initialization | `TrueClass, FalseClass` | `false` |
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
114
118
|
## Configuring flutter in continuous integration
|
115
119
|
|
116
120
|
Flutter can be used in continuous integration environments to speed up the turn
|
@@ -179,9 +183,9 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
179
183
|
and contains useful details.
|
180
184
|
- Create a new release using the `release` rake task as follows (for more details about specifying the version change
|
181
185
|
run `gem bump --help` which is the command used by the task):
|
182
|
-
- Patch release `bundle exec rake release["
|
183
|
-
- Minor release `bundle exec rake release["
|
184
|
-
- Major release `bundle exec rake release["
|
186
|
+
- Patch release `bundle exec rake release["patch"]`
|
187
|
+
- Minor release `bundle exec rake release["minor"]`
|
188
|
+
- Major release `bundle exec rake release["major"]`
|
185
189
|
> **Note**
|
186
190
|
> The `release` rake task automates updating the changelog & version, committing the changes & creating a new tag
|
187
191
|
- Push the tag. The CI workflow for tag pushes will take care of publishing the gem & creating a github release.
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "date"
|
3
4
|
require "rake/testtask"
|
4
5
|
require "keepachangelog"
|
5
6
|
|
@@ -27,11 +28,11 @@ desc "Increment the version, update changelog and create a tag for the release"
|
|
27
28
|
task :release, [:version] do |_t, args|
|
28
29
|
parser = Keepachangelog::MarkdownParser.load("CHANGELOG.md")
|
29
30
|
log = parser.parsed_content["versions"].delete("Unreleased")
|
30
|
-
sh("gem bump --pretend #{args[:version]}") do |ok, _|
|
31
|
+
sh("gem bump --pretend -v #{args[:version]}") do |ok, _|
|
31
32
|
if ok
|
32
|
-
new_version = %x(gem bump --no-commit #{args[:version]} | awk '{print $4}' | uniq).chomp
|
33
|
+
new_version = %x(gem bump --no-commit -v #{args[:version]} | awk '{print $4}' | uniq).chomp
|
33
34
|
parser.parsed_content["versions"]["Unreleased"] = { "url" => nil, "date" => nil, "changes" => {} }
|
34
|
-
parser.parsed_content["versions"][new_version] = log
|
35
|
+
parser.parsed_content["versions"]["#{new_version} - #{Date.today}"] = log
|
35
36
|
File.open("CHANGELOG.md", "w") do |file|
|
36
37
|
file.write(parser.to_md)
|
37
38
|
end
|
@@ -49,7 +50,7 @@ task :release_notes, [:version] do |_t, args|
|
|
49
50
|
parser = Keepachangelog::MarkdownParser.load("CHANGELOG.md")
|
50
51
|
parser.parsed_content.delete("intro")
|
51
52
|
parser.parsed_content.delete("title")
|
52
|
-
parser.parsed_content["versions"] = parser.parsed_content["versions"].select { |k, _v| k
|
53
|
+
parser.parsed_content["versions"] = parser.parsed_content["versions"].select { |k, _v| k.start_with?(version) }
|
53
54
|
lines = parser.to_md.split("\n")
|
54
55
|
chunk = lines.slice_after { |line| line.include?("## #{version}") }.to_a[1] || []
|
55
56
|
puts chunk.join("\n")
|
data/lib/flutter/minitest.rb
CHANGED
@@ -42,6 +42,8 @@ module Flutter
|
|
42
42
|
module Hooks
|
43
43
|
module ClassMethods
|
44
44
|
def runnable_methods
|
45
|
+
return super unless ::Flutter.enabled
|
46
|
+
|
45
47
|
Flutter::Minitest.filtered ||= 0
|
46
48
|
Flutter::Minitest.total ||= 0
|
47
49
|
default = super()
|
@@ -62,7 +64,7 @@ module Flutter
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def before_teardown
|
65
|
-
Minitest.flutter_tracker&.stop if ::Flutter.enabled
|
67
|
+
Minitest.flutter_tracker&.stop(location, failures.empty?) if ::Flutter.enabled
|
66
68
|
super
|
67
69
|
end
|
68
70
|
end
|
data/lib/flutter/parser.rb
CHANGED
@@ -51,9 +51,14 @@ module Flutter
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def build_signatures
|
54
|
-
require_relative @file
|
55
54
|
@targets.each do |container|
|
56
|
-
|
55
|
+
begin
|
56
|
+
instance = Kernel.const_get(container)
|
57
|
+
rescue NameError
|
58
|
+
require_relative @file
|
59
|
+
instance = Kernel.const_get(container)
|
60
|
+
end
|
61
|
+
|
57
62
|
class_methods = instance.methods + instance.private_methods
|
58
63
|
instance_methods = instance.instance_methods + instance.private_instance_methods
|
59
64
|
|
@@ -65,11 +70,12 @@ module Flutter
|
|
65
70
|
hash = source_hash(instance.instance_method(method))
|
66
71
|
["#{container}:#{method}", hash] if hash
|
67
72
|
end.compact.to_h)
|
68
|
-
rescue
|
69
|
-
|
73
|
+
rescue
|
74
|
+
warn("Failed to parse #{@file}")
|
75
|
+
break
|
70
76
|
end
|
71
77
|
rescue LoadError
|
72
|
-
|
78
|
+
warn("Failed to inspect #{@file}")
|
73
79
|
end
|
74
80
|
|
75
81
|
def source_hash(callable)
|
data/lib/flutter/rspec.rb
CHANGED
@@ -17,6 +17,8 @@ module Flutter
|
|
17
17
|
|
18
18
|
module ClassMethods
|
19
19
|
def filtered_examples
|
20
|
+
return super unless Flutter.enabled
|
21
|
+
|
20
22
|
Flutter::RSpec.filtered ||= Set.new
|
21
23
|
Flutter::RSpec.total ||= Set.new
|
22
24
|
Flutter::RSpec.tracker.reset! if Flutter.enabled && Flutter.config.reset_storage
|
@@ -52,7 +54,8 @@ if defined?(RSpec.configure)
|
|
52
54
|
config.around(:each) do |example|
|
53
55
|
Flutter::RSpec.tracker.start(example.full_description) if Flutter.enabled
|
54
56
|
example.run
|
55
|
-
Flutter::RSpec.tracker.stop
|
57
|
+
Flutter::RSpec.tracker.stop(example.full_description,
|
58
|
+
example.execution_result.exception.nil?) if Flutter.enabled
|
56
59
|
end
|
57
60
|
|
58
61
|
config.after(:suite) do
|
data/lib/flutter/tracker.rb
CHANGED
@@ -26,6 +26,7 @@ module Flutter
|
|
26
26
|
@exclusions = exclusions.map { |s| File.absolute_path(s) }
|
27
27
|
@storage = storage_class.new(**storage_options)
|
28
28
|
@test_mapping = @storage.test_mapping
|
29
|
+
@previous_test_mapping = {}
|
29
30
|
@test_source_mapping = {}
|
30
31
|
@source_mapping = @storage.source_mapping
|
31
32
|
@current_source_mapping = {}
|
@@ -39,7 +40,7 @@ module Flutter
|
|
39
40
|
def start(test)
|
40
41
|
# Delete test from the in-memory mapping to allow each new test run
|
41
42
|
# to store all the functions that the test calls into
|
42
|
-
@test_mapping.delete(test)
|
43
|
+
@previous_test_mapping[test] = @test_mapping.delete(test)
|
43
44
|
@current_tracepoint = TracePoint.new(:call) do |tp|
|
44
45
|
hit!(test, tp)
|
45
46
|
end
|
@@ -47,8 +48,11 @@ module Flutter
|
|
47
48
|
end
|
48
49
|
|
49
50
|
# End tracking (should be called after a call to {#start})
|
50
|
-
|
51
|
+
# @param [String] test A unique identifier for the test
|
52
|
+
# @param [TrueClass, FalseClass] success Whether the test succeeded
|
53
|
+
def stop(test, success)
|
51
54
|
@current_tracepoint&.disable
|
55
|
+
@test_mapping[test].merge!(@previous_test_mapping.delete(test) || {}) { |_, old, new| old + new } unless success
|
52
56
|
end
|
53
57
|
|
54
58
|
##
|
data/lib/flutter/version.rb
CHANGED
data/lib/flutter.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali-Akber Saifee
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-10-
|
12
|
+
date: 2022-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deep_merge
|
@@ -65,6 +65,7 @@ extra_rdoc_files: []
|
|
65
65
|
files:
|
66
66
|
- ".overcommit.yml"
|
67
67
|
- ".rubocop.yml"
|
68
|
+
- ".yardopts"
|
68
69
|
- CHANGELOG.md
|
69
70
|
- CODE_OF_CONDUCT.md
|
70
71
|
- Gemfile
|
@@ -84,13 +85,15 @@ files:
|
|
84
85
|
- lib/flutter/version.rb
|
85
86
|
- lib/minitest/flutter_plugin.rb
|
86
87
|
- sig/flutter.rbs
|
87
|
-
homepage: https://
|
88
|
+
homepage: https://flutter.indydevs.org
|
88
89
|
licenses:
|
89
90
|
- MIT
|
90
91
|
metadata:
|
91
|
-
homepage_uri: https://
|
92
|
+
homepage_uri: https://flutter.indydevs.org
|
92
93
|
source_code_uri: https://github.com/indydevs/flutter
|
94
|
+
bug_tracker_uri: https://github.com/indydevs/flutter/issues
|
93
95
|
changelog_uri: https://github.com/indydevs/flutter/blob/master/CHANGELOG.md
|
96
|
+
ducmentation_uri: https://flutter.indydevs.org
|
94
97
|
post_install_message:
|
95
98
|
rdoc_options: []
|
96
99
|
require_paths:
|