http_spew 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/GIT-VERSION-FILE CHANGED
@@ -1 +1 @@
1
- GIT_VERSION = 0.4.1
1
+ GIT_VERSION = 0.5.0
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.4.1.GIT
4
+ DEF_VER=v0.5.0
5
5
 
6
6
  LF='
7
7
  '
data/GNUmakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  all::
2
2
  RSYNC_DEST := bogomips.org:/srv/bogomips/http_spew
3
- rfproject := rainbows
4
3
  rfpackage := http_spew
5
4
 
6
5
  RUBY_VERSION_FILE = lib/http_spew/version.rb
@@ -10,7 +9,7 @@ include pkg.mk
10
9
  $(RUBY_VERSION_FILE): GIT-VERSION-FILE
11
10
  @$(RM) -f $@+
12
11
  @echo >> $@+ '# -*- encoding: binary -*-'
13
- @echo >> $@+ 'HTTP_Spew.const_set :VERSION, "$(GIT_VERSION)"'
12
+ @echo >> $@+ 'HTTP_Spew.const_set :VERSION, "$(GIT_VERSION)".freeze'
14
13
  @mv $@+ $@
15
14
 
16
15
  build: $(RUBY_VERSION_FILE)
data/LATEST CHANGED
@@ -1,4 +1,20 @@
1
- === http_spew 0.4.1 / 2012-09-23 00:01 UTC
1
+ === http_spew 0.5.0 / 2016-10-31 20:43 UTC
2
2
 
3
- Fix formatting of user-supplied headers.
3
+ This release requires Ruby 2.1 or later.
4
+
5
+ 13 changes since 0.4.1:
6
+
7
+ gemspec: require kcar >= 0.3.1
8
+ test/helper: explicit redirect for Ruby 2.0.0
9
+ update packaging + docs (website)
10
+ allow all future GPL versions
11
+ add benchmark scripts
12
+ relax dependency on unicorn
13
+ declare empty classes with constant assignment
14
+ test_upload: use object_id to check matches
15
+ use frozen string literals for Ruby 2.1+
16
+ merge into kcar project and mailing list
17
+ dedicated mailing list
18
+ rely on opt_str_freeze in more places
19
+ use monotonic clock for timing
4
20
 
data/LICENSE CHANGED
@@ -1,17 +1,14 @@
1
- HTTP Spew is copyrighted Free Software by all contributors, see logs in
1
+ http_spew is copyrighted Free Software by all contributors, see logs in
2
2
  revision control for names and email addresses of all of them.
3
3
 
4
4
  You can redistribute it and/or modify it under the terms of the GNU
5
- General Public License, version 2 *or* 3 ({GPLv3}[link:COPYING]) as
6
- published by the Free Software Foundation. The project leader
7
- (Eric Wong) reserves the right to relicense HTTP Spew under future versions
8
- of the GPL.
5
+ General Public License as published by the Free Software Foundation;
6
+ either version 2 of the License, or (at your option) any later version.
9
7
 
10
- HTTP Spew is distributed in the hope that it will be useful, but WITHOUT
8
+ http_spew is distributed in the hope that it will be useful, but WITHOUT
11
9
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13
- License for more details.
10
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11
+ for more details.
14
12
 
15
- You should have received a copy of the GNU General Public License
16
- along with HTTP Spew; if not, write to the Free Software Foundation, Inc.,
17
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
13
+ You should have received a copy of the GNU General Public License along
14
+ with this program; if not, see https://www.gnu.org/licenses/gpl-2.0.txt
data/NEWS CHANGED
@@ -1,3 +1,23 @@
1
+ === http_spew 0.5.0 / 2016-10-31 20:43 UTC
2
+
3
+ This release requires Ruby 2.1 or later.
4
+
5
+ 13 changes since 0.4.1:
6
+
7
+ gemspec: require kcar >= 0.3.1
8
+ test/helper: explicit redirect for Ruby 2.0.0
9
+ update packaging + docs (website)
10
+ allow all future GPL versions
11
+ add benchmark scripts
12
+ relax dependency on unicorn
13
+ declare empty classes with constant assignment
14
+ test_upload: use object_id to check matches
15
+ use frozen string literals for Ruby 2.1+
16
+ merge into kcar project and mailing list
17
+ dedicated mailing list
18
+ rely on opt_str_freeze in more places
19
+ use monotonic clock for timing
20
+
1
21
  === http_spew 0.4.1 / 2012-09-23 00:01 UTC
