2010-02-10 22:21:24 -08:00
|
|
|
require 'testing_env'
|
2010-03-02 22:54:12 -08:00
|
|
|
require 'test/testball'
|
2010-02-10 22:21:24 -08:00
|
|
|
|
|
|
|
|
2012-06-20 00:51:01 -05:00
|
|
|
class DefaultPatchBall < TestBall
|
2010-02-10 22:21:24 -08:00
|
|
|
def patches
|
|
|
|
# Default is p1
|
|
|
|
"file:///#{TEST_FOLDER}/patches/noop-a.diff"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-20 00:51:01 -05:00
|
|
|
class ListPatchBall < TestBall
|
2010-02-10 22:21:24 -08:00
|
|
|
def patches
|
|
|
|
["file:///#{TEST_FOLDER}/patches/noop-a.diff"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-20 00:51:01 -05:00
|
|
|
class P0PatchBall < TestBall
|
2010-02-10 22:21:24 -08:00
|
|
|
def patches
|
|
|
|
{ :p0 => ["file:///#{TEST_FOLDER}/patches/noop-b.diff"] }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-20 00:51:01 -05:00
|
|
|
class P1PatchBall < TestBall
|
2010-02-10 22:21:24 -08:00
|
|
|
def patches
|
|
|
|
{ :p1 => ["file:///#{TEST_FOLDER}/patches/noop-a.diff"] }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class PatchingTests < Test::Unit::TestCase
|
|
|
|
def read_file path
|
|
|
|
File.open(path, 'r') { |f| f.read }
|
|
|
|
end
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-10 22:21:24 -08:00
|
|
|
def test_single_patch
|
2012-04-17 19:11:36 -05:00
|
|
|
shutup do
|
2010-02-10 22:21:24 -08:00
|
|
|
DefaultPatchBall.new('test_patch').brew do
|
|
|
|
s = read_file 'libexec/NOOP'
|
|
|
|
assert !s.include?("NOOP"), "File was unpatched."
|
|
|
|
assert s.include?("ABCD"), "File was not patched as expected."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_patch_list
|
2012-04-17 19:11:36 -05:00
|
|
|
shutup do
|
2010-02-10 22:21:24 -08:00
|
|
|
ListPatchBall.new('test_patch_list').brew do
|
|
|
|
s = read_file 'libexec/NOOP'
|
|
|
|
assert !s.include?("NOOP"), "File was unpatched."
|
|
|
|
assert s.include?("ABCD"), "File was not patched as expected."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_p0_patch
|
2012-04-17 19:11:36 -05:00
|
|
|
shutup do
|
2010-02-10 22:21:24 -08:00
|
|
|
P0PatchBall.new('test_p0_patch').brew do
|
|
|
|
s = read_file 'libexec/NOOP'
|
|
|
|
assert !s.include?("NOOP"), "File was unpatched."
|
|
|
|
assert s.include?("ABCD"), "File was not patched as expected."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_p1_patch
|
2012-04-17 19:11:36 -05:00
|
|
|
shutup do
|
2010-02-10 22:21:24 -08:00
|
|
|
P1PatchBall.new('test_p1_patch').brew do
|
|
|
|
s = read_file 'libexec/NOOP'
|
|
|
|
assert !s.include?("NOOP"), "File was unpatched."
|
|
|
|
assert s.include?("ABCD"), "File was not patched as expected."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|