aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-06-26 22:08:54 -0500
committerJack Nagel2013-06-26 22:18:13 -0500
commit919aac0b8969550e1db4a21d10ab404bff88e4ed (patch)
tree1cd2201a0a5f3fff8ca714137e72b51a88505efb /Library
parent1cd31496775ab8cf1051e22367c8ab6184bb3b97 (diff)
downloadbrew-919aac0b8969550e1db4a21d10ab404bff88e4ed.tar.bz2
Add syntax sugar for MPIDependency
Closes Homebrew/homebrew#20797.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/audit.rb4
-rw-r--r--Library/Homebrew/dependency_collector.rb1
-rw-r--r--Library/Homebrew/requirements/mpi_dependency.rb9
-rw-r--r--Library/Homebrew/test/test_mpi_dependency.rb12
4 files changed, 21 insertions, 5 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index dada06f1f..79df38599 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -166,9 +166,9 @@ class FormulaAuditor
when 'open-mpi', 'mpich2'
problem <<-EOS.undent
There are multiple conflicting ways to install MPI. Use an MPIDependency:
- depends_on MPIDependency.new(<lang list>)
+ depends_on :mpi => [<lang list>]
Where <lang list> is a comma delimited list that can include:
- :cc, :cxx, :f90, :f77
+ :cc, :cxx, :f77, :f90
EOS
end
end
diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb
index 77370a3b9..e11be462d 100644
--- a/Library/Homebrew/dependency_collector.rb
+++ b/Library/Homebrew/dependency_collector.rb
@@ -94,6 +94,7 @@ class DependencyCollector
when :mysql then MysqlDependency.new(tags)
when :postgresql then PostgresqlDependency.new(tags)
when :fortran then FortranDependency.new(tags)
+ when :mpi then MPIDependency.new(*tags)
when :tex then TeXDependency.new(tags)
when :clt then CLTDependency.new(tags)
when :arch then ArchRequirement.new(tags)
diff --git a/Library/Homebrew/requirements/mpi_dependency.rb b/Library/Homebrew/requirements/mpi_dependency.rb
index 28a03d566..2baf9a904 100644
--- a/Library/Homebrew/requirements/mpi_dependency.rb
+++ b/Library/Homebrew/requirements/mpi_dependency.rb
@@ -13,11 +13,14 @@ class MPIDependency < Requirement
env :userpaths
- def initialize *lang_list
- @lang_list = lang_list
+ # This method must accept varargs rather than an array for
+ # backwards compatibility with formulae that call it directly.
+ def initialize(*tags)
@non_functional = []
@unknown_langs = []
- super()
+ @lang_list = [:cc, :cxx, :f77, :f90] & tags
+ tags -= @lang_list
+ super(tags)
end
def mpi_wrapper_works? compiler
diff --git a/Library/Homebrew/test/test_mpi_dependency.rb b/Library/Homebrew/test/test_mpi_dependency.rb
new file mode 100644
index 000000000..06f158805
--- /dev/null
+++ b/Library/Homebrew/test/test_mpi_dependency.rb
@@ -0,0 +1,12 @@
+require 'testing_env'
+require 'requirements/mpi_dependency'
+
+class MPIDependencyTests < Test::Unit::TestCase
+ def test_initialize_untangles_tags_and_wrapper_symbols
+ wrappers = [:cc, :cxx, :f77]
+ tags = [:optional, 'some-other-tag']
+ dep = MPIDependency.new(*wrappers + tags)
+ assert_equal wrappers, dep.lang_list
+ assert_equal tags, dep.tags
+ end
+end