3482 Commits

Author SHA1 Message Date
Mike McQuaid
bb8c22c90d brew-test: use SHA-1 in all testballs. 2013-01-26 13:10:06 +00:00
Jack Nagel
3725f771de 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
b9e5f1229b requirements: enable userpaths by default during evaluation 2013-01-22 14:11:21 -06:00
Jack Nagel
aed70e50e8 Add tests for ARGV.filter_for_dependencies 2013-01-22 13:57:13 -06:00
Jack Nagel
2bacf38833 Add tests for ENV.with_build_environment 2013-01-22 13:57:07 -06:00
Jack Nagel
452e79cf68 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
2503cedf2c 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
c53af42117 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
d06824c357 ENV.with_build_environment 2013-01-21 17:24:10 -06:00
Jack Nagel
1f505af566 tests: add mocha mocking library 2013-01-21 17:14:16 -06:00
Jack Nagel
b568742428 Fix JSON smoke test
- Simplify encoding example because hashes are unordered.
 - Fix broken require
2013-01-17 22:29:20 -06:00
Jack Nagel
997f9d0075 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
968782a31b Tests for Requirement DSL 2013-01-15 18:55:10 -06:00
Jack Nagel
175820af69 Tests for BuildEnvironment 2013-01-15 18:55:10 -06:00
Jack Nagel
fe4f39dcee 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
e629f14d56 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
900a5fec2d Beef up deps tests 2013-01-12 21:20:46 -06:00
Jack Nagel
09b77a7785 Define HOMEBREW_LIBRARY for tests 2013-01-12 17:51:29 -06:00
Jack Nagel
429caf69a9 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
df2cdc681a Add Apache version style test. 2013-01-01 17:30:57 +00:00
Mike McQuaid
7d61bfe88f Add another Erlang version format. 2012-12-16 14:35:41 +00:00
Jack Nagel
21dfef7ec2 Fix broken brew cleanup tests 2012-12-01 14:42:30 -06:00
Jack Nagel
8cc3479fb7 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
267ffddbd3 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
762c355b30 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
07d9adc295 test_cleaner: add missing require
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 14:29:43 -05:00
Jack Nagel
d1f754c02e 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
Misty De Meo
18f5bf1092 Fix Keg tests
* unreverse expected/actuals
* don't assume linked file order is guaranteed - it wasn't!
2012-10-23 17:10:12 -05:00
Misty De Meo
447f78c0d2 brew ln --force is now brew ln --overwrite
* Renames --force to --overwrite, freeing up brew ln --force for Homebrew/homebrew#13349
* Changes --dry-run to preview linking by default, rather than
  overwriting. An overwrite dry-run can be simulated via both
  --dry-run --overwrite
* Adds some basic Keg tests
2012-10-20 21:00:46 -05:00
Mike McQuaid
425440de3b Add Jenkins version matching (and test). 2012-10-16 10:31:35 +01:00
Jack Nagel
39ec66614b Test coverage for DownloadStrategyDetector
While at it, make it use class methods instead; no reason to instantiate
an object for this.

Eventually there should be some functional tests for the individual
strategies as well.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-15 17:45:48 -05:00
Misty De Meo
bbfb6400c7 Manage Requirements using ComparableSet
ComparableSet only allows a single object of a given class,
choosing the object with the greatest value. This was mainly created
for Requirements, so that, e.g., two X11Dependencies of differing
strictness don't both end up in the same requirement set.

Fixes Homebrew/homebrew#15240.
2012-10-15 09:46:29 -05:00
Jack Nagel
1027093eae tests: set newly-visible global constants
The changes to error ouput and logging require a few more things to be
visible during installation tests.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-29 12:14:57 -05:00
Jack Nagel
7e6c274f81 test_bucket: don't try to clean a non-existent keg
It is a no-op under Ruby 1.8 but Pathname#find raises ENOENT if the
directory doesn't exist under 1.9. But we really shouldn't try to clean
a non-existent keg anyway, and FormulaInstaller will have bailed out
long before the clean step if the keg doesn't exist, so lets just not
even test this condition; the cleaner has its own tests anyway.

Alternatively we can adjust the cleaner to handle this case, but I don't
see much value in that.

n.b. with this, the tests now pass under 1.9.3 (for me), which is nice
because I often run them on that version inadvertently.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-27 17:50:13 -05:00
Jack Nagel
1b2e19d425 Adjust test expectation for 'LD'
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-27 16:24:04 -05:00
Jack Nagel
6ebcccdcc5 Make FileUtils extension available globally
Now that we are monkeypatching copy_metadata, we should load our
extension up front for consistency.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-27 16:22:01 -05:00
Jack Nagel
33233f5039 Stop warning in ENV.x11
It has been long enough since `depends_on :x11` was introduced that we
can make it the caller's responsibility to ensure X11 is present before
invoking ENV.x11, so stop outputting a warning.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-03 21:04:49 -05:00
Jack Nagel
be8827d8a4 tests: avoid unnecessary chdir
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-30 00:10:02 -05:00
Jack Nagel
b7bdd2f578 tests: support "rake rcov" if rcov is installed
If the rcov gem is installed, `rake rcov` will generate a test coverage
report in the coverage directory.

I picked rcov because it is 1.8 compatible. But it could easily be
swapped out for another coverage tool.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-29 15:56:36 -05:00
Jack Nagel
8abfee7d9c tests: adjust expectations for 'opt' directory
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-29 15:37:58 -05:00
Jack Nagel
c350fad07e tests: adjust test_bottle_spec_selection for new bottle code
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-25 16:03:35 -05:00
Mike McQuaid
90010f4602 Fix tests and NoMethodError with no X11 installed. 2012-08-25 10:21:48 -07:00
Mike McQuaid
d9a18d4c1e erlang: fix version detection and bottles. 2012-08-25 10:21:48 -07:00
Jack Nagel
f069ebd0df Version: make MacOSVersion comparison more robust
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-23 18:16:08 -05:00
Jack Nagel
3081e69783 Test version interrogation methods
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-18 16:07:14 -05:00
Jack Nagel
23cc14f9a1 Simplify version comparison tests
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-18 16:03:43 -05:00
Jack Nagel
c924de7086 Version: build-in devel version comparisons
The heuristic used by the default version comparison is simple. A
version string is scanned for strings of digits, split into an array of
these strings, and then an element-wise comparison is done.

This fails when presented with something like

  Version.new("1.0.0beta7") <=> Version.new("1.0.0")

because the first three digits match, and the fourth digit of the
receiver (7) is greater than the assumed fourth digit of the parameter
(0).

Fix this by defining an element-wise comparator on a new VersionElement
class. This allows us to correctly compare "alpha", "beta", and "rc"
style version strings, and keeps the logic out of the main version
comparison.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-08-18 15:53:04 -05:00
Jack Nagel
b8231fc5f3 Add custom comparator for MacOS.version
This will allow us to do comparisons like

  if MacOS.version >= :lion

and hopefully deprecate the MacOS.<name>? family of methods, which are
counterinitutive.
2012-08-18 11:13:54 -05:00
Jack Nagel
2ff6c40735 Add support for custom version schemes
A version scheme is a class that inherits from Version and reimplements
Version#<=>. This will allow formulae to specify a custom comparison
method that will be used instead of the default, for cases where the
default is insufficient.
2012-08-18 11:12:09 -05:00
Jack Nagel
e57122780e Add Version#detected_from_url? 2012-08-18 11:12:09 -05:00