format
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
require 'mkmf'
|
||||
require "mkmf"
|
||||
|
||||
dir_config('bsdiff')
|
||||
fail unless have_header('unistd.h')
|
||||
fail unless have_header('bzlib.h')
|
||||
fail unless have_library('bz2')
|
||||
fail unless have_func('BZ2_bzWrite','bzlib.h')
|
||||
fail unless have_macro('BZ_OK','bzlib.h')
|
||||
create_header('bsdiff_config.h')
|
||||
create_makefile('bsdiff')
|
||||
dir_config("bsdiff")
|
||||
fail unless have_header("unistd.h")
|
||||
fail unless have_header("bzlib.h")
|
||||
fail unless have_library("bz2")
|
||||
fail unless have_func("BZ2_bzWrite", "bzlib.h")
|
||||
fail unless have_macro("BZ_OK", "bzlib.h")
|
||||
create_header("bsdiff_config.h")
|
||||
create_makefile("bsdiff")
|
||||
|
||||
@@ -14,7 +14,6 @@ class TestPatch < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_diff_and_patch
|
||||
|
||||
#../bsdiff b0 b1 p0
|
||||
#../bspatch b0 b3 p0
|
||||
|
||||
|
||||
@@ -8,13 +8,9 @@ BASE_DIR = File.absolute_path(File.dirname(__FILE__))
|
||||
$CXXFLAGS += " -std=c++17 -O3 "
|
||||
$CXXFLAGS += " -I#{BASE_DIR}/xdiff/xdiff "
|
||||
|
||||
if !find_executable("cmake")
|
||||
abort "ERROR: cmake is required."
|
||||
end
|
||||
abort "ERROR: cmake is required." if !find_executable("cmake")
|
||||
|
||||
if !find_executable("make")
|
||||
abort "ERROR: make is required."
|
||||
end
|
||||
abort "ERROR: make is required." if !find_executable("make")
|
||||
|
||||
def sys(cmd)
|
||||
puts "(#{Dir.pwd}) -- #{cmd}"
|
||||
@@ -30,9 +26,7 @@ def run_cmake(timeout, args)
|
||||
pgroup = Gem.win_platform? ? :new_pgroup : :pgroup
|
||||
pid = Process.spawn("cmake #{args}", pgroup => true)
|
||||
|
||||
Timeout.timeout(timeout) do
|
||||
Process.waitpid(pid)
|
||||
end
|
||||
Timeout.timeout(timeout) { Process.waitpid(pid) }
|
||||
rescue Timeout::Error
|
||||
# Kill it, #detach is essentially a background wait, since we don't actually
|
||||
# care about waiting for it now
|
||||
@@ -45,7 +39,10 @@ Dir.chdir("#{BASE_DIR}") do
|
||||
sys("tar -xzf xdiff.tar.gz") unless Dir.exist?("xdiff")
|
||||
Dir.mkdir("xdiff_build") unless Dir.exist?("xdiff_build")
|
||||
Dir.chdir("xdiff_build") do
|
||||
run_cmake(30, "#{BASE_DIR}/xdiff -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=C++17")
|
||||
run_cmake(
|
||||
30,
|
||||
"#{BASE_DIR}/xdiff -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=C++17"
|
||||
)
|
||||
sys("make")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,12 +2,12 @@ module XDiff
|
||||
VERSION = "0.0.1"
|
||||
|
||||
def self.validate_arg(method, name, arg)
|
||||
raise ArgumentError.new(
|
||||
"(#{method}) '#{name}' cannot be nil"
|
||||
) if arg.nil?
|
||||
raise ArgumentError.new(
|
||||
"(#{method}) '#{name}' must be String (is #{arg.class})"
|
||||
) unless arg.is_a?(String)
|
||||
raise ArgumentError.new("(#{method}) '#{name}' cannot be nil") if arg.nil?
|
||||
unless arg.is_a?(String)
|
||||
raise ArgumentError.new(
|
||||
"(#{method}) '#{name}' must be String (is #{arg.class})"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def self.diff(a, b)
|
||||
|
||||
Reference in New Issue
Block a user