2
22
 
3
23
  Fix formatting of user-supplied headers.
data/README CHANGED
@@ -11,7 +11,6 @@ Use HTTP Spew if you wish you could kinda multicast with HTTP...
11
11
  * No support for DNS resolution (WONTFIX, ever)
12
12
  * No support for HTTPS
13
13
  * No support for keepalive (yet?)
14
- * No support for Ruby 1.8, this is Ruby 1.9-only
15
14
  * Not remotely RFC-compliant
16
15
  * Messes up analytics/reporting on servers
17
16
  * Resets server connections
@@ -39,7 +38,7 @@ You can get the latest source via git from the following locations:
39
38
  You may browse the code from the web and download the latest snapshot
40
39
  tarballs here:
41
40
 
42
- * http://bogomips.org/http_spew.git (cgit)
41
+ * https://bogomips.org/http_spew.git
43
42
  * http://repo.or.cz/w/http_spew.git (gitweb)
44
43
 
45
44
  Inline patches (from "git format-patch") to the mailing list are
@@ -54,8 +53,8 @@ don't email the git mailing list or maintainer with http_spew patches.
54
53
  == Contact
55
54
 
56
55
  All feedback (bug reports, user/development discussion, patches, pull
57
- requests) go to the mailing list: mailto:http.spew@librelist.org
56
+ requests) go to the mailing list: mailto:http_spew-public@bogomips.org
58
57
 
59
- Mailing list archives in mbox format may be downloaded here:
58
+ Mailing list archives may be viewed and downloaded here:
60
59
 
61
- http://bogomips.org/http_spew/archives/
60
+ https://bogomips.org/http_spew-public/
@@ -0,0 +1,52 @@
1
+ # -*- encoding: binary -*-
2
+ require "./test/helper"
3
+ require "benchmark"
4
+
5
+ class TestBMContentMD5 < Test::Unit::TestCase
6
+ def setup
7
+ @addr, @port, @srv = start_server("./test/content-md5.ru", 1)
8
+ @sockaddr = Socket.pack_sockaddr_in(@port, @addr)
9
+ @env = {
10
+ "REQUEST_METHOD" => "PUT",
11
+ "REQUEST_URI" => "/",
12
+ "HTTP_HOST" => "example.com",
13
+ }
14
+ @tmpfiles = []
15
+ @bs = ENV['bs'] ? ENV['bs'].to_i : 1024 * 1024
16
+ @count = ENV['count'] ? ENV['count'].to_i : 1000
17
+ @cmd = %w(dd if=/dev/zero)
18
+ @cmd << "bs=#@bs"
19
+ @cmd << "count=#@count"
20
+ end
21
+
22
+ def teardown
23
+ Process.kill(:QUIT, @srv)
24
+ Process.waitpid2(@srv)
25
+ @tmpfiles.each { |tmp| tmp.closed? or tmp.close! }
26
+ end
27
+
28
+ def test_upload_with_md5
29
+ rd, wr = IO.pipe
30
+ pid = fork do
31
+ $stdout.reopen(wr)
32
+ rd.close
33
+ wr.close
34
+ exec(*@cmd)
35
+ end
36
+ wr.close
37
+ @env["CONTENT_LENGTH"] = (@bs * @count).to_s
38
+ @env["rack.input"] = rd
39
+ input = HTTP_Spew::ContentMD5.new(@env)
40
+ assert_nil @env["CONTENT_LENGTH"]
41
+ assert_equal "chunked", @env["HTTP_TRANSFER_ENCODING"]
42
+ req = HTTP_Spew::Request.new(@env, input, @sockaddr)
43
+ rv = nil
44
+ res = Benchmark.measure do
45
+ rv = req.run(100000)
46
+ end
47
+ assert_equal 200, rv[0].to_i
48
+ pid, status = Process.waitpid2(pid)
49
+ assert status.success?
50
+ p res
51
+ end
52
+ end
@@ -0,0 +1,59 @@
1
+ require "./test/helper"
2
+ require "benchmark"
3
+
4
+ class TestBMContentMD5InputSpray < Test::Unit::TestCase
5
+ def setup
6
+ @nr = 4
7
+ @addr, @port, @srv = start_server("./test/content-md5.ru", @nr)
8
+ @sockaddr = Socket.pack_sockaddr_in(@port, @addr)
9
+ @env = {
10
+ "REQUEST_METHOD" => "PUT",
11
+ "REQUEST_URI" => "/",
12
+ "HTTP_HOST" => "example.com",
13
+ }
14
+ @tmpfiles = []
15
+ @bs = ENV['bs'] ? ENV['bs'].to_i : 1024 * 1024
16
+ @count = ENV['count'] ? ENV['count'].to_i : 1000
17
+ @cmd = %w(dd if=/dev/zero)
18
+ @cmd << "bs=#@bs"
19
+ @cmd << "count=#@count"
20
+ end
21
+
22
+ def teardown
23
+ Process.kill(:QUIT, @srv)
24
+ Process.waitpid2(@srv)
25
+ @tmpfiles.each { |tmp| tmp.closed? or tmp.close! }
26
+ end
27
+
28
+ def test_spray_with_md5
29
+ rd, wr = IO.pipe
30
+ pid = fork do
31
+ $stdout.reopen(wr)
32
+ rd.close
33
+ wr.close
34
+ exec(*@cmd)
35
+ end
36
+ wr.close
37
+ @env["CONTENT_LENGTH"] = (@bs * @count).to_s
38
+ @env["rack.input"] = rd
39
+ input = HTTP_Spew::ContentMD5.new(@env)
40
+ sprayer = HTTP_Spew::InputSpray.new(@env, @nr, input)
41
+ assert_nil @env["CONTENT_LENGTH"]
42
+ assert_equal "chunked", @env["HTTP_TRANSFER_ENCODING"]
43
+ reqs = sprayer.readers.map do |md5_input|
44
+ HTTP_Spew::Request.new(@env, md5_input, @sockaddr)
45
+ end
46
+ assert_equal @nr, reqs.size
47
+ rv = nil
48
+ res = Benchmark.measure do
49
+ rv = HTTP_Spew.wait_mt reqs.size, reqs, 3600
50
+ end
51
+ assert_equal @nr, rv.size
52
+ rv.each do |resp|
53
+ assert_equal 200, resp.response[0].to_i
54
+ end
55
+ pid, status = Process.waitpid2(pid)
56
+ assert status.success?
57
+ p res
58
+ end
59
+ end
data/http_spew.gemspec CHANGED
@@ -1,24 +1,23 @@
1
1
  ENV["VERSION"] or abort "VERSION= must be specified"
