Use a custom test class so we can avoid monkeypatching

This commit is contained in:
Jack Nagel 2014-06-18 20:32:51 -05:00
parent 55950bec59
commit 982e9239b8
51 changed files with 70 additions and 68 deletions

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'extend/ARGV'
class ArgvExtensionTests < Test::Unit::TestCase
class ArgvExtensionTests < Homebrew::TestCase
def setup
@argv = [].extend(HomebrewArgvExtension)
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'extend/ENV'
class EnvironmentTests < Test::Unit::TestCase
class EnvironmentTests < Homebrew::TestCase
def setup
@env = {}.extend(EnvActivation)
@env.activate_extensions!
@ -116,7 +116,7 @@ module SharedEnvTests
end
end
class StdenvTests < Test::Unit::TestCase
class StdenvTests < Homebrew::TestCase
include SharedEnvTests
def setup
@ -124,7 +124,7 @@ class StdenvTests < Test::Unit::TestCase
end
end
class SuperenvTests < Test::Unit::TestCase
class SuperenvTests < Homebrew::TestCase
include SharedEnvTests
attr_reader :env, :bin

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'bottles'
class BottleCollectorTests < Test::Unit::TestCase
class BottleCollectorTests < Homebrew::TestCase
def setup
@collector = BottleCollector.new
end

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'formula_installer'
require 'hooks/bottles'
class BottleHookTests < Test::Unit::TestCase
class BottleHookTests < Homebrew::TestCase
class FormulaDouble
def bottle; end
def local_bottle_path; end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'bottles'
class BottleTagTests < Test::Unit::TestCase
class BottleTagTests < Homebrew::TestCase
def test_tag_tiger_ppc
MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
Hardware::CPU.stubs(:type).returns(:ppc)

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'bottle_version'
class BottleVersionParsingTests < Test::Unit::TestCase
class BottleVersionParsingTests < Homebrew::TestCase
def assert_version_detected expected, path
assert_equal expected, BottleVersion.parse(path).to_s
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'build_environment'
class BuildEnvironmentTests < Test::Unit::TestCase
class BuildEnvironmentTests < Homebrew::TestCase
def setup
@env = BuildEnvironment.new
end
@ -49,7 +49,7 @@ class BuildEnvironmentTests < Test::Unit::TestCase
end
end
class BuildEnvironmentDSLTests < Test::Unit::TestCase
class BuildEnvironmentDSLTests < Homebrew::TestCase
def make_instance(&block)
Class.new do
extend BuildEnvironmentDSL

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'build_options'
class BuildOptionsTests < Test::Unit::TestCase
class BuildOptionsTests < Homebrew::TestCase
def setup
args = %w{--with-foo --with-bar --without-qux}
@build = BuildOptions.new(args)

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'checksum'
class ChecksumTests < Test::Unit::TestCase
class ChecksumTests < Homebrew::TestCase
def test_empty?
assert_empty Checksum.new(:sha1, '')
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'test/testball'
class ChecksumTests < Test::Unit::TestCase
class ChecksumTests < Homebrew::TestCase
def assert_checksum_good
assert_nothing_raised { shutup { @_f.brew {} } }
end

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'cleaner'
require 'formula'
class CleanerTests < Test::Unit::TestCase
class CleanerTests < Homebrew::TestCase
include FileUtils
def setup

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'test/testball'
require 'cmd/cleanup'
class CleanupTests < Test::Unit::TestCase
class CleanupTests < Homebrew::TestCase
def test_cleanup
f1 = Class.new(TestBall) { version '0.1' }.new
f2 = Class.new(TestBall) { version '0.2' }.new

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'extend/set'
require 'requirements'
class ComparableSetTests < Test::Unit::TestCase
class ComparableSetTests < Homebrew::TestCase
def setup
@set = ComparableSet.new
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'compilers'
class CompilerQueueTests < Test::Unit::TestCase
class CompilerQueueTests < Homebrew::TestCase
FakeCompiler = Struct.new(:name, :priority)
def setup

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'compilers'
class CompilerSelectorTests < Test::Unit::TestCase
class CompilerSelectorTests < Homebrew::TestCase
class Double
attr_reader :name

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'dependencies'
require 'dependency'
class DependenciesTests < Test::Unit::TestCase
class DependenciesTests < Homebrew::TestCase
def setup
@deps = Dependencies.new
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'dependency'
class DependableTests < Test::Unit::TestCase
class DependableTests < Homebrew::TestCase
def setup
@tags = ["foo", "bar", :build]
@dep = Struct.new(:tags).new(@tags).extend(Dependable)
@ -18,7 +18,7 @@ class DependableTests < Test::Unit::TestCase
end
end
class DependencyTests < Test::Unit::TestCase
class DependencyTests < Homebrew::TestCase
def test_accepts_single_tag
dep = Dependency.new("foo", %w{bar})
assert_equal %w{bar}, dep.tags

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'dependency_collector'
require 'extend/set'
class DependencyCollectorTests < Test::Unit::TestCase
class DependencyCollectorTests < Homebrew::TestCase
def find_dependency(name)
@d.deps.find { |dep| dep.name == name }
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'dependency'
class DependencyExpansionTests < Test::Unit::TestCase
class DependencyExpansionTests < Homebrew::TestCase
def build_dep(name, tags=[], deps=[])
dep = Dependency.new(name.to_s, tags)
dep.stubs(:to_formula).returns(stub(:deps => deps, :name => name))

