Commit Graph
205 Commits
Author SHA1 Message Date
Jack Nagel ffa91790b0 Extract formula locks into a class 2013-02-09 18:19:50 -06:00
Jack Nagel 117470b7c9 LanguageModuleDependency: foward args to superclass initalizer 2013-02-08 00:12:49 -06:00
Jack Nagel b34f7727bd MacOSVersion -> MacOS::Version 2013-02-07 12:39:54 -06:00
Jack Nagel 9cb6939cfd Flesh out MacOSVersion tests 2013-02-07 12:35:15 -06:00
Jack Nagel 1372e53fe8 Add tests for raise monkey patch 2013-02-06 19:04:43 -06:00
Jack Nagel 7522e4883b Proper recursive expansion of requirements with filtering
Expand requirements recursively while applying the same optional? and
recommended? filters that dependencies are run through. Options
generated by requirements are now checked against the correct list of
requirements, eliminating the temporary "best guess" logic in the
installer.
2013-01-31 15:40:06 -06:00
Jack Nagel 8df3f14d15 Create proxy classes for "partial" X11 dependencies
When a formula's dependency tree contains more than one X11 dependency,
they are de-duplicated by comparing the min_version attribute. However,
this can result in broken dependency trees if one of the X11Dependency
objects was actually specified as e.g. `:libpng`.

In practice, this only matters when one or more of the dependencies has
additional metadata that makes it distinct from the rest, i.e. an
:optional or :recommended tag.

To combat this, make these special, "partial" X11 dependencies instances
of different classes so that they are not de-duped.

It will still be necessary, at the time when requirements are expanded
by the installer, to de-duplicate any remaining X11 dependencies after
applying the optional/recommended filters in order to avoid duplicated
modifications to the environment (as ENV.x11 is not idempotent).

c.f. #17369.
2013-01-31 15:39:26 -06:00
Mike McQuaid 1da2d5dd92 Remove MD5 support.
Closes #17317.
2013-01-30 22:36:12 -08:00
Mike McQuaid 063d5e5b78 jpeg: support version format. 2013-01-30 21:29:19 -08:00
Jack Nagel 7bec7abecd Fix passing multiple switches as a single word to the build
Fixes #17434.
2013-01-30 11:09:33 -06:00
Mike McQuaid 3318b08a2e Don't use underscores in (new) bottle filenames.
Closes #14270
2013-01-29 17:14:09 -08:00
Mike McQuaid e9eac42daa Cleanup old bottle syntax. 2013-01-29 17:14:00 -08:00
Jack Nagel f5d40bf8e3 DependencyCollector: return created dep from #add 2013-01-28 10:35:14 -06:00
Jack Nagel ca134adfbb Allow specifying a name attribute for X11Dependency 2013-01-28 10:35:14 -06:00
Jack Nagel d6ae459e63 Update require 2013-01-27 16:29:19 -06:00
Jack Nagel bf1ce53366 Split dependency classes into separate files 2013-01-26 20:30:05 -06:00
Jack Nagel 7e8d335789 Fix Dependencies -> Array conversion 2013-01-26 12:14:51 -06:00
Jack Nagel 97310a0fed Tag Xcode and CLT requirements as build-time
This way they can be skipped when installing bottles.
2013-01-26 12:14:50 -06:00
Jack Nagel 775184240d FormulaInstaller: construct new ARGV from an Options collection
The array of options that is passed to the spawned build process is a
combination of the current ARGV, options passed in by a dependent
formula, and an existing install receipt. The objects that are
interacting here each expect the resulting collection to have certain
properties, and the expectations are not consistent.

Clear up this confusing mess by only dealing with Options collections.
This keeps our representation of options uniform across the codebase.

We can remove BuildOptions dependency on HomebrewArgvExtension, which
allows us to pass any Array-like collection to Tab.create. The only
other site inside of FormulaInstaller that uses the array is the #exec
call, and there it is splatted and thus we can substitute our Options
collection there as well.
2013-01-26 12:14:47 -06:00
Jack Nagel 7a8935455b FormulaInstaller: allow formulae to pass options to deps
Formulae can now pass build options to dependencies. The following
syntax is supported:

  depends_on 'foo' => 'with-bar'
  depends_on 'foo' => ['with-bar', 'with-baz']

If a dependency is already installed but lacks the required build
options, an exception is raised. Eventually we may be able to just stash
the existing keg and reinstall it with the combined set of used_options
and passed options, but enabling that is left for another day.
2013-01-26 12:14:46 -06:00
Adam Vandenberg 4d2940e372 Add support for optional and recommended deps
Optional deps are not installed by default but generate a corresponding
"with-foo" option for the formula. Recommended deps _are_ installed by
default, and generate a corresponding "without-foo" option.
2013-01-26 12:14:45 -06:00
Jack Nagel a875e09217 Tests for BuildOptions 2013-01-26 11:37:02 -06:00
Jack Nagel 8f5ea8eea6 Refactor option handling internals
Currently we handle options in several ways, and it is hard to remember
what code needs an option string ("--foo"), what needs only the name
("foo") and what needs an Option object.

Now that Option objects can act as strings and be converted to JSON, we
can start using them instead of passing around strings between Formula
objects, Tab objects, and ARGV-style arrays.

The Options class is a special collection that can be queried for the
inclusion of options in any form: '--foo', 'foo', or Option.new("foo").
2013-01-26 11:37:01 -06:00
Mike McQuaid b5069edcbd brew-test: use SHA-1 in all testballs. 2013-01-26 13:10:06 +00:00
Jack Nagel 21efd0803c Infer path to be added for requirements that search PATH
When a requirement is specified like:

  satisfy { which "foo" }