2
2
  manifest = File.readlines('.manifest').map! { |x| x.chomp! }
3
- require 'wrongdoc'
4
- extend Wrongdoc::Gemspec
3
+ require 'olddoc'
4
+ extend Olddoc::Gemspec
5
5
  name, summary, title = readme_metadata
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = %q{http_spew}
9
9
  s.version = ENV["VERSION"].dup
10
- s.authors = ["HTTP Spew hackers"]
11
- s.date = Time.now.utc.strftime('%Y-%m-%d')
10
+ s.authors = ["kcar hackers"]
12
11
  s.description = readme_description
13
- s.email = %q{http.spew@librelist.org}
12
+ s.email = %q{kcar@bogomips.org}
14
13
  s.extra_rdoc_files = extra_rdoc_files(manifest)
15
14
  s.files = manifest
16
- s.homepage = Wrongdoc.config[:rdoc_url]
15
+ s.homepage = Olddoc.config['rdoc_url']
17
16
  s.summary = summary
18
- s.rdoc_options = rdoc_options
19
- s.rubyforge_project = %q{rainbows}
20
17
  s.test_files = Dir["test/test_*.rb"]
21
- s.add_dependency(%q<kcar>, "~> 0.3")
18
+ s.add_dependency(%q<kcar>, [ "~> 0.3", ">= 0.3.1"])
22
19
  s.add_dependency(%q<kgio>, "~> 2.6")
23
- s.add_development_dependency(%q<wrongdoc>, "~> 1.5")
20
+ s.add_development_dependency(%q<olddoc>, "~> 1.0")
21
+ s.required_ruby_version = '>= 2.1'
22
+ s.licenses = %w(GPL-2.0+)
24
23
  end
@@ -41,11 +41,11 @@ module HTTP_Spew::ClassMethods
41
41
  end
42
42
 
43
43
  def with_timeout(t)