View File

@ -10,7 +10,7 @@ class ResourceDouble
end
end
class AbstractDownloadStrategyTests < Test::Unit::TestCase
class AbstractDownloadStrategyTests < Homebrew::TestCase
def setup
@name = "foo"
@resource = ResourceDouble.new
@ -36,7 +36,7 @@ class AbstractDownloadStrategyTests < Test::Unit::TestCase
end
end
class VCSDownloadStrategyTests < Test::Unit::TestCase
class VCSDownloadStrategyTests < Homebrew::TestCase
def setup
@resource = ResourceDouble.new("http://example.com/bar")
@strategy = VCSDownloadStrategy
@ -62,7 +62,7 @@ class VCSDownloadStrategyTests < Test::Unit::TestCase
end
end
class DownloadStrategyDetectorTests < Test::Unit::TestCase
class DownloadStrategyDetectorTests < Homebrew::TestCase
def setup
@d = DownloadStrategyDetector.new
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'test/testball'
class FailsWithTests < Test::Unit::TestCase
class FailsWithTests < Homebrew::TestCase
def assert_fails_with(cc)
assert @f.new.fails_with?(cc)
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'test/testball'
class FormulaTests < Test::Unit::TestCase
class FormulaTests < Homebrew::TestCase
include VersionAssertions
def test_formula_instantiation

View File

