Merge pull request #6214 from zbeekman/add-MPI-cop
Add MPICH cop and test
This commit is contained in:
commit
c95cf90e32
@ -157,6 +157,24 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class MpiCheck < FormulaCop
|
||||||
|
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
||||||
|
# Enforce use of OpenMPI for MPI dependency in core
|
||||||
|
return unless formula_tap == "homebrew-core"
|
||||||
|
|
||||||
|
find_method_with_args(body_node, :depends_on, "mpich") do
|
||||||
|
problem "Use 'depends_on \"open-mpi\"' instead of '#{@offensive_node.source}'."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def autocorrect(node)
|
||||||
|
# The dependency nodes may need to be re-sorted because of this
|
||||||
|
lambda do |corrector|
|
||||||
|
corrector.replace(node.source_range, "depends_on \"open-mpi\"")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Miscellaneous < FormulaCop
|
class Miscellaneous < FormulaCop
|
||||||
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
||||||
# FileUtils is included in Formula
|
# FileUtils is included in Formula
|
||||||
|
@ -16,7 +16,7 @@ module RuboCop
|
|||||||
problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)."
|
problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)."
|
||||||
end
|
end
|
||||||
|
|
||||||
if depends_on?("veclibfort") || depends_on?("lapack")
|
if formula_tap == "homebrew-core" && (depends_on?("veclibfort") || depends_on?("lapack"))
|
||||||
problem "Formulae should use OpenBLAS as the default serial linear algebra library."
|
problem "Formulae should use OpenBLAS as the default serial linear algebra library."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -279,6 +279,31 @@ describe RuboCop::Cop::FormulaAudit::OptionDeclarations do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe RuboCop::Cop::FormulaAudit::MpiCheck do
|
||||||
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
|
context "When auditing formula" do
|
||||||
|
it "reports an offense when using depends_on \"mpich\"" do
|
||||||
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
|
class Foo < Formula
|
||||||
|
desc "foo"
|
||||||
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
|
depends_on "mpich"
|
||||||
|
^^^^^^^^^^^^^^^^^^ Use 'depends_on "open-mpi"' instead of 'depends_on "mpich"'.
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
expect_correction(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
desc "foo"
|
||||||
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
|
depends_on "open-mpi"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
|
@ -32,6 +32,28 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "when veclibfort is used instead of OpenBLAS" do
|
||||||
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
|
class Foo < Formula
|
||||||
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
homepage "https://brew.sh"
|
||||||
|
depends_on "veclibfort"
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^ Formulae should use OpenBLAS as the default serial linear algebra library.
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
it "when lapack is used instead of OpenBLAS" do
|
||||||
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
|
class Foo < Formula
|
||||||
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
homepage "https://brew.sh"
|
||||||
|
depends_on "lapack"
|
||||||
|
^^^^^^^^^^^^^^^^^^^ Formulae should use OpenBLAS as the default serial linear algebra library.
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
it "When xcodebuild is called without SYMROOT" do
|
it "When xcodebuild is called without SYMROOT" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
|
Loading…
x
Reference in New Issue
Block a user