44
- t0 = Time.now
44
+ t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
45
45
  yield
46
- ensure
47
- t[0] -= Time.now - t0
48
- t[0] = 0.0 if t[0] < 0
46
+ ensure
47
+ t[0] -= Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0
48
+ t[0] = 0.0 if t[0] < 0
49
49
  end
50
50
 
51
51
  # Returns an array of requests that are complete, including those
@@ -60,7 +60,7 @@ module HTTP_Spew::ClassMethods
60
60
  active << Thread.new do
61
61
  begin
62
62
  rv = req.run(timeout)
63
- w.write([ i ].pack("v"))
63
+ w.write([ i ].pack("v".freeze))
64
64
  rv
65
65
  rescue => err
66
66
  err
@@ -69,7 +69,7 @@ module HTTP_Spew::ClassMethods
69
69
  end
70
70
  begin
71
71
  with_timeout(t) { r.kgio_wait_readable(t[0]) }
72
- req_idx = r.read(2).unpack("v")[0]
72
+ req_idx = r.read(2).unpack("v".freeze)[0]
73
73
  thr = active[req_idx]
74
74
  with_timeout(t) { thr.join(t[0]) }
75
75
  rv = thr.value
@@ -7,17 +7,16 @@ class HTTP_Spew::ContentMD5
7
7
  attr_reader :content_md5
8
8
  attr_reader :bytes_digested
9
9
 
10
- CRLF = "\r\n" # :nodoc:
11
-
12
10
  def initialize(env, input = env["rack.input"])
13
11
  if trailer = env["HTTP_TRAILER"]
14
12
  unless trailer.split(/\s*,\s*/).grep(/\AContent-MD5\z/i)[0]
15
- trailer << (trailer.empty? ? "Content-MD5" : ",Content-MD5")
13
+ trailer << (trailer.empty? ? "Content-MD5".freeze
14
+ : ",Content-MD5".freeze)
16
15
  end
17
16
  else
18
- env["HTTP_TRAILER"] = "Content-MD5"
17
+ env["HTTP_TRAILER"] = "Content-MD5".freeze
19
18
  end
20
- env["HTTP_TRANSFER_ENCODING"] = "chunked"
19
+ env["HTTP_TRANSFER_ENCODING"] = "chunked".freeze
21
20
  @to_io, wr = HTTP_Spew::ChunkyPipe.new
22
21
  expect_md5 = env.delete("HTTP_CONTENT_MD5")
23
22
  expect_len = env.delete("CONTENT_LENGTH")
@@ -41,7 +40,7 @@ class HTTP_Spew::ContentMD5
41
40
  @bytes_digested += n
42
41
  wr.write("#{n.to_s(16)}\r\n")
43
42
  digest.update(buf)
44
- wr.write(buf << CRLF)
43
+ wr.write(buf << "\r\n".freeze)
45
44
  end while input.read(0x4000, buf)
46
45
  end
47
46
  if expect_len && expect_len.to_i != @bytes_digested
@@ -1,18 +1,10 @@
1
1
  # -*- encoding: binary -*-
2
2
  module HTTP_Spew::Headers
3
- # :stopdoc:
4
- REQUEST_METHOD = "REQUEST_METHOD"
5
- REQUEST_URI = "REQUEST_URI"
6
- CRLF = "\r\n"
7
- QUERY_STRING = "QUERY_STRING"
8
- PATH_INFO = "PATH_INFO"
9
- CONTENT_TYPE = "CONTENT_TYPE" # specified by Rack to be !/^HTTP_/
10
- # :startdoc:
11
3
 
12
4
  # regenerates the request_uri from a Rack +env+
13
5
  def request_uri(env)
14
- qs = env[QUERY_STRING]
15
- qs.size == 0 ? env[PATH_INFO] : "#{env[PATH_INFO]}?#{qs}"
6
+ qs = env['QUERY_STRING']
7
+ qs.size == 0 ? env['PATH_INFO'] : "#{env['PATH_INFO']}?#{qs}"
16
8
  end
17
9
  module_function :request_uri
18
10
 
@@ -27,26 +19,25 @@ module HTTP_Spew::Headers
27
19
  #
28
20
  # buf, input = env_to_headers(env, input)
29
21
  def env_to_headers(env, input)
