|
4 | 4 | require "dev-cmd/generate-cask-ci-matrix" |
5 | 5 |
|
6 | 6 | RSpec.describe Homebrew::DevCmd::GenerateCaskCiMatrix do |
| 7 | + subject(:generate_matrix) { described_class.new(["test"]) } |
| 8 | + |
| 9 | + let(:c_on_system_depends_on_mixed) do |
| 10 | + Cask::Cask.new("test-on-system-depends-on-mixed") do |
| 11 | + os macos: "darwin", linux: "linux" |
| 12 | + |
| 13 | + version "0.0.1,2" |
| 14 | + |
| 15 | + url "https://brew.sh/test-0.0.1.dmg" |
| 16 | + name "Test" |
| 17 | + desc "Test cask" |
| 18 | + homepage "https://brew.sh" |
| 19 | + |
| 20 | + on_macos do |
| 21 | + depends_on arch: :x86_64 |
| 22 | + end |
| 23 | + |
| 24 | + on_linux do |
| 25 | + depends_on arch: :arm64 |
| 26 | + end |
| 27 | + end |
| 28 | + end |
| 29 | + let(:c_on_macos_depends_on_intel) do |
| 30 | + Cask::Cask.new("test-on-macos-depends-on-intel") do |
| 31 | + os macos: "darwin", linux: "linux" |
| 32 | + |
| 33 | + version "0.0.1,2" |
| 34 | + |
| 35 | + url "https://brew.sh/test-0.0.1.dmg" |
| 36 | + name "Test" |
| 37 | + desc "Test cask" |
| 38 | + homepage "https://brew.sh" |
| 39 | + |
| 40 | + on_macos do |
| 41 | + depends_on arch: :x86_64 |
| 42 | + end |
| 43 | + end |
| 44 | + end |
| 45 | + let(:c_on_linux_depends_on_intel) do |
| 46 | + Cask::Cask.new("test-on-linux-depends-on-intel") do |
| 47 | + os macos: "darwin", linux: "linux" |
| 48 | + |
| 49 | + version "0.0.1,2" |
| 50 | + |
| 51 | + url "https://brew.sh/test-0.0.1.dmg" |
| 52 | + name "Test" |
| 53 | + desc "Test cask" |
| 54 | + homepage "https://brew.sh" |
| 55 | + |
| 56 | + on_linux do |
| 57 | + depends_on arch: :x86_64 |
| 58 | + end |
| 59 | + end |
| 60 | + end |
| 61 | + let(:c_on_system_depends_on_intel) do |
| 62 | + Cask::Cask.new("test-on-system-depends-on-intel") do |
| 63 | + os macos: "darwin", linux: "linux" |
| 64 | + |
| 65 | + version "0.0.1,2" |
| 66 | + |
| 67 | + url "https://brew.sh/test-0.0.1.dmg" |
| 68 | + name "Test" |
| 69 | + desc "Test cask" |
| 70 | + homepage "https://brew.sh" |
| 71 | + |
| 72 | + depends_on arch: :x86_64 |
| 73 | + end |
| 74 | + end |
| 75 | + let(:c_on_system) do |
| 76 | + Cask::Cask.new("test-on-system") do |
| 77 | + os macos: "darwin", linux: "linux" |
| 78 | + |
| 79 | + version "0.0.1,2" |
| 80 | + |
| 81 | + url "https://brew.sh/test-0.0.1.dmg" |
| 82 | + name "Test" |
| 83 | + desc "Test cask" |
| 84 | + homepage "https://brew.sh" |
| 85 | + end |
| 86 | + end |
| 87 | + let(:c_depends_macos_on_intel) do |
| 88 | + Cask::Cask.new("test-depends-on-intel") do |
| 89 | + version "0.0.1,2" |
| 90 | + |
| 91 | + url "https://brew.sh/test-0.0.1.dmg" |
| 92 | + name "Test" |
| 93 | + desc "Test cask" |
| 94 | + homepage "https://brew.sh" |
| 95 | + |
| 96 | + depends_on arch: :x86_64 |
| 97 | + |
| 98 | + app "Test.app" |
| 99 | + end |
| 100 | + end |
| 101 | + let(:c_app) do |
| 102 | + Cask::Cask.new("test-app") do |
| 103 | + version "0.0.1,2" |
| 104 | + |
| 105 | + url "https://brew.sh/test-0.0.1.dmg" |
| 106 | + name "Test" |
| 107 | + desc "Test cask" |
| 108 | + homepage "https://brew.sh" |
| 109 | + |
| 110 | + app "Test.app" |
| 111 | + end |
| 112 | + end |
| 113 | + let(:c_app_only_macos) do |
| 114 | + Cask::Cask.new("test-on-macos-guarded-stanza") do |
| 115 | + os macos: "darwin", linux: "linux" |
| 116 | + version "0.0.1,2" |
| 117 | + |
| 118 | + url "https://brew.sh/test-0.0.1.dmg" |
| 119 | + name "Test" |
| 120 | + desc "Test cask" |
| 121 | + homepage "https://brew.sh" |
| 122 | + |
| 123 | + on_macos do |
| 124 | + app "Test.app" |
| 125 | + end |
| 126 | + end |
| 127 | + end |
| 128 | + let(:c) do |
| 129 | + Cask::Cask.new("test-font") do |
| 130 | + version "0.0.1,2" |
| 131 | + |
| 132 | + url "https://brew.sh/test-0.0.1.dmg" |
| 133 | + name "Test" |
| 134 | + desc "Test cask" |
| 135 | + homepage "https://brew.sh" |
| 136 | + |
| 137 | + font "Test.ttf" |
| 138 | + end |
| 139 | + end |
| 140 | + let(:newest_macos) { MacOSVersion.new(HOMEBREW_MACOS_NEWEST_SUPPORTED).to_sym } |
| 141 | + |
7 | 142 | it_behaves_like "parseable arguments" |
| 143 | + |
| 144 | + describe "::filter_runners" do |
| 145 | + # We simulate a macOS version older than the newest, as the method will use |
| 146 | + # the host macOS version instead of the default (the newest macOS version). |
| 147 | + let(:older_macos) { :big_sur } |
| 148 | + |
| 149 | + context "when cask does not have on_system blocks/calls or `depends_on arch`" do |
| 150 | + it "returns an array including everything" do |
| 151 | + expect(generate_matrix.send(:filter_runners, c)) |
| 152 | + .to eq({ |
| 153 | + { arch: :arm, name: "macos-14", symbol: :sonoma } => 0.0, |
| 154 | + { arch: :arm, name: "macos-15", symbol: :sequoia } => 0.0, |
| 155 | + { arch: :arm, name: "macos-26", symbol: :tahoe } => 1.0, |
| 156 | + { arch: :arm, name: "ubuntu-22.04-arm", symbol: :linux } => 1.0, |
| 157 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 158 | + { arch: :intel, name: "ubuntu-22.04", symbol: :linux } => 1.0, |
| 159 | + }) |
| 160 | + |
| 161 | + expect(generate_matrix.send(:filter_runners, c_app_only_macos)) |
| 162 | + .to eq({ |
| 163 | + { arch: :arm, name: "macos-14", symbol: :sonoma } => 0.0, |
| 164 | + { arch: :arm, name: "macos-15", symbol: :sequoia } => 0.0, |
| 165 | + { arch: :arm, name: "macos-26", symbol: :tahoe } => 1.0, |
| 166 | + { arch: :arm, name: "ubuntu-22.04-arm", symbol: :linux } => 1.0, |
| 167 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 168 | + { arch: :intel, name: "ubuntu-22.04", symbol: :linux } => 1.0, |
| 169 | + }) |
| 170 | + end |
| 171 | + end |
| 172 | + |
| 173 | + context "when cask does not have on_system blocks/calls but has macOS specific stanza" do |
| 174 | + it "returns an array including all macOS" do |
| 175 | + expect(generate_matrix.send(:filter_runners, c_app)) |
| 176 | + .to eq({ |
| 177 | + { arch: :arm, name: "macos-14", symbol: :sonoma } => 0.0, |
| 178 | + { arch: :arm, name: "macos-15", symbol: :sequoia } => 0.0, |
| 179 | + { arch: :arm, name: "macos-26", symbol: :tahoe } => 1.0, |
| 180 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 181 | + }) |
| 182 | + end |
| 183 | + end |
| 184 | + |
| 185 | + context "when cask does not have on_system blocks/calls but has `depends_on arch`" do |
| 186 | + it "returns an array only including macOS/`depends_on arch` value" do |
| 187 | + expect(generate_matrix.send(:filter_runners, c_depends_macos_on_intel)) |
| 188 | + .to eq({ { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0 }) |
| 189 | + end |
| 190 | + end |
| 191 | + |
| 192 | + context "when cask has on_system blocks/calls but does not have `depends_on arch`" do |
| 193 | + it "returns an array with combinations of OS and architectures" do |
| 194 | + expect(generate_matrix.send(:filter_runners, c_on_system)) |
| 195 | + .to eq({ |
| 196 | + { arch: :arm, name: "macos-14", symbol: :sonoma } => 0.0, |
| 197 | + { arch: :arm, name: "macos-15", symbol: :sequoia } => 0.0, |
| 198 | + { arch: :arm, name: "macos-26", symbol: :tahoe } => 1.0, |
| 199 | + { arch: :arm, name: "ubuntu-22.04-arm", symbol: :linux } => 1.0, |
| 200 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 201 | + { arch: :intel, name: "ubuntu-22.04", symbol: :linux } => 1.0, |
| 202 | + }) |
| 203 | + end |
| 204 | + end |
| 205 | + |
| 206 | + context "when cask has on_system blocks/calls and `depends_on arch`" do |
| 207 | + it "returns an array with combinations of OS and `depends_on arch` value" do |
| 208 | + expect(generate_matrix.send(:filter_runners, c_on_system_depends_on_intel)) |
| 209 | + .to eq({ |
| 210 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 211 | + { arch: :intel, name: "ubuntu-22.04", symbol: :linux } => 1.0, |
| 212 | + }) |
| 213 | + |
| 214 | + expect(generate_matrix.send(:filter_runners, c_on_linux_depends_on_intel)) |
| 215 | + .to eq({ |
| 216 | + { arch: :arm, name: "macos-14", symbol: :sonoma } => 0.0, |
| 217 | + { arch: :arm, name: "macos-15", symbol: :sequoia } => 0.0, |
| 218 | + { arch: :arm, name: "macos-26", symbol: :tahoe } => 1.0, |
| 219 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 220 | + { arch: :intel, name: "ubuntu-22.04", symbol: :linux } => 1.0, |
| 221 | + }) |
| 222 | + |
| 223 | + expect(generate_matrix.send(:filter_runners, c_on_macos_depends_on_intel)) |
| 224 | + .to eq({ |
| 225 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 226 | + { arch: :intel, name: "ubuntu-22.04", symbol: :linux } => 1.0, |
| 227 | + { arch: :arm, name: "ubuntu-22.04-arm", symbol: :linux } => 1.0, |
| 228 | + }) |
| 229 | + |
| 230 | + expect(generate_matrix.send(:filter_runners, c_on_system_depends_on_mixed)) |
| 231 | + .to eq({ |
| 232 | + { arch: :arm, name: "ubuntu-22.04-arm", symbol: :linux } => 1.0, |
| 233 | + { arch: :intel, name: "macos-15-intel", symbol: :sequoia } => 1.0, |
| 234 | + }) |
| 235 | + end |
| 236 | + end |
| 237 | + end |
8 | 238 | end |
0 commit comments