PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Languages/Ruby/Tests/Scripts/utr/rack_tests.rb

http://github.com/IronLanguages/main
Ruby | 258 lines | 181 code | 37 blank | 40 comment | 9 complexity | affdc09e64de6371317fe2a50a74665e MD5 | raw file
Possible License(s): CPL-1.0, BSD-3-Clause, ISC, GPL-2.0, MPL-2.0-no-copyleft-exception
  1. class UnitTestSetup
  2. def initialize
  3. @name = "Rack"
  4. super
  5. end
  6. VERSION = '1.1.0'
  7. def ironruby?
  8. defined?(RUBY_ENGINE) and RUBY_ENGINE == "ironruby"
  9. end
  10. def require_files
  11. if ironruby?
  12. require 'test/ispec'
  13. end
  14. require 'rubygems'
  15. gem 'rack', "=#{VERSION}"
  16. end
  17. def gather_files
  18. @lib_tests_dir = File.expand_path("Languages/Ruby/Tests/Libraries/rack-#{VERSION}", ENV["DLR_ROOT"])
  19. @irk_tests_dir = File.expand_path("Hosts/IronRuby.Rack/ironruby-rack/test", ENV["DLR_ROOT"])
  20. @all_test_files = Dir.glob("#{@lib_tests_dir}/test/test*.rb") + Dir.glob("#{@lib_tests_dir}/test/spec*.rb")
  21. @all_test_files.concat Dir.glob("#{@irk_tests_dir}/spec*.rb") if ironruby?
  22. %W(lib test).each{|i| $:.unshift i}
  23. end
  24. def sanity
  25. # Some tests load data assuming the current folder
  26. Dir.chdir(@lib_tests_dir)
  27. end
  28. def exclude_critical_files
  29. @all_test_files = @all_test_files.delete_if{|i| i =~ /camping/}
  30. end
  31. def disable_mri_only_failures
  32. # NotImplementedError: fork() function is unimplemented on this machine
  33. disable_spec 'rackup',
  34. 'rackup',
  35. 'rackup --help',
  36. 'rackup --port',
  37. 'rackup --debug',
  38. 'rackup --eval',
  39. 'rackup --warn',
  40. 'rackup --include',
  41. 'rackup --require',
  42. 'rackup --server',
  43. 'rackup --host',
  44. 'rackup --daemonize --pid',
  45. 'rackup --pid',
  46. 'rackup --version',
  47. 'rackup --env development includes lint',
  48. 'rackup --env deployment does not include lint',
  49. 'rackup --env none does not include lint',
  50. 'rackup --env deployment does log',
  51. 'rackup --env none does not log'
  52. disable_spec 'Rack::Utils::Multipart',
  53. #EOFError: bad content body
  54. "can parse fields that end at the end of the buffer"
  55. # <"/foo/bar/hello.txt"> expected but was
  56. # <"d:/tmp/hello.txt">.
  57. disable_spec 'Rack::Sendfile',
  58. 'sets X-Accel-Redirect response header and discards body',
  59. 'sets X-Lighttpd-Send-File response header and discards body',
  60. 'sets X-Sendfile response header and discards body'
  61. disable_spec 'Rack::Handler::FastCGI',
  62. 'startup',
  63. # NotImplementedError: fork() function is unimplemented on this machine
  64. 'should respond',
  65. # Exception raised:
  66. # Class: <Errno::ECONNREFUSED>
  67. # Message: <"No connection could be made because the target machine actively refused it. - connect(2)">
  68. 'should respond via rackup server',
  69. 'should be a lighttpd',
  70. 'should have rack headers',
  71. 'should have CGI headers on GET',
  72. 'should support HTTP auth',
  73. 'should set status',
  74. # Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2)
  75. 'shutdown'
  76. #TypeError: wrong argument type nil (expected Fixnum)
  77. disable_spec 'Rack::Handler::CGI',
  78. 'startup',
  79. # NotImplementedError: fork() function is unimplemented on this machine
  80. 'should respond',
  81. # Exception raised:
  82. # Class: <Errno::ECONNREFUSED>
  83. # Message: <"No connection could be made because the target machine actively refused it. - connect(2)">
  84. 'should be a lighttpd',
  85. 'should have rack headers',
  86. 'should have CGI headers on GET',
  87. 'should have CGI headers on POST',
  88. 'should support HTTP auth',
  89. 'should set status',
  90. # Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2)
  91. 'shutdown'
  92. #TypeError: wrong argument type nil (expected Fixnum)
  93. end
  94. def disable_mri_failures
  95. if valid_context? 'Rack::Handler::Mongrel'
  96. disable_spec "Rack::Handler::Mongrel",
  97. # Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it.
  98. 'should respond',
  99. 'should be a Mongrel',
  100. 'should have rack headers',
  101. 'should have CGI headers on GET',
  102. 'should have CGI headers on POST',
  103. 'should support HTTP auth',
  104. 'should set status',
  105. # empty? expected to be false.
  106. 'should stream #each part of the response'
  107. end
  108. if valid_context? 'Rack::Handler::FastCGI'
  109. disable_spec 'Rack::Handler::FastCGI',
  110. 'should have CGI headers on POST'
  111. end
  112. disable_spec 'Rack::Handler',
  113. #LoadError: no such file to load -- fcgi
  114. "has registered default handlers"
  115. # <0.10001> expected to be
  116. # >
  117. # <0.10001>.
  118. disable_spec "Rack::Runtime", 'should allow multiple timers to be set'
  119. end
  120. def disable_tests
  121. disable_spec "Rack::Handler::ASPNET",
  122. # TODO implement .run
  123. 'should provide a .run',
  124. # <"/"> expected but was
  125. # <"/test">.
  126. 'should have CGI headers on POST',
  127. # <"/"> expected but was
  128. # <"/test/">
  129. 'should have CGI headers on GET'
  130. disable_spec "rackup",
  131. 'rackup --debug',
  132. 'rackup --daemonize --pid'
  133. disable_spec 'Rack::Cascade',
  134. #NameError: uninitialized constant Errno::EPERM
  135. "should append new app",
  136. "should dispatch onward on 404 by default"
  137. disable_spec 'Rack::Handler::CGI',
  138. "should respond",
  139. #ArgumentError: IPv4 address 0.0.0.0 and IPv6 address ::0 are unspecified addresses that cannot be use...
  140. "should support HTTP auth",
  141. "should have CGI headers on POST",
  142. "should set status",
  143. "should have CGI headers on GET",
  144. "should have rack headers",
  145. "should be a lighttpd",
  146. #NotImplementedError: Signals are not currently implemented. Signal.trap just pretends to work
  147. "shutdown",
  148. #NoMethodError: undefined method `fork' for #<:0x0002198 @method_name="test_spec {Rack::Handler::CGI} ...
  149. "startup"
  150. disable_spec 'Rack::Handler::FastCGI',
  151. "should respond",
  152. #ArgumentError: IPv4 address 0.0.0.0 and IPv6 address ::0 are unspecified addresses that cannot be use...
  153. "should have CGI headers on POST",
  154. "should have CGI headers on GET",
  155. "should support HTTP auth",
  156. "should set status",
  157. "should respond via rackup server",
  158. "should have rack headers",
  159. "should be a lighttpd",
  160. #NotImplementedError: Signals are not currently implemented. Signal.trap just pretends to work
  161. "shutdown",
  162. #NoMethodError: undefined method `fork' for #<:0x00021fe @method_name="test_spec {Rack::Handler::FastC...
  163. "startup"
  164. if valid_context? 'Rack::Handler::Mongrel'
  165. disable_spec 'Mongrel',
  166. 'should provide a .run',
  167. 'should provide a .run that maps a hash'
  168. end
  169. disable_spec 'Rack::Directory',
  170. #NameError: uninitialized constant Errno::ELOOP
  171. "404s if it can't find the file"
  172. disable_spec 'Rack::File',
  173. #NameError: uninitialized constant Errno::EPERM
  174. "detects SystemCallErrors",
  175. "404s if it can't find the file"
  176. disable_spec 'Rack::Handler',
  177. #LoadError: no such file to load -- fcgi
  178. "has registered default handlers"
  179. disable_spec 'Rack::RewindableInput given an IO object that is not rewindable',
  180. #NoMethodError: undefined method `close' for nil:NilClass
  181. "should buffer into a Tempfile when data has been consumed for the first time",
  182. "should not buffer into a Tempfile if no data has been read yet",
  183. "should be able to handle each",
  184. "should be possible to call #close multiple times",
  185. "should be possibel to call #close when no data has been buffered yet",
  186. "should close the underlying tempfile upon calling #close",
  187. "should be able to handle gets",
  188. "should be able to handle to read(length)",
  189. "should be able to handle to read(nil)",
  190. "should be able to handle to read()",
  191. "should rewind to the beginning when #rewind is called",
  192. "should be able to handle to read(nil, buffer)",
  193. "should be able to handle to read(length, buffer)"
  194. disable_spec 'Rack::Session::Cookie',
  195. #NameError: uninitialized constant OpenSSL::Digest::SHA1
  196. "loads from a cookie wih integrity hash",
  197. "ignores tampered with session cookies"
  198. disable_spec 'Rack::Static',
  199. #NameError: uninitialized constant Errno::EPERM
  200. "404s if url root is known but it can't find the file"
  201. disable_spec 'Rack::Utils::Multipart',
  202. #EOFError: bad content body
  203. "can parse fields that end at the end of the buffer"
  204. disable_spec 'Rack::ETag',
  205. "sets ETag if none is set"
  206. disable_spec 'Rack::MockRequest',
  207. "should accept params and build multipart encoded params for POST requests"
  208. disable_spec 'Rack::Sendfile',
  209. "sets X-Accel-Redirect response header and discards body",
  210. "sets X-Sendfile response header and discards body",
  211. "sets X-Lighttpd-Send-File response header and discards body"
  212. disable_spec 'Rack::Utils',
  213. "should figure out which encodings are acceptable"
  214. end
  215. end