@ -4,7 +4,7 @@ require 'test/testball'
require 'keg'
class InstallTests < Test::Unit::TestCase
class InstallTests < Homebrew::TestCase
def teardown
HOMEBREW_CACHE.rmtree
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'formula_lock'
class FormulaLockTests < Test::Unit::TestCase
class FormulaLockTests < Homebrew::TestCase
def setup
@lock = FormulaLock.new("foo")
@lock.lock

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'formula_pin'
class FormulaPinTests < Test::Unit::TestCase
class FormulaPinTests < Homebrew::TestCase
class FormulaDouble
def name
"double"

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'formula'
class FormulaSpecSelectionTests < Test::Unit::TestCase
class FormulaSpecSelectionTests < Homebrew::TestCase
def assert_spec_selected(spec)
assert_equal @_f.send(spec), @_f.active_spec
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'formula'
class FormulaValidationTests < Test::Unit::TestCase
class FormulaValidationTests < Homebrew::TestCase
def assert_invalid(attr, &block)
e = assert_raises(FormulaValidationError, &block)
assert_equal attr, e.attr

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'hardware'
class HardwareTests < Test::Unit::TestCase
class HardwareTests < Homebrew::TestCase
def test_hardware_cpu_type
assert [:intel, :ppc].include?(Hardware::CPU.type)
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'extend/string'
class InreplaceTest < Test::Unit::TestCase
class InreplaceTest < Homebrew::TestCase
def test_change_make_var
# Replace flag
s1="OTHER=def\nFLAG = abc\nFLAG2=abc"

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'utils/json'
class JsonSmokeTest < Test::Unit::TestCase
class JsonSmokeTest < Homebrew::TestCase
def test_encode
hash = { "foo" => ["bar", "baz"] }
json = %q|{"foo":["bar","baz"]}|

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'keg'
require 'stringio'
class LinkTests < Test::Unit::TestCase
class LinkTests < Homebrew::TestCase
include FileUtils
def setup

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'requirements/language_module_dependency'
class LanguageModuleDependencyTests < Test::Unit::TestCase
class LanguageModuleDependencyTests < Homebrew::TestCase
def assert_deps_fail(spec)
l = LanguageModuleDependency.new(*spec.shift.reverse)
assert !l.satisfied?

View File

@ -1,6 +1,6 @@
require 'testing_env'
class MachOPathnameTests < Test::Unit::TestCase
class MachOPathnameTests < Homebrew::TestCase
def dylib_path(name)
Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.dylib")
end
@ -161,7 +161,7 @@ class ArchitectureListExtensionTests < MachOPathnameTests
end
end
class TextExecutableTests < Test::Unit::TestCase
class TextExecutableTests < Homebrew::TestCase
attr_reader :pn
def setup

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'requirements/mpi_dependency'
class MPIDependencyTests < Test::Unit::TestCase
class MPIDependencyTests < Homebrew::TestCase
def test_initialize_untangles_tags_and_wrapper_symbols
wrappers = [:cc, :cxx, :f77]
tags = [:optional, 'some-other-tag']

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'options'
class OptionTests < Test::Unit::TestCase
class OptionTests < Homebrew::TestCase
def setup
@option = Option.new("foo")
end
@ -42,7 +42,7 @@ class OptionTests < Test::Unit::TestCase
end
end
class OptionsTests < Test::Unit::TestCase
class OptionsTests < Homebrew::TestCase
def setup
@options = Options.new
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'patch'
class PatchTests < Test::Unit::TestCase
class PatchTests < Homebrew::TestCase
def test_create_simple
patch = Patch.create(:p2)
assert_kind_of ExternalPatch, patch
@ -51,7 +51,7 @@ class PatchTests < Test::Unit::TestCase
end
end
class LegacyPatchTests < Test::Unit::TestCase
class LegacyPatchTests < Homebrew::TestCase
def test_patch_single_string
patches = Patch.normalize_legacy_patches("http://example.com/patch.diff")
assert_equal 1, patches.length

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'formula'
require 'testball'
class PatchingTests < Test::Unit::TestCase
class PatchingTests < Homebrew::TestCase
PATCH_URL_A = "file://#{TEST_DIRECTORY}/patches/noop-a.diff"
PATCH_URL_B = "file://#{TEST_DIRECTORY}/patches/noop-b.diff"

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'tmpdir'
require 'extend/pathname'
class PathnameExtensionTests < Test::Unit::TestCase
class PathnameExtensionTests < Homebrew::TestCase
include FileUtils
def setup

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'pkg_version'
class PkgVersionTests < Test::Unit::TestCase
class PkgVersionTests < Homebrew::TestCase
def v(version)
PkgVersion.parse(version)
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'debrew/raise_plus'
class RaisePlusTests < Test::Unit::TestCase
class RaisePlusTests < Homebrew::TestCase
include RaisePlus
def test_raises_runtime_error_when_no_args

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'requirement'
class RequirementTests < Test::Unit::TestCase
class RequirementTests < Homebrew::TestCase
def test_accepts_single_tag
dep = Requirement.new(%w{bar})
assert_equal %w{bar}, dep.tags

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'resource'
class ResourceTests < Test::Unit::TestCase
class ResourceTests < Homebrew::TestCase
include VersionAssertions
def setup

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'software_spec'
class SoftwareSpecTests < Test::Unit::TestCase
class SoftwareSpecTests < Homebrew::TestCase
include VersionAssertions
def setup
@ -87,7 +87,7 @@ class SoftwareSpecTests < Test::Unit::TestCase
end
end
class HeadSoftwareSpecTests < Test::Unit::TestCase
class HeadSoftwareSpecTests < Homebrew::TestCase
include VersionAssertions
def setup
@ -103,7 +103,7 @@ class HeadSoftwareSpecTests < Test::Unit::TestCase
end
end
class BottleSpecificationTests < Test::Unit::TestCase
class BottleSpecificationTests < Homebrew::TestCase
def setup
@spec = BottleSpecification.new
end

