Switch to Minitest
This commit is contained in:
parent
89d74ec475
commit
06305e6211
@ -3,7 +3,7 @@ require 'rake/testtask'
|
||||
|
||||
TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__))
|
||||
TEST_FILES = Dir["#{TEST_DIRECTORY}/test_*.rb"]
|
||||
GEM_DEPS = ['mocha']
|
||||
GEM_DEPS = %w[mocha minitest]
|
||||
|
||||
task :default => :test
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ class ChecksumTests < Homebrew::TestCase
|
||||
|
||||
a = Checksum.new(:sha1, 'deadbeef'*5)
|
||||
b = Checksum.new(:sha1, 'feedface'*5)
|
||||
assert_not_equal a, b
|
||||
refute_equal a, b
|
||||
|
||||
a = Checksum.new(:sha1, 'deadbeef'*5)
|
||||
b = Checksum.new(:sha256, 'deadbeef'*5)
|
||||
assert_not_equal a, b
|
||||
refute_equal a, b
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ class CompilerSelectorTests < Homebrew::TestCase
|
||||
|
||||
def test_all_compiler_failures
|
||||
@f << :clang << :llvm << :gcc << 'gcc-4.8'
|
||||
assert_raise(CompilerSelectionError) { actual_cc }
|
||||
assert_raises(CompilerSelectionError) { actual_cc }
|
||||
end
|
||||
|
||||
def test_no_compiler_failures
|
||||
@ -111,7 +111,7 @@ class CompilerSelectorTests < Homebrew::TestCase
|
||||
def test_missing_gcc
|
||||
@versions = CompilerVersions.new( :gcc_build_version => nil)
|
||||
@f << :clang << :llvm << 'gcc-4.8'
|
||||
assert_raise(CompilerSelectionError) { actual_cc }
|
||||
assert_raises(CompilerSelectionError) { actual_cc }
|
||||
end
|
||||
|
||||
def test_missing_llvm_and_gcc
|
||||
@ -120,6 +120,6 @@ class CompilerSelectorTests < Homebrew::TestCase
|
||||
:llvm_build_version => nil
|
||||
)
|
||||
@f << :clang << 'gcc-4.8'
|
||||
assert_raise(CompilerSelectionError) { actual_cc }
|
||||
assert_raises(CompilerSelectionError) { actual_cc }
|
||||
end
|
||||
end
|
||||
|
||||
@ -74,7 +74,7 @@ class DependenciesTests < Homebrew::TestCase
|
||||
|
||||
b << Dependency.new("bar", [:optional])
|
||||
|
||||
assert_not_equal a, b
|
||||
refute_equal a, b
|
||||
assert !a.eql?(b)
|
||||
end
|
||||
end
|
||||
|
||||
@ -45,7 +45,7 @@ class DependencyTests < Homebrew::TestCase
|
||||
bar = Dependency.new("bar")
|
||||
assert_equal foo1, foo2
|
||||
assert foo1.eql?(foo2)
|
||||
assert_not_equal foo1, bar
|
||||
refute_equal foo1, bar
|
||||
assert !foo1.eql?(bar)
|
||||
end
|
||||
end
|
||||
|
||||
@ -32,7 +32,7 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase
|
||||
def test_expand_safe_system_args_does_not_mutate_argument
|
||||
result = @strategy.expand_safe_system_args(@args)
|
||||
assert_equal %w{foo bar baz}, @args
|
||||
assert_not_same @args, result
|
||||
refute_same @args, result
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -131,15 +131,15 @@ class FormulaTests < Homebrew::TestCase
|
||||
def test_inequality
|
||||
x = TestBall.new("foo")
|
||||
y = TestBall.new("bar")
|
||||
assert_not_equal x, y
|
||||
assert_not_equal y, x
|
||||
assert_not_equal x.hash, y.hash
|
||||
refute_equal x, y
|
||||
refute_equal y, x
|
||||
refute_equal x.hash, y.hash
|
||||
assert !x.eql?(y)
|
||||
assert !y.eql?(x)
|
||||
end
|
||||
|
||||
def test_comparison_with_non_formula_objects_does_not_raise
|
||||
assert_not_equal TestBall.new, Object.new
|
||||
refute_equal TestBall.new, Object.new
|
||||
end
|
||||
|
||||
def test_class_naming
|
||||
|
||||
@ -49,14 +49,14 @@ class LinkTests < Homebrew::TestCase
|
||||
|
||||
def test_linking_fails_when_already_linked
|
||||
@keg.link
|
||||
assert_raise Keg::AlreadyLinkedError do
|
||||
assert_raises Keg::AlreadyLinkedError do
|
||||
shutup { @keg.link }
|
||||
end
|
||||
end
|
||||
|
||||
def test_linking_fails_when_files_exist
|
||||
touch HOMEBREW_PREFIX/"bin/helloworld"
|
||||
assert_raise Keg::ConflictError do
|
||||
assert_raises Keg::ConflictError do
|
||||
shutup { @keg.link }
|
||||
end
|
||||
end
|
||||
|
||||
@ -15,7 +15,7 @@ class LanguageModuleDependencyTests < Homebrew::TestCase
|
||||
def test_unique_deps_are_not_eql
|
||||
x = LanguageModuleDependency.new(:node, "less")
|
||||
y = LanguageModuleDependency.new(:node, "coffee-script")
|
||||
assert_not_equal x.hash, y.hash
|
||||
refute_equal x.hash, y.hash
|
||||
assert !x.eql?(y)
|
||||
assert !y.eql?(x)
|
||||
end
|
||||
|
||||
@ -18,7 +18,7 @@ class OptionTests < Homebrew::TestCase
|
||||
foo = Option.new("foo")
|
||||
bar = Option.new("bar")
|
||||
assert_equal foo, @option
|
||||
assert_not_equal bar, @option
|
||||
refute_equal bar, @option
|
||||
assert @option.eql?(foo)
|
||||
assert !@option.eql?(bar)
|
||||
assert_operator bar, :<, foo
|
||||
|
||||
@ -132,7 +132,7 @@ class RequirementTests < Homebrew::TestCase
|
||||
|
||||
def test_not_eql
|
||||
a, b = Requirement.new([:optional]), Requirement.new
|
||||
assert_not_equal a.hash, b.hash
|
||||
refute_equal a.hash, b.hash
|
||||
assert !a.eql?(b)
|
||||
assert !b.eql?(a)
|
||||
end
|
||||
|
||||
@ -14,7 +14,7 @@ class X11DependencyTests < Homebrew::TestCase
|
||||
def test_not_eql_when_hashes_differ
|
||||
x = X11Dependency.new("foo")
|
||||
y = X11Dependency.new
|
||||
assert_not_equal x.hash, y.hash
|
||||
refute_equal x.hash, y.hash
|
||||
assert !x.eql?(y)
|
||||
assert !y.eql?(x)
|
||||
end
|
||||
|
||||
@ -5,6 +5,7 @@ $:.push(File.expand_path(__FILE__+'/../..'))
|
||||
require 'extend/module'
|
||||
require 'extend/fileutils'
|
||||
require 'extend/pathname'
|
||||
require 'extend/ARGV'
|
||||
require 'extend/string'
|
||||
require 'extend/symbol'
|
||||
require 'extend/enumerable'
|
||||
@ -56,22 +57,14 @@ at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
||||
# Test fixtures and files can be found relative to this path
|
||||
TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
require 'test/unit' # must be after at_exit
|
||||
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
|
||||
ARGV.extend(HomebrewArgvExtension)
|
||||
|
||||
begin
|
||||
require 'rubygems'
|
||||
require 'mocha/setup'
|
||||
require "rubygems"
|
||||
require "minitest/autorun"
|
||||
require "mocha/setup"
|
||||
rescue LoadError
|
||||
warn 'The mocha gem is required to run some tests, expect failures'
|
||||
end
|
||||
|
||||
module Test::Unit::Assertions
|
||||
def assert_empty(obj, msg=nil)
|
||||
assert_respond_to(obj, :empty?, msg)
|
||||
assert(obj.empty?, msg)
|
||||
end unless method_defined?(:assert_empty)
|
||||
abort "Run `rake deps` or install the mocha and minitest gems before running the tests"
|
||||
end
|
||||
|
||||
module Homebrew
|
||||
@ -97,7 +90,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
class TestCase < ::Test::Unit::TestCase
|
||||
class TestCase < ::Minitest::Test
|
||||
include VersionAssertions
|
||||
|
||||
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
|
||||
@ -120,5 +113,9 @@ module Homebrew
|
||||
$stdout.reopen(out)
|
||||
end
|
||||
end
|
||||
|
||||
def assert_nothing_raised
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user