Module: SimpleCov::CLI::Watch::TestPlan
Instance Method Summary collapse
-
#build(changed, document, root:, input:, stderr:) ⇒ Object
tests: where nil tests mean the full command.
- #recorded_test_files(document) ⇒ Object
-
#watched_paths(document, root) ⇒ Object
The watch set a report defines: its tracked files plus the files of its recorded tests.
Instance Method Details
#build(changed, document, root:, input:, stderr:) ⇒ Object
tests: where nil tests mean the full command. A report with no map, a malformed one, or any fail-open trigger runs everything; an empty selection runs nothing.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simplecov/cli/watch/test_plan.rb', line 12 def build(changed, document, root:, input:, stderr:) contexts = document["contexts"] return {run: true, tests: nil} unless contexts.instance_of?(Array) && contexts.all?(String) selection = Affected::Selection.build(changed, document, contexts, {input: input}, stderr, root: root) return {run: true, tests: nil} if selection.nil? || !selection.fetch(:triggers).empty? return {run: false, tests: []} if selection.fetch(:tests).empty? {run: true, tests: selection.fetch(:tests)} end |
#recorded_test_files(document) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/simplecov/cli/watch/test_plan.rb', line 33 def recorded_test_files(document) none = [] #: Array[String] contexts = document["contexts"] return none unless contexts.instance_of?(Array) contexts.filter_map { |id| Affected::Selection.test_file_of(id.to_s) } end |
#watched_paths(document, root) ⇒ Object
The watch set a report defines: its tracked files plus the files of its recorded tests.
25 26 27 28 29 30 31 |
# File 'lib/simplecov/cli/watch/test_plan.rb', line 25 def watched_paths(document, root) none = [] #: Array[String] coverage = document["coverage"] sources = coverage.instance_of?(Hash) ? coverage.keys : none tests = recorded_test_files(document).map { |path| File.(path, root) } (sources + tests).uniq end |