View File

@ -4,7 +4,7 @@ require 'formula'
require 'cxxstdlib'
require 'tab'
class CxxStdlibTests < Test::Unit::TestCase
class CxxStdlibTests < Homebrew::TestCase
def setup
@clang = CxxStdlib.new(:libstdcxx, :clang)
@gcc = CxxStdlib.new(:libstdcxx, :gcc)

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'extend/string'
class StringTest < Test::Unit::TestCase
class StringTest < Homebrew::TestCase
def test_undent
undented = <<-EOS.undent
hi

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'cmd/update'
require 'yaml'
class UpdaterTests < Test::Unit::TestCase
class UpdaterTests < Homebrew::TestCase
class UpdaterMock < ::Updater
def initialize(*args)
super

View File

@ -1,6 +1,6 @@
require 'testing_env'
class UtilTests < Test::Unit::TestCase
class UtilTests < Homebrew::TestCase
def test_put_columns_empty
# Issue #217 put columns with new results fails.
puts_columns []

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'version'
require 'os/mac/version'
class MacOSVersionTests < Test::Unit::TestCase
class MacOSVersionTests < Homebrew::TestCase
def setup
@v = MacOS::Version.new("10.7")
end

View File

@ -1,7 +1,7 @@
require 'testing_env'
require 'version'
class VersionTests < Test::Unit::TestCase
class VersionTests < Homebrew::TestCase
include VersionAssertions
def test_accepts_objects_responding_to_to_str
@ -28,7 +28,7 @@ class VersionTests < Test::Unit::TestCase
end
end
class VersionComparisonTests < Test::Unit::TestCase
class VersionComparisonTests < Homebrew::TestCase
include VersionAssertions
def test_version_comparisons
@ -95,7 +95,7 @@ class VersionComparisonTests < Test::Unit::TestCase
end
end
class VersionParsingTests < Test::Unit::TestCase
class VersionParsingTests < Homebrew::TestCase
include VersionAssertions
def test_pathname_version

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'extend/set'
require 'requirements/x11_dependency'
class X11DependencyTests < Test::Unit::TestCase
class X11DependencyTests < Homebrew::TestCase
def test_eql_instances_are_eql
x = X11Dependency.new
y = X11Dependency.new

View File

@ -113,11 +113,13 @@ module Test::Unit::Assertions
end unless method_defined?(:assert_empty)
end
class Test::Unit::TestCase
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
module Homebrew
class TestCase < ::Test::Unit::TestCase
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
def formula(name="formula_name", path=Formula.path(name), &block)
@_f = Class.new(Formula, &block).new(name, path)
def formula(name="formula_name", path=Formula.path(name), &block)
@_f = Class.new(Formula, &block).new(name, path)
end
end
end