Resolve compiler_selector_spec violation

This commit is contained in:
Douglas Eichelberger 2023-01-22 17:05:56 -08:00
parent d30ba99612
commit ea832538f7

View File

@ -10,12 +10,7 @@ describe CompilerSelector do
let(:compilers) { [:clang, :gnu] }
let(:software_spec) { SoftwareSpec.new }
let(:cc) { :clang }
let(:versions) do
double(
llvm_build_version: Version::NULL,
clang_build_version: Version.create("600"),
)
end
let(:versions) { class_double(DevelopmentTools, clang_build_version: Version.create("600")) }
before do
allow(versions).to receive(:gcc_version) do |name|
@ -46,13 +41,15 @@ describe CompilerSelector do
it "returns gcc-6 if gcc formula offers gcc-6 on mac", :needs_macos do
software_spec.fails_with(:clang)
allow(Formulary).to receive(:factory).with("gcc").and_return(double(version: Version.new("6.0")))
allow(Formulary).to receive(:factory).with("gcc")
.and_return(instance_double(Formula, version: Version.new("6.0")))
expect(selector.compiler).to eq("gcc-6")
end
it "returns gcc-5 if gcc formula offers gcc-5 on linux", :needs_linux do
software_spec.fails_with(:clang)
allow(Formulary).to receive(:factory).with("gcc@11").and_return(double(version: Version.new("5.0")))
allow(Formulary).to receive(:factory).with("gcc@11")
.and_return(instance_double(Formula, version: Version.new("5.0")))
expect(selector.compiler).to eq("gcc-5")
end
@ -60,14 +57,16 @@ describe CompilerSelector do
software_spec.fails_with(:clang)
software_spec.fails_with(gcc: "5")
software_spec.fails_with(gcc: "7")
allow(Formulary).to receive(:factory).with("gcc@11").and_return(double(version: Version.new("5.0")))
allow(Formulary).to receive(:factory).with("gcc@11")
.and_return(instance_double(Formula, version: Version.new("5.0")))
expect(selector.compiler).to eq("gcc-6")
end
it "returns gcc-7 if gcc formula offers gcc-5 and fails with gcc <= 6 on linux", :needs_linux do
software_spec.fails_with(:clang)
software_spec.fails_with(:gcc) { version "6" }
allow(Formulary).to receive(:factory).with("gcc@11").and_return(double(version: Version.new("5.0")))
allow(Formulary).to receive(:factory).with("gcc@11")
.and_return(instance_double(Formula, version: Version.new("5.0")))
expect(selector.compiler).to eq("gcc-7")
end