30
- req = "#{env[REQUEST_METHOD]} " \
31
- "#{env[REQUEST_URI] || request_uri(env)} HTTP/1.1\r\n" \
22
+ req = "#{env['REQUEST_METHOD']} " \
23
+ "#{env['REQUEST_URI'] || request_uri(env)} HTTP/1.1\r\n" \
32
24
  "Connection: close\r\n"
33
- uscore, dash = "_", "-"
34
25
  env.each do |key,value|
35
26
  %r{\AHTTP_(\w+)\z} =~ key or next
36
27
  key = $1
37
28
  %r{\A(?:VERSION|EXPECT|TRANSFER_ENCODING|CONNECTION|KEEP_ALIVE)\z}x =~
38
29
  key and next
39
30
 
40
- key.tr!(uscore, dash)
31
+ key.tr!('_'.freeze, '-'.freeze)
41
32
  req << "#{key}: #{value}\r\n"
42
33
  end
43
34
  if input
44
35
  req << (input.respond_to?(:size) ?
45
36
  "Content-Length: #{input.size}\r\n" :
46
- "Transfer-Encoding: chunked\r\n")
47
- ct = env[CONTENT_TYPE] and req << "Content-Type: #{ct}\r\n"
37
+ "Transfer-Encoding: chunked\r\n".freeze)
38
+ ct = env['CONTENT_TYPE'] and req << "Content-Type: #{ct}\r\n"
48
39
  end
49
- req << CRLF
40
+ req << "\r\n".freeze
50
41
  String === input ? (req << input) : [ req, input ]
51
42
  end
52
43
  module_function :env_to_headers
@@ -55,17 +55,17 @@ class HTTP_Spew::Request
55
55
  # returns a 3-element Rack response array on successful completion
56
56
  # returns an Exception if one was raised
57
57
  def run(timeout)
58
- t0 = Time.now
58
+ t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
59
59
  buf, @buf = @buf, nil # make inspect nicer
60
60
  @to_io.write(buf)
61
61
  if @input
62
62
  @to_io.write(buf) while @input.read(0x4000, buf)
63
63
  end
64
- timeout -= (Time.now - t0)
64
+ timeout -= (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0)
65
65
  while :wait_readable == (rv = read_response) && timeout >= 0.0
66
- t0 = Time.now
66
+ t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
67
67
  @to_io.kgio_wait_readable(timeout) if timeout > 0.0
68
- timeout -= (Time.now - t0)
68
+ timeout -= (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0)
69
69
  end
70
70
  rv
71
71
  rescue => e
@@ -1,2 +1,2 @@
1
1
  # -*- encoding: binary -*-
2
- HTTP_Spew.const_set :VERSION, "0.4.1"
2
+ HTTP_Spew.const_set :VERSION, "0.5.0".freeze
data/lib/http_spew.rb CHANGED
@@ -8,20 +8,20 @@ module HTTP_Spew
8
8
  autoload :HitNRun, "http_spew/hit_n_run"
9
9
  autoload :InputSpray, "http_spew/input_spray"
10
10
 
11
- class Error < RuntimeError; end
12
- class TimeoutError < Error; end
13
- class ConnectionReset < Error; end
14
- class RequestError < Error; end
15
- class UnexpectedResponse < RequestError; end
16
- class ChecksumError < HTTP_Spew::Error; end
17
- class LengthError < HTTP_Spew::Error; end
18
- class NoWritersError < HTTP_Spew::Error; end
19
- class EOF < EOFError; end
11
+ Error = Class.new(RuntimeError)
12
+ TimeoutError = Class.new(Error)
13
+ ConnectionReset = Class.new(Error)
14
+ RequestError = Class.new(Error)
15
+ UnexpectedResponse = Class.new(RequestError)
16
+ ChecksumError = Class.new(Error)
17
+ LengthError = Class.new(Error)
18
+ NoWritersError = Class.new(Error)
19
+ EOF = Class.new(EOFError)
20
20
 
21
- require "http_spew/version"
22
- require "http_spew/headers"
23
- require "http_spew/request"
24
- require "http_spew/class_methods"
21
+ require_relative "http_spew/version"
22
+ require_relative "http_spew/headers"
23
+ require_relative "http_spew/request"
24
+ require_relative "http_spew/class_methods"
25
25
 
26
26
  extend HTTP_Spew::ClassMethods
27
27
  end
data/pkg.mk CHANGED
@@ -1,7 +1,8 @@
1
1
  RUBY = ruby
