From fd453107c6bade4320ca7bafcc7707eef24ce01e Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Wed, 10 Feb 2010 22:21:24 -0800 Subject: Add tests for patching. --- Library/Homebrew/test/test_patching.rb | 91 ++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Library/Homebrew/test/test_patching.rb (limited to 'Library/Homebrew/test/test_patching.rb') diff --git a/Library/Homebrew/test/test_patching.rb b/Library/Homebrew/test/test_patching.rb new file mode 100644 index 000000000..df4825711 --- /dev/null +++ b/Library/Homebrew/test/test_patching.rb @@ -0,0 +1,91 @@ +require 'testing_env' + +require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser +ARGV.extend(HomebrewArgvExtension) + +require 'formula' +require 'utils' + + +class TestBall ["file:///#{TEST_FOLDER}/patches/noop-b.diff"] } + end +end + +class P1PatchBall ["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 + + def test_single_patch + nostdout do + 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 + nostdout do + 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 + nostdout do + 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 + nostdout do + 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 -- cgit v1.2.3