Refactor patching tests
This commit is contained in:
parent
f14e38de2f
commit
6dd242e2df
@ -21,51 +21,41 @@ class PatchingTests < Homebrew::TestCase
|
|||||||
@_f.patchlist.select(&:external?).each(&:clear_cache)
|
@_f.patchlist.select(&:external?).each(&:clear_cache)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_patched(path)
|
def assert_patched(formula)
|
||||||
s = File.read(path)
|
shutup do
|
||||||
refute_includes s, "NOOP", "#{path} was not patched as expected"
|
formula.brew do
|
||||||
assert_includes s, "ABCD", "#{path} was not patched as expected"
|
formula.patch
|
||||||
|
s = File.read("libexec/NOOP")
|
||||||
|
refute_includes s, "NOOP", "libexec/NOOP was not patched as expected"
|
||||||
|
assert_includes s, "ABCD", "libexec/NOOP was not patched as expected"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_single_patch
|
def test_single_patch
|
||||||
shutup do
|
assert_patched formula {
|
||||||
formula do
|
|
||||||
def patches
|
def patches
|
||||||
PATCH_URL_A
|
PATCH_URL_A
|
||||||
end
|
end
|
||||||
end.brew do |f|
|
}
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_single_patch_dsl
|
def test_single_patch_dsl
|
||||||
shutup do
|
assert_patched formula {
|
||||||
formula do
|
|
||||||
patch do
|
patch do
|
||||||
url PATCH_URL_A
|
url PATCH_URL_A
|
||||||
sha1 "fa8af2e803892e523fdedc6b758117c45e5749a2"
|
sha1 "fa8af2e803892e523fdedc6b758117c45e5749a2"
|
||||||
end
|
end
|
||||||
end.brew do |f|
|
}
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_single_patch_dsl_with_strip
|
def test_single_patch_dsl_with_strip
|
||||||
shutup do
|
assert_patched formula {
|
||||||
formula do
|
|
||||||
patch :p1 do
|
patch :p1 do
|
||||||
url PATCH_URL_A
|
url PATCH_URL_A
|
||||||
sha1 "fa8af2e803892e523fdedc6b758117c45e5749a2"
|
sha1 "fa8af2e803892e523fdedc6b758117c45e5749a2"
|
||||||
end
|
end
|
||||||
end.brew do |f|
|
}
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_single_patch_dsl_with_incorrect_strip
|
def test_single_patch_dsl_with_incorrect_strip
|
||||||
@ -82,104 +72,44 @@ class PatchingTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_p0_dsl
|
def test_patch_p0_dsl
|
||||||
shutup do
|
assert_patched formula {
|
||||||
formula do
|
|
||||||
patch :p0 do
|
patch :p0 do
|
||||||
url PATCH_URL_B
|
url PATCH_URL_B
|
||||||
sha1 "3b54bd576f998ef6d6623705ee023b55062b9504"
|
sha1 "3b54bd576f998ef6d6623705ee023b55062b9504"
|
||||||
end
|
end
|
||||||
end.brew do |f|
|
}
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_p0
|
def test_patch_p0
|
||||||
shutup do
|
assert_patched formula { def patches; { :p0 => PATCH_URL_B }; end }
|
||||||
formula do
|
|
||||||
def patches
|
|
||||||
{ :p0 => PATCH_URL_B }
|
|
||||||
end
|
|
||||||
end.brew do |f|
|
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_array
|
def test_patch_array
|
||||||
shutup do
|
assert_patched formula { def patches; [PATCH_URL_A]; end }
|
||||||
formula do
|
|
||||||
def patches
|
|
||||||
[PATCH_URL_A]
|
|
||||||
end
|
|
||||||
end.brew do |f|
|
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_hash
|
def test_patch_hash
|
||||||
shutup do
|
assert_patched formula { def patches; { :p1 => PATCH_URL_A }; end }
|
||||||
formula do
|
|
||||||
def patches
|
|
||||||
{ :p1 => PATCH_URL_A }
|
|
||||||
end
|
|
||||||
end.brew do |f|
|
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_hash_array
|
def test_patch_hash_array
|
||||||
shutup do
|
assert_patched formula { def patches; { :p1 => [PATCH_URL_A] } end }
|
||||||
formula do
|
|
||||||
def patches
|
|
||||||
{ :p1 => [PATCH_URL_A] }
|
|
||||||
end
|
|
||||||
end.brew do |f|
|
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_string
|
def test_patch_string
|
||||||
shutup do
|
assert_patched formula { patch PATCH_A_CONTENTS }
|
||||||
formula do
|
|
||||||
patch PATCH_A_CONTENTS
|
|
||||||
end.brew do |f|
|
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_string_with_strip
|
def test_patch_string_with_strip
|
||||||
shutup do
|
assert_patched formula { patch :p0, PATCH_B_CONTENTS }
|
||||||
formula do
|
|
||||||
patch :p0, PATCH_B_CONTENTS
|
|
||||||
end.brew do |f|
|
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_DATA_constant
|
def test_patch_DATA_constant
|
||||||
shutup do
|
assert_patched formula("test", Pathname.new(__FILE__).expand_path) {
|
||||||
formula("test", Pathname.new(__FILE__).expand_path) do
|
|
||||||
def patches
|
def patches
|
||||||
Formula::DATA
|
Formula::DATA
|
||||||
end
|
end
|
||||||
end.brew do |f|
|
}
|
||||||
f.patch
|
|
||||||
assert_patched 'libexec/NOOP'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user