2
2
  RAKE = rake
3
3
  RSYNC = rsync
4
- WRONGDOC = wrongdoc
4
+ OLDDOC = olddoc
5
+ RDOC = rdoc
5
6
 
6
7
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
7
8
  @./GIT-VERSION-GEN
@@ -12,14 +13,6 @@ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
12
13
  RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
13
14
  lib := lib
14
15
 
15
- ifeq ($(shell test -f script/isolate_for_tests && echo t),t)
16
- isolate_libs := tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION)/isolate.mk
17
- $(isolate_libs): script/isolate_for_tests
18
- @$(RUBY) script/isolate_for_tests
19
- -include $(isolate_libs)
20
- lib := $(lib):$(ISOLATE_LIBS)
21
- endif
22
-
23
16
  ext := $(firstword $(wildcard ext/*))
24
17
  ifneq ($(ext),)
25
18
  ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
@@ -36,7 +29,7 @@ $(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
36
29
  install -m 644 $< $@
37
30
  $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
38
31
  $(RM) -f $(@D)/*.o
39
- cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb
32
+ cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
40
33
  ext_sfx := _ext.$(DLEXT)
41
34
  ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
42
35
  $(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
@@ -48,10 +41,10 @@ else
48
41
  build:
49
42
  endif
50
43
 
51
- pkg_extra += GIT-VERSION-FILE NEWS ChangeLog LATEST
52
- ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
53
- $(WRONGDOC) prepare
54
- NEWS LATEST: ChangeLog
44
+ pkg_extra += GIT-VERSION-FILE NEWS LATEST
45
+ NEWS: GIT-VERSION-FILE .olddoc.yml
46
+ $(OLDDOC) prepare
47
+ LATEST: NEWS
55
48
 
56
49
  manifest:
57
50
  $(RM) .manifest
@@ -63,28 +56,20 @@ manifest:
63
56
  cmp $@+ $@ || mv $@+ $@
64
57
  $(RM) $@+
65
58
 
66
- doc:: .document .wrongdoc.yml $(pkg_extra)
59
+ doc:: .document .olddoc.yml $(pkg_extra) $(PLACEHOLDERS)
67
60
  -find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
68
61
  -find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
69
62
  $(RM) -r doc
70
- $(WRONGDOC) all
71
- install -m644 COPYING doc/COPYING
72
- install -m644 $(shell grep '^[A-Z]' .document) doc/
63
+ $(RDOC) -f oldweb
64
+ $(OLDDOC) merge
65
+ if test -f COPYING; then install -m644 COPYING doc/COPYING; fi
66
+ install -m644 NEWS doc/NEWS
67
+ install -m644 NEWS.atom.xml doc/NEWS.atom.xml
68
+ install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
73
69
 
74
70
  ifneq ($(VERSION),)
75
71
  pkggem := pkg/$(rfpackage)-$(VERSION).gem
76
72
  pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
77
- release_notes := release_notes-$(VERSION)
78
- release_changes := release_changes-$(VERSION)
79
-
80
- release-notes: $(release_notes)
81
- release-changes: $(release_changes)
82
- $(release_changes):
83
- $(WRONGDOC) release_changes > $@+
84
- $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
85
- $(release_notes):
86
- $(WRONGDOC) release_notes > $@+
87
- $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
88
73
 
89
74
  # ensures we're actually on the tagged $(VERSION), only used for release
90
75
  verify:
@@ -120,31 +105,18 @@ $(pkgtgz): manifest fix-perms
120
105
 
121
106
  package: $(pkgtgz) $(pkggem)
122
107
 
123
- test-release:: verify package $(release_notes) $(release_changes)
124
- # make tgz release on RubyForge
125
- @echo rubyforge add_release -f \
126
- -n $(release_notes) -a $(release_changes) \
127
- $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
128
- @echo gem push $(pkggem)
129
- @echo rubyforge add_file \
130
- $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
131
- release:: verify package $(release_notes) $(release_changes)
132
- # make tgz release on RubyForge
133
- rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
134
- $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
108
+ release:: verify package
135
109
  # push gem to RubyGems.org
136
110
  gem push $(pkggem)
137
- # in case of gem downloads from RubyForge releases page
138
- rubyforge add_file \
139
- $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
140
111
  else
141
112
  gem install-gem: GIT-VERSION-FILE
142
113
  $(MAKE) $@ VERSION=$(GIT_VERSION)
143
114
  endif
144
115
 
145
- all:: test
116
+ all:: check
146
117
  test_units := $(wildcard test/test_*.rb)
147
- test: test-unit
118
+ test: check
119
+ check: test-unit
148
120
  test-unit: $(test_units)
149
121
  $(test_units): build
150
122
  $(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
@@ -154,8 +126,6 @@ ifneq ($(RSYNC_DEST),)
154
126
  publish_doc:
155
127
  -git set-file-times
156
128
  $(MAKE) doc
157
- find doc/images -type f | \
158
- TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
159
129
  $(MAKE) doc_gz
160
130
  $(RSYNC) -av doc/ $(RSYNC_DEST)/
161
131
  git ls-files | xargs touch
@@ -163,13 +133,18 @@ endif
163
133
 
164
134
  # Create gzip variants of the same timestamp as the original so nginx
165
135
  # "gzip_static on" can serve the gzipped versions directly.
166
- doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
136
+ doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
167
137
  doc_gz:
168
138
  for i in $(docs); do \
169
139
  gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
170
140
  check-warnings:
171
- @(for i in $$(git ls-files '*.rb'|grep -v '^setup\.rb$$'); \
141
+ @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
172
142
  do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
173
143
 
174
- .PHONY: all .FORCE-GIT-VERSION-FILE doc test $(test_units) manifest
144
+ ifneq ($(PLACEHOLDERS),)
145
+ $(PLACEHOLDERS):
146
+ echo olddoc_placeholder > $@
147
+ endif
148
+
149
+ .PHONY: all .FORCE-GIT-VERSION-FILE doc check test $(test_units) manifest
175
150
  .PHONY: check-warnings
data/test/helper.rb CHANGED
@@ -10,6 +10,7 @@ require "rack"
10
10
  require "tempfile"
11
11
  $-w = true
12
12
  require "http_spew"
13
+ HAVE_UNICORN = `which unicorn 2>/dev/null`.size > 0
13
14
 
14
15
  def start_server(config, worker_processes = 4, rewindable_input = false)
15
16
  ENV["RACK_ENV"] = "deployment"
@@ -32,7 +33,8 @@ EOF
32
33
  cfg.flush
33
34
  pid = fork do
34
35
  ENV["UNICORN_FD"] = sock.fileno.to_s
35
- exec "unicorn", "-l#{addr}:#{port}", "-c#{cfg.path}", config
36
+ redirect = { sock => sock } if RUBY_VERSION.to_f >= 2.0
37
+ exec "unicorn", "-l#{addr}:#{port}", "-c#{cfg.path}", config, redirect
36
38
  end
37
39
  File.open(fifo_path).close
38
40
  File.unlink fifo_path
@@ -102,4 +102,4 @@ class TestContentMD5 < Test::Unit::TestCase
102
102
  assert_equal expect_md5, input.content_md5
103
103
  assert_equal 123 * 8 * 1021 * 13, input.bytes_digested
104
104
  end
105
- end
105
+ end if HAVE_UNICORN
@@ -44,4 +44,4 @@ class TestHitNRun < Test::Unit::TestCase
44
44
  end
45
45
  assert_equal HTTP_Spew::HitNRun::RESPONSE.object_id, rv.object_id
46
46
  end
47
- end
47
+ end if HAVE_UNICORN
@@ -60,9 +60,9 @@ class TestInputSprayWithMD5 < Test::Unit::TestCase
60
60
  HTTP_Spew::Request.new(@env, md5_input, @sockaddr)
61
61
  end
62
62
  assert_equal @nr, reqs.size
63
- t0 = Time.now
63
+ t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
64
64
  rv = HTTP_Spew.wait_mt reqs.size, reqs, 3600
65
- elapsed = Time.now - t0
65
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0
66
66
  assert(elapsed <= 30, "took too long: #{elapsed}s")
67
67
  assert_equal @nr, rv.size
68
68
  rv.each { |r|
@@ -104,4 +104,4 @@ class TestInputSprayWithMD5 < Test::Unit::TestCase
104
104
  assert_equal expect_md5, input.content_md5
105
105
  assert_equal 123 * 8 * 1021 * 13, input.bytes_digested
106
106
  end
107
- end
107
+ end if HAVE_UNICORN