Skip to content

Commit 2d4bd68

Browse files
committed
Refactor Matrixeval::Ruby::Context#all to consider exclusions
1 parent 7c5abb0 commit 2d4bd68

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/matrixeval/ruby/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def rest_vector_variants_matrix
4242
end
4343

4444
def exclusions
45-
YAML["exclude"]
45+
YAML["exclude"] || []
4646
end
4747

4848
end

lib/matrixeval/ruby/context.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def all
1616
main_variant: variants.find { |v| v.vector.main? },
1717
rest_variants: variants.reject { |v| v.vector.main? }
1818
)
19+
end.select do |context|
20+
Config.exclusions.none? do |exclusion|
21+
context.match_exclusion?(exclusion)
22+
end
1923
end
2024
end
2125

test/matrixeval/ruby/context_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_all
9191
@rails_6_variant
9292
]
9393
])
94+
Matrixeval::Ruby::Config.stubs(:exclusions).returns([])
9495

9596
contexts = Matrixeval::Ruby::Context.all
9697

@@ -100,4 +101,19 @@ def test_all
100101
assert_equal [@rails_6_variant, @sidekiq_5_variant], contexts[0].rest_variants
101102
end
102103

104+
def test_all_with_exclusions
105+
Matrixeval::Ruby::Config.stubs(:variant_combinations).returns([
106+
[
107+
@ruby_3_variant,
108+
@sidekiq_5_variant,
109+
@rails_6_variant
110+
]
111+
])
112+
Matrixeval::Ruby::Config.stubs(:exclusions).returns([{ "ruby" => "3.0", "rails" => "6.1" }])
113+
114+
contexts = Matrixeval::Ruby::Context.all
115+
116+
assert_equal 0, contexts.count
117+
end
118+
103119
end

0 commit comments

Comments
 (0)