There is no reason that we should inject all of ENV.userpaths! into the
build environment. Instead, infer the directory to be added to PATH from
the Pathname that is returned.

This is another step towards condensing the "which program" requirements
down into a one-liner DSL element.
2013-01-22 14:59:10 -06:00
Jack Nagel 0d28b0566d requirements: enable userpaths by default during evaluation 2013-01-22 14:11:21 -06:00
Jack Nagel ad9d41a7fe Add tests for ARGV.filter_for_dependencies 2013-01-22 13:57:13 -06:00
Jack Nagel 36715c0dbd Add tests for ENV.with_build_environment 2013-01-22 13:57:07 -06:00
Jack Nagel b48e89cbb2 Allow satisfied? to be specified in a block
Instead of overriding #satisfied?, Requirement subclasses can specify
the condition in a block:

  satisfy do
    some_condition?
  end

The contents of the block are evaluated in the context of the instance,
and so have access to instance variables and instance methods as before.
Additionally, it is wrapped in an ENV.with_build_environment block. This
can be disabled by passing :build_env => false to satisfy:

  satisfy :build_env => false do
    some_condition?
  end
2013-01-21 17:24:12 -06:00
Jack Nagel 8bb496febf Object#instance_exec for Ruby 1.8.6
Not thread safe! But I don't think we care.

We want to evaluate the env DSL block in the context of ENV for asthetic
reasons, but we also want access to methods on the requirement instance.
We can use #instance_exec to pass the requirement itself into the block:

  class Foo < Requirement
    env do |req|
      append 'PATH', req.some_path
    end

    def some_path
      which 'something'
    end
  end

Also add a simplified version of Object#instance_exec for Ruby 1.8.6.
2013-01-21 17:24:11 -06:00
Jack Nagel cfdc7efef9 Allow env DSL to take a block
In addition to

  env :userpaths
  env :std

requirements can now do

  env do
    append 'PATH', '/some/path/to/bin'
    # and more
  end
2013-01-21 17:24:10 -06:00
Jack Nagel 3270fd2cd9 ENV.with_build_environment 2013-01-21 17:24:10 -06:00
Jack Nagel 483ac48734 tests: add mocha mocking library 2013-01-21 17:14:16 -06:00
Jack Nagel 652716423d Fix JSON smoke test
- Simplify encoding example because hashes are unordered.
 - Fix broken require
2013-01-17 22:29:20 -06:00
Jack Nagel e21156719f Update multi_json to 1.5.0
This contains updates to the OkJson library that allow objects to define
to_json for serialization, and this will be used in the upcoming options
and deps work.
2013-01-17 21:39:43 -06:00
Jack Nagel c9f3be3e3d Tests for Requirement DSL 2013-01-15 18:55:10 -06:00
Jack Nagel a8e2e6e53b Tests for BuildEnvironment 2013-01-15 18:55:10 -06:00
Jack Nagel 693e9e706a Split up dependency test coverage
The DependencyCollector tests are really integration tests, while the
rest are closer to real unit tests. Split them up so that the tests can
be run in isolation on a per-class basis.
2013-01-13 21:01:15 -06:00
Jack Nagel 1e0c0cfe16 Remove <=> from Dependency interface
It is important that dep equality corresponds to the name attribute, but
we may want to use the Comparable interface to sort them by installation
order in the future. Code that needs to sort them alphabetically should
just use sort_by.
2013-01-13 21:01:15 -06:00
Jack Nagel 514830d856 Beef up deps tests 2013-01-12 21:20:46 -06:00
Jack Nagel 296c31b717 Define HOMEBREW_LIBRARY for tests 2013-01-12 17:51:29 -06:00
Jack Nagel c48c568a3e Remove Array subclassing
Inheriting from Array (and other core types) is problematic:

  - It exposes a very wide interface with many methods that are not
    really relevant to the subclass.
  - It can cause some weird side effects, as many Array operations are
    in C and have hardcoded return values; for example, combining two
    array subclasses returns a new Array instead of the subclass.

Avoid these problems using delegation and the Enumerable module where
applicable.
2013-01-07 14:32:14 -06:00
Mike McQuaid ee17db950a Add Apache version style test. 2013-01-01 17:30:57 +00:00
Mike McQuaid e4b5b88bd9 Add another Erlang version format. 2012-12-16 14:35:41 +00:00
Jack Nagel 5d645a6ef6 Fix broken brew cleanup tests 2012-12-01 14:42:30 -06:00
Jack Nagel 37a1ab7237 tests: add profiling support
`rake profile` will run ruby-prof on the test suite if the ruby-prof gem
is installed.
2012-11-17 22:59:06 -06:00
Jack Nagel fbfc30fe1c tests: define assert_empty for Ruby <= 1.8
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 22:09:23 -05:00
Jack Nagel 6ec361aa12 ComparableSet#merge returns self
Set#merge is supposed to return self, and Formula#recursive_requirements
depended on this being true.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 15:54:55 -05:00
Jack Nagel 511138f863 test_cleaner: add missing require
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 14:29:43 -05:00
Jack Nagel fb490be58b Allow requirements to record tags
To allow

  depends_on :x11 => :optional

and friends to work as expected, make requirements record any tags and
add special handling to the X11Dependency to record both a minimum
version and additional tags.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 14:28:53 -05:00