PageRenderTime 68ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/patches/ruby/2.1.0/railsexpress/01-current-2.1.1-fixes.patch

http://github.com/skaes/rvm-patchsets
Patch | 4227 lines | 3895 code | 332 blank | 0 comment | 0 complexity | 5cc9064f0dee3da79ab793c6a21b40bb MD5 | raw file
  1. diff --git a/ChangeLog b/ChangeLog
  2. index 0349f7c..66ef0e4 100644
  3. --- a/ChangeLog
  4. +++ b/ChangeLog
  5. @@ -1,3 +1,216 @@
  6. +Thu Feb 6 08:23:28 2014 Eric Wong <e@80x24.org>
  7. +
  8. + * ext/thread/thread.c (rb_szqueue_max_set): use correct queue and
  9. + limit wakeups. [Bug #9343][ruby-core:60517]
  10. + * test/thread/test_queue.rb (test_sized_queue_assign_max):
  11. + test for bug
  12. +
  13. +Thu Feb 6 11:27:39 2014 Eric Hodel <drbrain@segment7.net>
  14. +
  15. + * lib/rubygems: RubyGems 2.2.2 which contains the following bug fixes:
  16. + http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.2.2+%2F+2014-02-05
  17. + https://bugs.ruby-lang.org/issues/9489
  18. +
  19. +Thu Feb 6 11:23:59 2014 Koichi Sasada <ko1@atdot.net>
  20. +
  21. + * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided,
  22. + then set objspace->rgengc.oldmalloc_increase_limit.
  23. + Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT
  24. + does not work.
  25. +
  26. + * gc.c (get_envparam_int): accept a value equals to lowerbounds.
  27. +
  28. + * gc.c (get_envparam_double): ditto.
  29. +
  30. +Wed Feb 5 23:57:05 2014 Charlie Somerville <charliesome@ruby-lang.org>
  31. +
  32. + * ext/thread/thread.c (rb_szqueue_push): check GET_SZQUEUE_WAITERS
  33. + instead of GET_QUEUE_WAITERS to prevent deadlock. Patch by Eric Wong.
  34. + [Bug #9302] [ruby-core:59324]
  35. +
  36. + * test/thread/test_queue.rb: add test
  37. +
  38. +Wed Feb 5 23:43:30 2014 NAKAMURA Usaku <usa@ruby-lang.org>
  39. +
  40. + * hash.c (rb_objid_hash): should return `long'. brushup r44534.
  41. +
  42. + * object.c (rb_obj_hash): follow above change.
  43. +
  44. +Wed Feb 5 23:43:30 2014 NAKAMURA Usaku <usa@ruby-lang.org>
  45. +
  46. + * hash.c (rb_any_hash): should treat the return value of rb_objid_hash()
  47. + as `long', because ruby assumes the hash value of the object id of
  48. + an object is `long'.
  49. + this fixes test failures on mswin64 introduced at r44525.
  50. +
  51. +Wed Feb 5 23:43:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  52. +
  53. + * hash.c (rb_objid_hash): return hash value from object ID with a
  54. + salt, extract from rb_any_hash().
  55. +
  56. + * object.c (rb_obj_hash): return same value as rb_any_hash().
  57. + fix r44125. [ruby-core:59638] [Bug #9381]
  58. +
  59. +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  60. +
  61. + * vm_insnhelper.c (vm_search_super_method): allow bound method from a
  62. + module, yet another method transplanting.
  63. +
  64. +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  65. +
  66. + * vm_insnhelper.c (vm_search_super_method): when super called in a
  67. + bound UnboundMethod generated from a module, no superclass is
  68. + found since the current defined class is the module, then call
  69. + method_missing in that case. [ruby-core:59619] [Bug #9377]
  70. +
  71. +Wed Feb 5 21:57:40 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  72. +
  73. + * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno
  74. + argument version anduse rb_syserr_fail_str() instead of
  75. + rb_sys_fail_str() with restoring errno.
  76. +
  77. + * ext/socket/socket.c (rsock_syserr_fail_path): ditto, and
  78. + rb_syserr_fail().
  79. +
  80. + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto, use
  81. + rsock_syserr_fail_raddrinfo().
  82. +
  83. + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto.
  84. +
  85. + * ext/socket/socket.c (setup_domain_and_type): ditto.
  86. +
  87. +Wed Feb 5 21:57:40 2014 Eric Wong <normalperson@yhbt.net>
  88. +
  89. + * ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno
  90. + before calling rb_sys_fail_str to prevent [BUG] errno == 0.
  91. + Patch by Eric Wong. [ruby-core:59498] [Bug #9352]
  92. +
  93. + * ext/socket/socket.c (rsock_sys_fail_path): ditto
  94. + * ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto
  95. + * ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto
  96. + * ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto
  97. +
  98. +Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  99. +
  100. + * lib/timeout.rb (Timeout::ExitException.catch): pass arguments
  101. + for new instance.
  102. +
  103. + * lib/timeout.rb (Timeout::ExitException#exception): fallback to
  104. + Timeout::Error if couldn't throw. [ruby-dev:47872] [Bug #9380]
  105. +
  106. + * lib/timeout.rb (Timeout#timeout): initialize ExitException with
  107. + message for the fallback case.
  108. +
  109. +Wed Feb 5 21:12:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  110. +
  111. + * lib/timeout.rb (Timeout#timeout): should not rescue ordinarily
  112. + raised ExitException, which should not be thrown.
  113. +
  114. + * lib/timeout.rb (Timeout::ExitException.catch): set @thread only if
  115. + it ought to be caught.
  116. +
  117. + * lib/timeout.rb (Timeout#timeout): when a custom exception is given,
  118. + no instance is needed to be caught, so defer creating new instance
  119. + until it is raised. [ruby-core:59511] [Bug #9354]
  120. +
  121. +Wed Feb 5 17:55:28 2014 Aman Gupta <ruby@tmm1.net>
  122. +
  123. + * array.c (ary_add_hash): Fix consistency issue between Array#uniq and
  124. + Array#uniq! [Bug #9340] [ruby-core:59457]
  125. + * test/ruby/test_array.rb (class TestArray): regression test for above.
  126. +
  127. +Wed Feb 5 11:48:42 2014 Charlie Somerville <charliesome@ruby-lang.org>
  128. +
  129. + * struct.c (rb_struct_set): return assigned value from setter method
  130. + rather than struct object. [Bug #9353] [ruby-core:59509]
  131. +
  132. + * test/ruby/test_struct.rb (test_setter_method_returns_value): add test
  133. +
  134. +Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  135. +
  136. + * string.c (rb_str_modify_expand): enable capacity and disable
  137. + assocation with packed objects when setting capa, so that
  138. + pack("p") string fails to unpack properly after modified.
  139. +
  140. +Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  141. +
  142. + * lib/delegate.rb (Delegator): keep source information methods
  143. + which start and end with '__'. [ruby-core:59718] [Bug #9403]
  144. +
  145. +Fri Jan 31 12:10:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  146. +
  147. + * proc.c (mnew_from_me): keep iclass as-is, to make inheritance
  148. + chain consistent. [ruby-core:59358] [Bug #9315]
  149. +
  150. + * proc.c (method_owner): return the original defined_class from
  151. + prepended iclass, instead.
  152. +
  153. +Fri Jan 31 12:05:59 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  154. +
  155. + * configure.in: let mingw do something black-magic, and check if
  156. + _gmtime64_s() is available actually.
  157. +
  158. + * win32/win32.c (gmtime_s, localtime_s): use _gmtime64_s() and
  159. + _localtime64_s() if available, not depending on very confusing
  160. + mingw variants macros. based on the patch by phasis68 (Heesob
  161. + Park) at [ruby-core:58764]. [ruby-core:58391] [Bug #9119]
  162. +
  163. +Thu Jan 30 15:02:35 2014 Shugo Maeda <shugo@ruby-lang.org>
  164. +
  165. + * configure.in: use $@ instead of $(.TARGET) because .TARGET is not
  166. + supported by GNU make.
  167. +
  168. +Mon Jan 27 16:49:52 2014 Kenta Murata <mrkn@mrkn.jp>
  169. +
  170. + * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): Add an additional
  171. + digit for the quotient to be compatible with bigdecimal 1.2.1 and
  172. + the former. [ruby-core:59365] [#9316] [#9305]
  173. +
  174. + * test/bigdecimal/test_bigdecimal.rb: tests for the above change.
  175. +
  176. + * ext/bigdecimal/bigdecimal.gemspec: bigdecimal version 1.2.4.
  177. +
  178. +Mon Jan 27 16:45:34 2014 Yamashita Yuu <yamashita@geishatokyo.com>
  179. +
  180. + * ext/openssl/ossl_ssl.c (Init_ossl_ssl): Declare a constant
  181. + `OP_MSIE_SSLV2_RSA_PADDING` only if the macro is defined. The
  182. + `SSL_OP_MSIE_SSLV2_RSA_PADDING` has been removed from latest
  183. + snapshot of OpenSSL 1.0.1. [Fixes GH-488]
  184. +
  185. +Thu Jan 23 10:37:24 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
  186. +
  187. + * hash.c (HAS_EXTRA_STATES): warn extra states only when something
  188. + differ. [ruby-core:59254] [Bug #9275]
  189. +
  190. +Thu Jan 9 14:05:24 2014 NAKAMURA Usaku <usa@ruby-lang.org>
  191. +
  192. + * win32/{setup.mak,Makefile.sub}: update fake.rb like
  193. + template/fake.rb.in.
  194. +
  195. +Thu Jan 9 14:05:24 2014 NAKAMURA Usaku <usa@ruby-lang.org>
  196. +
  197. + * win32/Makefile.sub (fake.rb): should depend on version.h because
  198. + if RUBY_VERSION is updated, fake.rb need to say the new version
  199. + to avoid install error in rbconfig.rb.
  200. +
  201. +Thu Jan 9 08:21:00 2014 Aman Gupta <ruby@tmm1.net>
  202. +
  203. + * test/net/imap/cacert.pem: generate new CA cert, since the last one
  204. + expired. [Bug #9341] [ruby-core:59459]
  205. + * test/net/imap/server.crt: new server cert signed with updated CA.
  206. + * test/net/imap/Makefile: add `make regen_certs` to automate this
  207. + process.
  208. +
  209. +Thu Dec 26 03:28:11 2013 Koichi Sasada <ko1@atdot.net>
  210. +
  211. + * vm_insnhelper.c (argument_error): insert dummy frame to make
  212. + a backtrace object intead of modify backtrace string array.
  213. + [Bug #9295]
  214. +
  215. + * test/ruby/test_backtrace.rb: add a test for this patch.
  216. + fix test to compare a result of Exception#backtrace with
  217. + a result of Exception#backtrace_locations.
  218. +
  219. Wed Dec 25 16:58:31 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
  220. * proc.c (rb_mod_define_method): consider visibility only if self
  221. diff --git a/NEWS b/NEWS
  222. index 59251a4..afd15fa 100644
  223. --- a/NEWS
  224. +++ b/NEWS
  225. @@ -114,6 +114,7 @@ with all sufficient information, see the ChangeLog file.
  226. * Process.clock_getres
  227. * String
  228. + * "literal".freeze is now optimized to return the same object
  229. * New methods:
  230. * String#scrub and String#scrub! verify and fix invalid byte sequence.
  231. If you want to use this function with older Ruby,
  232. @@ -133,6 +134,10 @@ with all sufficient information, see the ChangeLog file.
  233. === Core classes compatibility issues (excluding feature bug fixes)
  234. +* Dir
  235. + * incompatible changes:
  236. + * Dir#glob returns composed characters (previously Apple Modofied UTF-8).
  237. +
  238. * Hash
  239. * incompatible changes:
  240. * Hash#reject will return plain Hash object in the future versions, that
  241. @@ -250,7 +255,7 @@ String
  242. * REXML::Parsers::SAX2Parser
  243. * Fixes wrong number of arguments of entitydecl event. Document of the event
  244. says "an array of the entity declaration" but implementation passes two
  245. - or more arguments. It is an implementation bug but it breaks backword
  246. + or more arguments. It is an implementation bug but it breaks backward
  247. compatibility.
  248. * REXML::Parsers::StreamParser
  249. @@ -271,6 +276,8 @@ String
  250. * Improved, iterative resolver (compared to RubyGems 2.1 and earlier)
  251. * Support for a sharing a GEM_HOME across ruby platforms and versions
  252. + * Updated to 2.2.2. Fixes some minor bugs and performance regressions.
  253. +
  254. For a complete list of enhancements and bug fixes see:
  255. https://github.com/rubygems/rubygems/tree/master/History.txt
  256. diff --git a/array.c b/array.c
  257. index 45713c5..ff77a3e 100644
  258. --- a/array.c
  259. +++ b/array.c
  260. @@ -3904,7 +3904,9 @@ ary_add_hash(VALUE hash, VALUE ary)
  261. for (i=0; i<RARRAY_LEN(ary); i++) {
  262. VALUE elt = RARRAY_AREF(ary, i);
  263. - rb_hash_aset(hash, elt, elt);
  264. + if (rb_hash_lookup2(hash, elt, Qundef) == Qundef) {
  265. + rb_hash_aset(hash, elt, elt);
  266. + }
  267. }
  268. return hash;
  269. }
  270. diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
  271. index 4282bc6..0a7cb0a 100644
  272. --- a/bootstraptest/test_method.rb
  273. +++ b/bootstraptest/test_method.rb
  274. @@ -957,8 +957,8 @@ assert_equal 'ok', %q{
  275. assert_normal_exit %q{
  276. begin
  277. - Process.setrlimit(Process::RLIMIT_STACK, 4_202_496)
  278. - # FreeBSD fails this less than 4M + 8K bytes.
  279. + Process.setrlimit(Process::RLIMIT_STACK, 4_206_592)
  280. + # FreeBSD SEGVs this less than 4M + 12K bytes.
  281. rescue Exception
  282. exit
  283. end
  284. diff --git a/configure.in b/configure.in
  285. index ea14b94..84f176d 100644
  286. --- a/configure.in
  287. +++ b/configure.in
  288. @@ -888,6 +888,7 @@ AC_ARG_WITH(winnt-ver,
  289. AS_CASE(["$target_os"],
  290. [mingw*], [
  291. RUBY_APPEND_OPTION(CPPFLAGS, -D_WIN32_WINNT=$with_winnt_ver)
  292. + RUBY_APPEND_OPTION(CPPFLAGS, -D__MINGW_USE_VC2005_COMPAT)
  293. ])
  294. AS_CASE(["$target_os"],
  295. @@ -1040,6 +1041,7 @@ main()
  296. if test x"$ac_cv_type_NET_LUID" = xyes; then
  297. AC_DEFINE(HAVE_TYPE_NET_LUID, 1)
  298. fi
  299. + AC_CHECK_FUNCS(_gmtime64_s)
  300. AC_LIBOBJ([langinfo])
  301. ],
  302. [os2-emx*], [ LIBS="-lm $LIBS"
  303. @@ -2656,7 +2658,7 @@ if test "$with_dln_a_out" != yes; then
  304. : ${LDSHARED='$(CC) -shared'}
  305. if test "$rb_cv_binary_elf" = yes; then
  306. LDFLAGS="$LDFLAGS -rdynamic"
  307. - DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)'
  308. + DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$@'
  309. else
  310. test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED='$(LD) -Bshareable'
  311. fi
  312. diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
  313. index e0b7c01..8537817 100644
  314. --- a/ext/bigdecimal/bigdecimal.c
  315. +++ b/ext/bigdecimal/bigdecimal.c
  316. @@ -1221,8 +1221,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
  317. *div = b;
  318. mx = a->Prec + vabs(a->exponent);
  319. - if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
  320. - mx =(mx + 1) * VpBaseFig();
  321. + if (mx < b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
  322. + mx++; /* NOTE: An additional digit is needed for the compatibility to
  323. + the version 1.2.1 and the former. */
  324. + mx = (mx + 1) * VpBaseFig();
  325. GUARD_OBJ((*c), VpCreateRbObject(mx, "#0"));
  326. GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
  327. VpDivd(*c, *res, a, b);
  328. diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
  329. index 676e05b..7be9d72 100644
  330. --- a/ext/bigdecimal/bigdecimal.gemspec
  331. +++ b/ext/bigdecimal/bigdecimal.gemspec
  332. @@ -1,5 +1,5 @@
  333. # -*- ruby -*-
  334. -_VERSION = "1.2.3"
  335. +_VERSION = "1.2.4"
  336. date = %w$Date:: $[1]
  337. Gem::Specification.new do |s|
  338. diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
  339. index ec71350..206470c 100644
  340. --- a/ext/openssl/ossl_ssl.c
  341. +++ b/ext/openssl/ossl_ssl.c
  342. @@ -2229,7 +2229,9 @@ Init_ossl_ssl()
  343. ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
  344. ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG);
  345. ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER);
  346. +#if defined(SSL_OP_MSIE_SSLV2_RSA_PADDING)
  347. ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING);
  348. +#endif
  349. ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG);
  350. ossl_ssl_def_const(OP_TLS_D5_BUG);
  351. ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG);
  352. diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
  353. index 97c02fc..c74fb32 100644
  354. --- a/ext/socket/rubysocket.h
  355. +++ b/ext/socket/rubysocket.h
  356. @@ -374,6 +374,12 @@ void rsock_init_sockopt(void);
  357. void rsock_init_sockifaddr(void);
  358. void rsock_init_socket_init(void);
  359. +NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE));
  360. +NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE));
  361. +NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len));
  362. +NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai));
  363. +NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai));
  364. +
  365. NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE));
  366. NORETURN(void rsock_sys_fail_path(const char *, VALUE));
  367. NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len));
  368. diff --git a/ext/socket/socket.c b/ext/socket/socket.c
  369. index 5fd7465..c7fc5b7 100644
  370. --- a/ext/socket/socket.c
  371. +++ b/ext/socket/socket.c
  372. @@ -15,6 +15,12 @@ static VALUE sock_s_unpack_sockaddr_in(VALUE, VALUE);
  373. void
  374. rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
  375. {
  376. + rsock_syserr_fail_host_port(errno, mesg, host, port);
  377. +}
  378. +
  379. +void
  380. +rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port)
  381. +{
  382. VALUE message;
  383. port = rb_String(port);
  384. @@ -22,13 +28,20 @@ rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
  385. message = rb_sprintf("%s for \"%s\" port %s",
  386. mesg, StringValueCStr(host), StringValueCStr(port));
  387. - rb_sys_fail_str(message);
  388. + rb_syserr_fail_str(err, message);
  389. }
  390. void
  391. rsock_sys_fail_path(const char *mesg, VALUE path)
  392. {
  393. + rsock_syserr_fail_path(errno, mesg, path);
  394. +}
  395. +
  396. +void
  397. +rsock_syserr_fail_path(int err, const char *mesg, VALUE path)
  398. +{
  399. VALUE message;
  400. +
  401. if (RB_TYPE_P(path, T_STRING)) {
  402. if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
  403. path = rb_str_inspect(path);
  404. @@ -39,45 +52,64 @@ rsock_sys_fail_path(const char *mesg, VALUE path)
  405. message = rb_sprintf("%s for \"%s\"", mesg,
  406. StringValueCStr(path));
  407. }
  408. - rb_sys_fail_str(message);
  409. + rb_syserr_fail_str(err, message);
  410. }
  411. else {
  412. - rb_sys_fail(mesg);
  413. + rb_syserr_fail(err, mesg);
  414. }
  415. }
  416. void
  417. rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
  418. {
  419. + rsock_syserr_fail_sockaddr(errno, mesg, addr, len);
  420. +}
  421. +
  422. +void
  423. +rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)
  424. +{
  425. VALUE rai;
  426. rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil);
  427. - rsock_sys_fail_raddrinfo(mesg, rai);
  428. + rsock_syserr_fail_raddrinfo(err, mesg, rai);
  429. }
  430. void
  431. rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
  432. {
  433. + rsock_syserr_fail_raddrinfo(errno, mesg, rai);
  434. +}
  435. +
  436. +void
  437. +rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)
  438. +{
  439. VALUE str, message;
  440. str = rsock_addrinfo_inspect_sockaddr(rai);
  441. message = rb_sprintf("%s for %s", mesg, StringValueCStr(str));
  442. - rb_sys_fail_str(message);
  443. + rb_syserr_fail_str(err, message);
  444. }
  445. void
  446. rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
  447. {
  448. + rsock_syserr_fail_raddrinfo_or_sockaddr(errno, mesg, addr, rai);
  449. +}
  450. +
  451. +void
  452. +rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)
  453. +{
  454. if (NIL_P(rai)) {
  455. StringValue(addr);
  456. - rsock_sys_fail_sockaddr(mesg,
  457. +
  458. + rsock_syserr_fail_sockaddr(err, mesg,
  459. (struct sockaddr *)RSTRING_PTR(addr),
  460. (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */
  461. }
  462. else
  463. - rsock_sys_fail_raddrinfo(mesg, rai);
  464. + rsock_syserr_fail_raddrinfo(err, mesg, rai);
  465. }
  466. static void
  467. diff --git a/ext/thread/thread.c b/ext/thread/thread.c
  468. index b8be5d8..a8f675c 100644
  469. --- a/ext/thread/thread.c
  470. +++ b/ext/thread/thread.c
  471. @@ -437,7 +437,7 @@ rb_szqueue_max_set(VALUE self, VALUE vmax)
  472. diff = max - GET_SZQUEUE_ULONGMAX(self);
  473. }
  474. RSTRUCT_SET(self, SZQUEUE_MAX, vmax);
  475. - while (diff > 0 && !NIL_P(t = rb_ary_shift(GET_QUEUE_QUE(self)))) {
  476. + while (diff-- > 0 && !NIL_P(t = rb_ary_shift(GET_SZQUEUE_WAITERS(self)))) {
  477. rb_thread_wakeup_alive(t);
  478. }
  479. return vmax;
  480. @@ -459,7 +459,7 @@ static VALUE
  481. rb_szqueue_push(VALUE self, VALUE obj)
  482. {
  483. struct waiting_delete args;
  484. - args.waiting = GET_QUEUE_WAITERS(self);
  485. + args.waiting = GET_SZQUEUE_WAITERS(self);
  486. args.th = rb_thread_current();
  487. while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
  488. diff --git a/gc.c b/gc.c
  489. index 19e942d..e51b727 100644
  490. --- a/gc.c
  491. +++ b/gc.c
  492. @@ -2916,7 +2916,9 @@ gc_before_sweep(rb_objspace_t *objspace)
  493. }
  494. }
  495. - if (0) fprintf(stderr, "%d\t%d\t%u\t%u\t%d\n", (int)rb_gc_count(), objspace->rgengc.need_major_gc,
  496. + if (0) fprintf(stderr, "%d\t%d\t%u\t%u\t%d\n",
  497. + (int)rb_gc_count(),
  498. + (int)objspace->rgengc.need_major_gc,
  499. (unsigned int)objspace->rgengc.oldmalloc_increase,
  500. (unsigned int)objspace->rgengc.oldmalloc_increase_limit,
  501. (unsigned int)gc_params.oldmalloc_limit_max);
  502. @@ -5647,7 +5649,7 @@ get_envparam_int(const char *name, unsigned int *default_value, int lower_bound)
  503. if (ptr != NULL) {
  504. val = atoi(ptr);
  505. - if (val > lower_bound) {
  506. + if (val >= lower_bound) {
  507. if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%d (%d)\n", name, val, *default_value);
  508. *default_value = val;
  509. return 1;
  510. @@ -5667,7 +5669,7 @@ get_envparam_double(const char *name, double *default_value, double lower_bound)
  511. if (ptr != NULL) {
  512. val = strtod(ptr, NULL);
  513. - if (val > lower_bound) {
  514. + if (val >= lower_bound) {
  515. if (RTEST(ruby_verbose)) fprintf(stderr, "%s=%f (%f)\n", name, val, *default_value);
  516. *default_value = val;
  517. return 1;
  518. @@ -5746,7 +5748,10 @@ ruby_gc_set_params(int safe_level)
  519. get_envparam_double("RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR", &gc_params.malloc_limit_growth_factor, 1.0);
  520. #ifdef RGENGC_ESTIMATE_OLDMALLOC
  521. - get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0);
  522. + if (get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) {
  523. + rb_objspace_t *objspace = &rb_objspace;
  524. + objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
  525. + }
  526. get_envparam_int("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0);
  527. get_envparam_double("RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR", &gc_params.oldmalloc_limit_growth_factor, 1.0);
  528. #endif
  529. diff --git a/hash.c b/hash.c
  530. index 1fa40b1..1c285c2 100644
  531. --- a/hash.c
  532. +++ b/hash.c
  533. @@ -27,12 +27,24 @@
  534. # endif
  535. #endif
  536. -#define HAS_MISC_ATTRIBUTES(hash, klass) ( \
  537. - (klass = rb_obj_class(hash)) != rb_cHash || \
  538. - (klass = 0, \
  539. - FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \
  540. - !NIL_P(RHASH_IFNONE(hash))))
  541. -#define HASH_REJECT_COPY_MISC_ATTRIBUTES 1
  542. +#define HAS_EXTRA_STATES(hash, klass) ( \
  543. + ((klass = has_extra_methods(rb_obj_class(hash))) != 0) || \
  544. + FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \
  545. + !NIL_P(RHASH_IFNONE(hash)))
  546. +#define HASH_REJECT_COPY_EXTRA_STATES 1
  547. +
  548. +static VALUE
  549. +has_extra_methods(VALUE klass)
  550. +{
  551. + const VALUE base = rb_cHash;
  552. + VALUE c = klass;
  553. + while (c != base) {
  554. + st_table *mtbl = RCLASS_M_TBL(c);
  555. + if (mtbl && mtbl->num_entries) return klass;
  556. + c = RCLASS_SUPER(c);
  557. + }
  558. + return 0;
  559. +}
  560. static VALUE rb_hash_s_try_convert(VALUE, VALUE);
  561. @@ -111,6 +123,8 @@ rb_hash(VALUE obj)
  562. return hval;
  563. }
  564. +long rb_objid_hash(st_index_t index);
  565. +
  566. static st_index_t
  567. rb_any_hash(VALUE a)
  568. {
  569. @@ -119,9 +133,7 @@ rb_any_hash(VALUE a)
  570. if (SPECIAL_CONST_P(a)) {
  571. if (a == Qundef) return 0;
  572. - hnum = rb_hash_start((st_index_t)a);
  573. - hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash);
  574. - hnum = rb_hash_end(hnum);
  575. + hnum = rb_objid_hash((st_index_t)a);
  576. }
  577. else if (BUILTIN_TYPE(a) == T_STRING) {
  578. hnum = rb_str_hash(a);
  579. @@ -134,6 +146,15 @@ rb_any_hash(VALUE a)
  580. return (st_index_t)RSHIFT(hnum, 1);
  581. }
  582. +long
  583. +rb_objid_hash(st_index_t index)
  584. +{
  585. + st_index_t hnum = rb_hash_start(index);
  586. + hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash);
  587. + hnum = rb_hash_end(hnum);
  588. + return hnum;
  589. +}
  590. +
  591. static const struct st_hash_type objhash = {
  592. rb_any_cmp,
  593. rb_any_hash,
  594. @@ -1133,11 +1154,11 @@ rb_hash_reject(VALUE hash)
  595. RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
  596. if (RTEST(ruby_verbose)) {
  597. VALUE klass;
  598. - if (HAS_MISC_ATTRIBUTES(hash, klass)) {
  599. -#if HASH_REJECT_COPY_MISC_ATTRIBUTES
  600. - rb_warn("copying unguaranteed attributes: %+"PRIsVALUE, hash);
  601. - rb_warn("following atributes will not be copied in the future version:");
  602. - if (klass != rb_cHash) {
  603. + if (HAS_EXTRA_STATES(hash, klass)) {
  604. +#if HASH_REJECT_COPY_EXTRA_STATES
  605. + rb_warn("copying extra states: %+"PRIsVALUE, hash);
  606. + rb_warn("following states will not be copied in the future version:");
  607. + if (klass) {
  608. rb_warn(" subclass: %+"PRIsVALUE, klass);
  609. }
  610. if (FL_TEST(hash, FL_EXIVAR)) {
  611. @@ -1153,8 +1174,7 @@ rb_hash_reject(VALUE hash)
  612. else if (!NIL_P(RHASH_IFNONE(hash)))
  613. rb_warn(" default value: %+"PRIsVALUE, RHASH_IFNONE(hash));
  614. #else
  615. - rb_warn("unguaranteed attributes are not copied: %+"PRIsVALUE, hash);
  616. - rb_warn("following atributes are ignored now:");
  617. + rb_warn("extra states are no longer copied: %+"PRIsVALUE, hash);
  618. #endif
  619. }
  620. }
  621. diff --git a/lib/delegate.rb b/lib/delegate.rb
  622. index c33f7e4..d790229 100644
  623. --- a/lib/delegate.rb
  624. +++ b/lib/delegate.rb
  625. @@ -48,7 +48,7 @@ class Delegator < BasicObject
  626. undef_method m
  627. end
  628. private_instance_methods.each do |m|
  629. - if /\Ablock_given\?\z|iterator\?\z|\A__raise__\z/ =~ m
  630. + if /\Ablock_given\?\z|iterator\?\z|\A__.*__\z/ =~ m
  631. next
  632. end
  633. undef_method m
  634. diff --git a/lib/rubygems.rb b/lib/rubygems.rb
  635. index 73c4846..456273e 100644
  636. --- a/lib/rubygems.rb
  637. +++ b/lib/rubygems.rb
  638. @@ -8,7 +8,7 @@
  639. require 'rbconfig'
  640. module Gem
  641. - VERSION = '2.2.0'
  642. + VERSION = '2.2.2'
  643. end
  644. # Must be first since it unloads the prelude from 1.9.2
  645. @@ -572,7 +572,7 @@ module Gem
  646. # gem's paths are inserted before site lib directory by default.
  647. def self.load_path_insert_index
  648. - index = $LOAD_PATH.index ConfigMap[:sitelibdir]
  649. + index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
  650. index
  651. end
  652. @@ -743,8 +743,8 @@ module Gem
  653. def self.prefix
  654. prefix = File.dirname RUBYGEMS_DIR
  655. - if prefix != File.expand_path(ConfigMap[:sitelibdir]) and
  656. - prefix != File.expand_path(ConfigMap[:libdir]) and
  657. + if prefix != File.expand_path(RbConfig::CONFIG['sitelibdir']) and
  658. + prefix != File.expand_path(RbConfig::CONFIG['libdir']) and
  659. 'lib' == File.basename(RUBYGEMS_DIR) then
  660. prefix
  661. end
  662. @@ -765,6 +765,10 @@ module Gem
  663. f.flock(File::LOCK_EX)
  664. f.read
  665. end
  666. + rescue Errno::EACCES
  667. + open path, 'rb' do |f|
  668. + f.read
  669. + end
  670. end
  671. ##
  672. @@ -772,8 +776,8 @@ module Gem
  673. def self.ruby
  674. if @ruby.nil? then
  675. - @ruby = File.join(ConfigMap[:bindir],
  676. - "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}")
  677. + @ruby = File.join(RbConfig::CONFIG['bindir'],
  678. + "#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}")
  679. @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/
  680. end
  681. @@ -785,8 +789,7 @@ module Gem
  682. # Returns a String containing the API compatibility version of Ruby
  683. def self.ruby_api_version
  684. - @ruby_api_version ||=
  685. - "#{ConfigMap[:MAJOR]}.#{ConfigMap[:MINOR]}.#{ConfigMap[:TEENY]}"
  686. + @ruby_api_version ||= RbConfig::CONFIG['ruby_version'].dup
  687. end
  688. ##
  689. diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
  690. index d8655af..fabdd6e 100644
  691. --- a/lib/rubygems/available_set.rb
  692. +++ b/lib/rubygems/available_set.rb
  693. @@ -4,9 +4,12 @@ class Gem::AvailableSet
  694. Tuple = Struct.new(:spec, :source)
  695. + attr_accessor :remote # :nodoc:
  696. +
  697. def initialize
  698. @set = []
  699. @sorted = nil
  700. + @remote = true
  701. end
  702. attr_reader :set
  703. diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
  704. index a52377f..470a6eb 100644
  705. --- a/lib/rubygems/basic_specification.rb
  706. +++ b/lib/rubygems/basic_specification.rb
  707. @@ -207,6 +207,24 @@ class Gem::BasicSpecification
  708. end
  709. ##
  710. + # Returns the paths to the source files for use with analysis and
  711. + # documentation tools. These paths are relative to full_gem_path.
  712. +
  713. + def source_paths
  714. + paths = raw_require_paths.dup
  715. +
  716. + if @extensions then
  717. + ext_dirs = @extensions.map do |extension|
  718. + extension.split(File::SEPARATOR, 2).first
  719. + end.uniq
  720. +
  721. + paths.concat ext_dirs
  722. + end
  723. +
  724. + paths.uniq
  725. + end
  726. +
  727. + ##
  728. # Return a Gem::Specification from this gem
  729. def to_spec
  730. diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
  731. index 9721884..603f1d0 100644
  732. --- a/lib/rubygems/commands/contents_command.rb
  733. +++ b/lib/rubygems/commands/contents_command.rb
  734. @@ -94,11 +94,11 @@ prefix or only the files that are requireable.
  735. spec.files.sort.map do |file|
  736. case file
  737. when /\A#{spec.bindir}\//
  738. - [Gem::ConfigMap[:bindir], $POSTMATCH]
  739. + [RbConfig::CONFIG['bindir'], $POSTMATCH]
  740. when /\.so\z/
  741. - [Gem::ConfigMap[:archdir], file]
  742. + [RbConfig::CONFIG['archdir'], file]
  743. else
  744. - [Gem::ConfigMap[:rubylibdir], file]
  745. + [RbConfig::CONFIG['rubylibdir'], file]
  746. end
  747. end
  748. end
  749. diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
  750. index a7db013..ca6f694 100644
  751. --- a/lib/rubygems/commands/generate_index_command.rb
  752. +++ b/lib/rubygems/commands/generate_index_command.rb
  753. @@ -62,7 +62,7 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
  754. end
  755. def execute
  756. - # This is always true becasue it's the only way now.
  757. + # This is always true because it's the only way now.
  758. options[:build_modern] = true
  759. if not File.exist?(options[:directory]) or
  760. diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
  761. index 4485eb1..8219eef 100644
  762. --- a/lib/rubygems/commands/install_command.rb
  763. +++ b/lib/rubygems/commands/install_command.rb
  764. @@ -228,7 +228,18 @@ to write the specification by hand. For example:
  765. def install_gem_without_dependencies name, req # :nodoc:
  766. gem = nil
  767. - if remote? then
  768. + if local? then
  769. + if name =~ /\.gem$/ and File.file? name then
  770. + source = Gem::Source::SpecificFile.new name
  771. + spec = source.spec
  772. + else
  773. + source = Gem::Source::Local.new
  774. + spec = source.find_gem name, req
  775. + end
  776. + gem = source.download spec if spec
  777. + end
  778. +
  779. + if remote? and not gem then
  780. dependency = Gem::Dependency.new name, req
  781. dependency.prerelease = options[:prerelease]
  782. @@ -236,13 +247,6 @@ to write the specification by hand. For example:
  783. gem = fetcher.download_to_cache dependency
  784. end
  785. - if local? and not gem then
  786. - source = Gem::Source::Local.new
  787. - spec = source.find_gem name, req
  788. -
  789. - gem = source.download spec
  790. - end
  791. -
  792. inst = Gem::Installer.new gem, options
  793. inst.install
  794. diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
  795. index face77f..681db0d 100644
  796. --- a/lib/rubygems/commands/setup_command.rb
  797. +++ b/lib/rubygems/commands/setup_command.rb
  798. @@ -13,7 +13,7 @@ class Gem::Commands::SetupCommand < Gem::Command
  799. super 'setup', 'Install RubyGems',
  800. :format_executable => true, :document => %w[ri],
  801. - :site_or_vendor => :sitelibdir,
  802. + :site_or_vendor => 'sitelibdir',
  803. :destdir => '', :prefix => '', :previous_version => ''
  804. add_option '--previous-version=VERSION',
  805. @@ -36,7 +36,7 @@ class Gem::Commands::SetupCommand < Gem::Command
  806. add_option '--[no-]vendor',
  807. 'Install into vendorlibdir not sitelibdir' do |vendor, options|
  808. - options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir
  809. + options[:site_or_vendor] = vendor ? 'vendorlibdir' : 'sitelibdir'
  810. end
  811. add_option '--[no-]format-executable',
  812. @@ -343,19 +343,19 @@ TEXT
  813. site_or_vendor = options[:site_or_vendor]
  814. if prefix.empty? then
  815. - lib_dir = Gem::ConfigMap[site_or_vendor]
  816. - bin_dir = Gem::ConfigMap[:bindir]
  817. + lib_dir = RbConfig::CONFIG[site_or_vendor]
  818. + bin_dir = RbConfig::CONFIG['bindir']
  819. else
  820. # Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets
  821. # confused about installation location, so switch back to
  822. # sitelibdir/vendorlibdir.
  823. if defined?(APPLE_GEM_HOME) and
  824. # just in case Apple and RubyGems don't get this patched up proper.
  825. - (prefix == Gem::ConfigMap[:libdir] or
  826. + (prefix == RbConfig::CONFIG['libdir'] or
  827. # this one is important
  828. - prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then
  829. - lib_dir = Gem::ConfigMap[site_or_vendor]
  830. - bin_dir = Gem::ConfigMap[:bindir]
  831. + prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby')) then
  832. + lib_dir = RbConfig::CONFIG[site_or_vendor]
  833. + bin_dir = RbConfig::CONFIG['bindir']
  834. else
  835. lib_dir = File.join prefix, 'lib'
  836. bin_dir = File.join prefix, 'bin'
  837. diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
  838. index 5e8618f..d06ade1 100644
  839. --- a/lib/rubygems/compatibility.rb
  840. +++ b/lib/rubygems/compatibility.rb
  841. @@ -33,6 +33,8 @@ end
  842. module Gem
  843. RubyGemsVersion = VERSION
  844. + # TODO remove at RubyGems 3
  845. +
  846. RbConfigPriorities = %w[
  847. MAJOR
  848. MINOR
  849. @@ -45,7 +47,7 @@ module Gem
  850. unless defined?(ConfigMap)
  851. ##
  852. # Configuration settings from ::RbConfig
  853. - ConfigMap = Hash.new do |cm, key|
  854. + ConfigMap = Hash.new do |cm, key| # TODO remove at RubyGems 3
  855. cm[key] = RbConfig::CONFIG[key.to_s]
  856. end
  857. else
  858. diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
  859. index 1acae9b..cf14017 100644
  860. --- a/lib/rubygems/config_file.rb
  861. +++ b/lib/rubygems/config_file.rb
  862. @@ -137,9 +137,10 @@ class Gem::ConfigFile
  863. attr_reader :ssl_verify_mode
  864. ##
  865. - # Path name of directory or file of openssl CA certificate, used for remote https connection
  866. + # Path name of directory or file of openssl CA certificate, used for remote
  867. + # https connection
  868. - attr_reader :ssl_ca_cert
  869. + attr_accessor :ssl_ca_cert
  870. ##
  871. # Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
  872. diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
  873. index 715c0b7..6924f48 100644
  874. --- a/lib/rubygems/defaults.rb
  875. +++ b/lib/rubygems/defaults.rb
  876. @@ -29,22 +29,22 @@ module Gem
  877. def self.default_dir
  878. path = if defined? RUBY_FRAMEWORK_VERSION then
  879. [
  880. - File.dirname(ConfigMap[:sitedir]),
  881. + File.dirname(RbConfig::CONFIG['sitedir']),
  882. 'Gems',
  883. - ConfigMap[:ruby_version]
  884. + RbConfig::CONFIG['ruby_version']
  885. ]
  886. - elsif ConfigMap[:rubylibprefix] then
  887. + elsif RbConfig::CONFIG['rubylibprefix'] then
  888. [
  889. - ConfigMap[:rubylibprefix],
  890. + RbConfig::CONFIG['rubylibprefix'],
  891. 'gems',
  892. - ConfigMap[:ruby_version]
  893. + RbConfig::CONFIG['ruby_version']
  894. ]
  895. else
  896. [
  897. - ConfigMap[:libdir],
  898. + RbConfig::CONFIG['libdir'],
  899. ruby_engine,
  900. 'gems',
  901. - ConfigMap[:ruby_version]
  902. + RbConfig::CONFIG['ruby_version']
  903. ]
  904. end
  905. @@ -74,7 +74,7 @@ module Gem
  906. def self.user_dir
  907. parts = [Gem.user_home, '.gem', ruby_engine]
  908. - parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty?
  909. + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
  910. File.join parts
  911. end
  912. @@ -100,7 +100,7 @@ module Gem
  913. # Deduce Ruby's --program-prefix and --program-suffix from its install name
  914. def self.default_exec_format
  915. - exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
  916. + exec_format = RbConfig::CONFIG['ruby_install_name'].sub('ruby', '%s') rescue '%s'
  917. unless exec_format =~ /%s/ then
  918. raise Gem::Exception,
  919. @@ -117,7 +117,7 @@ module Gem
  920. if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
  921. '/usr/bin'
  922. else # generic install
  923. - ConfigMap[:bindir]
  924. + RbConfig::CONFIG['bindir']
  925. end
  926. end
  927. diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
  928. index b7babf6..da6994a 100644
  929. --- a/lib/rubygems/dependency_installer.rb
  930. +++ b/lib/rubygems/dependency_installer.rb
  931. @@ -419,6 +419,7 @@ class Gem::DependencyInstaller
  932. request_set = as.to_request_set install_development_deps
  933. request_set.soft_missing = @force
  934. + request_set.remote = false unless consider_remote?
  935. installer_set = Gem::Resolver::InstallerSet.new @domain
  936. installer_set.always_install.concat request_set.always_install
  937. diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
  938. index 274d6a5..e19360d 100644
  939. --- a/lib/rubygems/deprecate.rb
  940. +++ b/lib/rubygems/deprecate.rb
  941. @@ -50,7 +50,7 @@ module Gem::Deprecate
  942. class_eval {
  943. old = "_deprecated_#{name}"
  944. alias_method old, name
  945. - define_method name do |*args, &block| # TODO: really works on 1.8.7?
  946. + define_method name do |*args, &block|
  947. klass = self.kind_of? Module
  948. target = klass ? "#{self}." : "#{self.class}#"
  949. msg = [ "NOTE: #{target}#{name} is deprecated",
  950. diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
  951. index 402aa96..990fd18 100644
  952. --- a/lib/rubygems/ext/ext_conf_builder.rb
  953. +++ b/lib/rubygems/ext/ext_conf_builder.rb
  954. @@ -34,7 +34,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
  955. ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ')
  956. cmd = [Gem.ruby, File.basename(extension), *args].join ' '
  957. - run cmd, results
  958. + begin
  959. + run cmd, results
  960. + ensure
  961. + FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log'
  962. + end
  963. ENV["DESTDIR"] = nil
  964. ENV["RUBYOPT"] = rubyopt
  965. diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
  966. index f8eb2c2..c809816 100644
  967. --- a/lib/rubygems/installer.rb
  968. +++ b/lib/rubygems/installer.rb
  969. @@ -480,7 +480,7 @@ class Gem::Installer
  970. #
  971. def shebang(bin_file_name)
  972. - ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
  973. + ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang
  974. path = File.join gem_dir, spec.bindir, bin_file_name
  975. first_line = File.open(path, "rb") {|file| file.gets}
  976. @@ -493,7 +493,7 @@ class Gem::Installer
  977. if which = Gem.configuration[:custom_shebang]
  978. # replace bin_file_name with "ruby" to avoid endless loops
  979. - which = which.gsub(/ #{bin_file_name}$/," #{Gem::ConfigMap[:ruby_install_name]}")
  980. + which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}")
  981. which = which.gsub(/\$(\w+)/) do
  982. case $1
  983. @@ -641,7 +641,7 @@ version = "#{Gem::Requirement.default}"
  984. if ARGV.first
  985. str = ARGV.first
  986. str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  987. - if str =~ /\\A_(.*)_\\z/
  988. + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
  989. version = $1
  990. ARGV.shift
  991. end
  992. diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
  993. index 28da1db..f9ab13a 100644
  994. --- a/lib/rubygems/package/tar_header.rb
  995. +++ b/lib/rubygems/package/tar_header.rb
  996. @@ -134,7 +134,7 @@ class Gem::Package::TarHeader
  997. vals[:gid] ||= 0
  998. vals[:mtime] ||= 0
  999. vals[:checksum] ||= ""
  1000. - vals[:typeflag] ||= "0"
  1001. + vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty?
  1002. vals[:magic] ||= "ustar"
  1003. vals[:version] ||= "00"
  1004. vals[:uname] ||= "wheel"
  1005. diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
  1006. index e050959..1bcd754 100644
  1007. --- a/lib/rubygems/platform.rb
  1008. +++ b/lib/rubygems/platform.rb
  1009. @@ -16,7 +16,7 @@ class Gem::Platform
  1010. attr_accessor :version
  1011. def self.local
  1012. - arch = Gem::ConfigMap[:arch]
  1013. + arch = RbConfig::CONFIG['arch']
  1014. arch = "#{arch}_60" if arch =~ /mswin32$/
  1015. @local ||= new(arch)
  1016. end
  1017. diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb
  1018. index 52249dc..633bd89 100644
  1019. --- a/lib/rubygems/rdoc.rb
  1020. +++ b/lib/rubygems/rdoc.rb
  1021. @@ -193,7 +193,7 @@ class Gem::RDoc # :nodoc: all
  1022. ::RDoc::Parser::C.reset
  1023. args = @spec.rdoc_options
  1024. - args.concat @spec.require_paths
  1025. + args.concat @spec.source_paths
  1026. args.concat @spec.extra_rdoc_files
  1027. case config_args = Gem.configuration[:rdoc]
  1028. diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
  1029. index e32c024..58991ca 100644
  1030. --- a/lib/rubygems/remote_fetcher.rb
  1031. +++ b/lib/rubygems/remote_fetcher.rb
  1032. @@ -131,11 +131,19 @@ class Gem::RemoteFetcher
  1033. FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
  1034. - # Always escape URI's to deal with potential spaces and such
  1035. - unless URI::Generic === source_uri
  1036. - source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
  1037. - URI::DEFAULT_PARSER.escape(source_uri.to_s) :
  1038. - URI.escape(source_uri.to_s))
  1039. + # Always escape URI's to deal with potential spaces and such
  1040. + # It should also be considered that source_uri may already be
  1041. + # a valid URI with escaped characters. e.g. "{DESede}" is encoded
  1042. + # as "%7BDESede%7D". If this is escaped again the percentage
  1043. + # symbols will be escaped.
  1044. + unless source_uri.is_a?(URI::Generic)
  1045. + begin
  1046. + source_uri = URI.parse(source_uri)
  1047. + rescue
  1048. + source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
  1049. + URI::DEFAULT_PARSER.escape(source_uri.to_s) :
  1050. + URI.escape(source_uri.to_s))
  1051. + end
  1052. end
  1053. scheme = source_uri.scheme
  1054. @@ -285,20 +293,20 @@ class Gem::RemoteFetcher
  1055. def cache_update_path uri, path = nil, update = true
  1056. mtime = path && File.stat(path).mtime rescue nil
  1057. - if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true)
  1058. - Gem.read_binary(path)
  1059. - else
  1060. - data = fetch_path(uri)
  1061. + data = fetch_path(uri, mtime)
  1062. - if update and path then
  1063. - open(path, 'wb') do |io|
  1064. - io.flock(File::LOCK_EX)
  1065. - io.write data
  1066. - end
  1067. - end
  1068. + if data == nil # indicates the server returned 304 Not Modified
  1069. + return Gem.read_binary(path)
  1070. + end
  1071. - data
  1072. + if update and path
  1073. + open(path, 'wb') do |io|
  1074. + io.flock(File::LOCK_EX)
  1075. + io.write data
  1076. + end
  1077. end
  1078. +
  1079. + data
  1080. end
  1081. ##
  1082. diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
  1083. index e870763..d2f076f 100644
  1084. --- a/lib/rubygems/request.rb
  1085. +++ b/lib/rubygems/request.rb
  1086. @@ -48,15 +48,14 @@ class Gem::Request
  1087. connection.key = OpenSSL::PKey::RSA.new pem
  1088. end
  1089. + store.set_default_paths
  1090. + add_rubygems_trusted_certs(store)
  1091. if Gem.configuration.ssl_ca_cert
  1092. if File.directory? Gem.configuration.ssl_ca_cert
  1093. store.add_path Gem.configuration.ssl_ca_cert
  1094. else
  1095. store.add_file Gem.configuration.ssl_ca_cert
  1096. end
  1097. - else
  1098. - store.set_default_paths
  1099. - add_rubygems_trusted_certs(store)
  1100. end
  1101. connection.cert_store = store
  1102. rescue LoadError => e
  1103. @@ -106,7 +105,8 @@ class Gem::Request
  1104. request = @request_class.new @uri.request_uri
  1105. unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then
  1106. - request.basic_auth @uri.user, @uri.password
  1107. + request.basic_auth Gem::UriFormatter.new(@uri.user).unescape,
  1108. + Gem::UriFormatter.new(@uri.password).unescape
  1109. end
  1110. request.add_field 'User-Agent', @user_agent
  1111. diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
  1112. index aa3f27c..fb54e34 100644
  1113. --- a/lib/rubygems/request_set.rb
  1114. +++ b/lib/rubygems/request_set.rb
  1115. @@ -39,6 +39,11 @@ class Gem::RequestSet
  1116. attr_accessor :ignore_dependencies
  1117. ##
  1118. + # When false no remote sets are used for resolving gems.
  1119. +
  1120. + attr_accessor :remote
  1121. +
  1122. + ##
  1123. # Sets used for resolution
  1124. attr_reader :sets # :nodoc:
  1125. @@ -71,6 +76,7 @@ class Gem::RequestSet
  1126. @git_set = nil
  1127. @ignore_dependencies = false
  1128. @install_dir = Gem.dir
  1129. + @remote = true
  1130. @requests = []
  1131. @sets = []
  1132. @soft_missing = false
  1133. @@ -150,6 +156,7 @@ class Gem::RequestSet
  1134. gemdeps = options[:gemdeps]
  1135. @install_dir = options[:install_dir] || Gem.dir
  1136. + @remote = options[:domain] != :local
  1137. load_gemdeps gemdeps, options[:without_groups]
  1138. @@ -235,6 +242,7 @@ class Gem::RequestSet
  1139. @sets << @vendor_set
  1140. set = Gem::Resolver.compose_sets(*@sets)
  1141. + set.remote = @remote
  1142. resolver = Gem::Resolver.new @dependencies, set
  1143. resolver.development = @development
  1144. diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
  1145. index 522caf1..0433d2a 100644
  1146. --- a/lib/rubygems/request_set/lockfile.rb
  1147. +++ b/lib/rubygems/request_set/lockfile.rb
  1148. @@ -303,7 +303,12 @@ class Gem::RequestSet::Lockfile
  1149. type, data, = get [:text, :requirement]
  1150. if type == :text and column == 4 then
  1151. - last_spec = set.add name, data, Gem::Platform::RUBY
  1152. + version, platform = data.split '-', 2
  1153. +
  1154. + platform =
  1155. + platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
  1156. +
  1157. + last_spec = set.add name, version, platform
  1158. else
  1159. dependency = parse_dependency name, data
  1160. diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
  1161. index d455e03..65e92bb 100644
  1162. --- a/lib/rubygems/resolver.rb
  1163. +++ b/lib/rubygems/resolver.rb
  1164. @@ -59,6 +59,8 @@ class Gem::Resolver
  1165. sets = sets.map do |set|
  1166. case set
  1167. + when Gem::Resolver::BestSet then
  1168. + set
  1169. when Gem::Resolver::ComposedSet then
  1170. set.sets
  1171. else
  1172. @@ -179,27 +181,6 @@ class Gem::Resolver
  1173. end
  1174. ##
  1175. - # Finds the State in +states+ that matches the +conflict+ so that we can try
  1176. - # other possible sets.
  1177. - #
  1178. - # If no good candidate is found, the first state is tried.
  1179. -
  1180. - def find_conflict_state conflict, states # :nodoc:
  1181. - until states.empty? do
  1182. - state = states.pop
  1183. -
  1184. - explain :consider, state.dep, conflict.failed_dep
  1185. -
  1186. - if conflict.for_spec? state.spec
  1187. - state.conflicts << [state.spec, conflict]
  1188. - return state
  1189. - end
  1190. - end
  1191. -
  1192. - nil
  1193. - end
  1194. -
  1195. - ##
  1196. # Extracts the specifications that may be able to fulfill +dependency+ and
  1197. # returns those that match the local platform and all those that match.
  1198. diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb
  1199. index 89ee3c9..5475e62 100644
  1200. --- a/lib/rubygems/resolver/api_set.rb
  1201. +++ b/lib/rubygems/resolver/api_set.rb
  1202. @@ -25,10 +25,12 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
  1203. # http://guides.rubygems.org/rubygems-org-api
  1204. def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies'
  1205. + super()
  1206. +
  1207. dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8
  1208. @dep_uri = dep_uri
  1209. - @uri = dep_uri + '../../..'
  1210. + @uri = dep_uri + '../..'
  1211. @data = Hash.new { |h,k| h[k] = [] }
  1212. @source = Gem::Source.new @uri
  1213. @@ -41,6 +43,8 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
  1214. def find_all req
  1215. res = []
  1216. + return res unless @remote
  1217. +
  1218. versions(req.name).each do |ver|
  1219. if req.dependency.match? req.name, ver[:number]
  1220. res << Gem::Resolver::APISpecification.new(self, ver)
  1221. @@ -55,6 +59,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set
  1222. # data for DependencyRequests +reqs+.
  1223. def prefetch reqs
  1224. + return unless @remote
  1225. names = reqs.map { |r| r.dependency.name }
  1226. needed = names - @data.keys
  1227. diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb
  1228. index fa6c9f8..20bb948 100644
  1229. --- a/lib/rubygems/resolver/best_set.rb
  1230. +++ b/lib/rubygems/resolver/best_set.rb
  1231. @@ -12,11 +12,30 @@ class Gem::Resolver::BestSet < Gem::Resolver::ComposedSet
  1232. def initialize sources = Gem.sources
  1233. super()
  1234. - sources.each_source do |source|
  1235. + @sources = sources
  1236. + end
  1237. +
  1238. + ##
  1239. + # Picks which sets to use for the configured sources.
  1240. +
  1241. + def pick_sets # :nodoc:
  1242. + @sources.each_source do |source|
  1243. @sets << source.dependency_resolver_set
  1244. end
  1245. end
  1246. + def find_all req # :nodoc:
  1247. + pick_sets if @remote and @sets.empty?
  1248. +
  1249. + super
  1250. + end
  1251. +
  1252. + def prefetch reqs # :nodoc:
  1253. + pick_sets if @remote and @sets.empty?
  1254. +
  1255. + super
  1256. + end
  1257. +
  1258. def pretty_print q # :nodoc:
  1259. q.group 2, '[BestSet', ']' do
  1260. q.breakable
  1261. diff --git a/lib/rubygems/resolver/composed_set.rb b/lib/rubygems/resolver/composed_set.rb
  1262. index 19227e0..6f912b0 100644
  1263. --- a/lib/rubygems/resolver/composed_set.rb
  1264. +++ b/lib/rubygems/resolver/composed_set.rb
  1265. @@ -16,10 +16,21 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
  1266. # Gem::Resolver::compose_sets instead.
  1267. def initialize *sets
  1268. + super()
  1269. +
  1270. @sets = sets
  1271. end
  1272. ##
  1273. + # Sets the remote network access for all composed sets.
  1274. +
  1275. + def remote= remote
  1276. + super
  1277. +
  1278. + @sets.each { |set| set.remote = remote }
  1279. + end
  1280. +
  1281. + ##
  1282. # Finds all specs matching +req+ in all sets.
  1283. def find_all req
  1284. diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb
  1285. index 1a2b230..d32710e 100644
  1286. --- a/lib/rubygems/resolver/git_set.rb
  1287. +++ b/lib/rubygems/resolver/git_set.rb
  1288. @@ -33,6 +33,8 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
  1289. attr_reader :specs # :nodoc:
  1290. def initialize # :nodoc:
  1291. + super()
  1292. +
  1293. @git = ENV['git'] || 'git'
  1294. @need_submodules = {}
  1295. @repositories = {}
  1296. @@ -91,6 +93,7 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
  1297. @repositories.each do |name, (repository, reference)|
  1298. source = Gem::Source::Git.new name, repository, reference
  1299. source.root_dir = @root_dir
  1300. + source.remote = @remote
  1301. source.specs.each do |spec|
  1302. git_spec = Gem::Resolver::GitSpecification.new self, spec, source
  1303. diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb
  1304. index a6ef56b..ef01f0f 100644
  1305. --- a/lib/rubygems/resolver/index_set.rb
  1306. +++ b/lib/rubygems/resolver/index_set.rb
  1307. @@ -5,6 +5,8 @@
  1308. class Gem::Resolver::IndexSet < Gem::Resolver::Set
  1309. def initialize source = nil # :nodoc:
  1310. + super()
  1311. +
  1312. @f =
  1313. if source then
  1314. sources = Gem::SourceList.from [source]
  1315. @@ -34,6 +36,8 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
  1316. def find_all req
  1317. res = []
  1318. + return res unless @remote
  1319. +
  1320. name = req.dependency.name
  1321. @all[name].each do |uri, n|
  1322. diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
  1323. index e35e0aa..045c893 100644
  1324. --- a/lib/rubygems/resolver/installer_set.rb
  1325. +++ b/lib/rubygems/resolver/installer_set.rb
  1326. @@ -24,15 +24,17 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
  1327. # Creates a new InstallerSet that will look for gems in +domain+.
  1328. def initialize domain
  1329. + super()
  1330. +
  1331. @domain = domain
  1332. + @remote = consider_remote?
  1333. @f = Gem::SpecFetcher.fetcher
  1334. - @all = Hash.new { |h,k| h[k] = [] }
  1335. @always_install = []
  1336. @ignore_dependencies = false
  1337. @ignore_installed = false
  1338. - @loaded_remote_specs = []
  1339. + @remote_set = Gem::Resolver::BestSet.new
  1340. @specs = {}
  1341. end
  1342. @@ -79,16 +81,7 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
  1343. end
  1344. end
  1345. - if consider_remote? then
  1346. - load_remote_specs dep
  1347. -
  1348. - @all[name].each do |remote_source, n|
  1349. - if dep.match? n then
  1350. - res << Gem::Resolver::IndexSpecification.new(
  1351. - self, n.name, n.version, remote_source, n.platform)
  1352. - end
  1353. - end
  1354. - end
  1355. + res.concat @remote_set.find_all req if consider_remote?
  1356. res
  1357. end
  1358. @@ -102,27 +95,6 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
  1359. end
  1360. ##
  1361. - # Loads remote prerelease specs if +dep+ is a prerelease dependency
  1362. -
  1363. - def load_remote_specs dep # :nodoc:
  1364. - types = [:released]
  1365. - types << :prerelease if dep.prerelease?
  1366. -
  1367. - types.each do |type|
  1368. - next if @loaded_remote_specs.include? type
  1369. - @loaded_remote_specs << type
  1370. -
  1371. - list, = @f.available_specs type
  1372. -
  1373. - list.each do |uri, specs|
  1374. - specs.each do |n|
  1375. - @all[n.name] << [uri, n]
  1376. - end
  1377. - end
  1378. - end
  1379. - end
  1380. -
  1381. - ##
  1382. # Called from IndexSpecification to get a true Specification
  1383. # object.
  1384. @@ -151,5 +123,16 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
  1385. end
  1386. end
  1387. + def remote= remote # :nodoc:
  1388. + case @domain
  1389. + when :local then
  1390. + @domain = :both if remote
  1391. + when :remote then
  1392. + @domain = nil unless remote
  1393. + when :both then
  1394. + @domain = :local unless remote
  1395. + end
  1396. + end
  1397. +
  1398. end
  1399. diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb
  1400. index cdb41b2..f498757 100644
  1401. --- a/lib/rubygems/resolver/lock_set.rb
  1402. +++ b/lib/rubygems/resolver/lock_set.rb
  1403. @@ -9,6 +9,8 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
  1404. # Creates a new LockSet from the given +source+
  1405. def initialize source
  1406. + super()
  1407. +
  1408. @source = Gem::Source::Lock.new source
  1409. @specs = []
  1410. end
  1411. diff --git a/lib/rubygems/resolver/set.rb b/lib/rubygems/resolver/set.rb
  1412. index 32c137e..f053b65 100644
  1413. --- a/lib/rubygems/resolver/set.rb
  1414. +++ b/lib/rubygems/resolver/set.rb
  1415. @@ -5,6 +5,15 @@
  1416. class Gem::Resolver::Set
  1417. ##
  1418. + # Set to true to disable network access for this set
  1419. +
  1420. + attr_accessor :remote
  1421. +
  1422. + def initialize # :nodoc:
  1423. + @remote = true
  1424. + end
  1425. +
  1426. + ##
  1427. # The find_all method must be implemented. It returns all Resolver
  1428. # Specification objects matching the given DependencyRequest +req+.
  1429. @@ -23,5 +32,13 @@ class Gem::Resolver::Set
  1430. def prefetch reqs
  1431. end
  1432. + ##
  1433. + # When true, this set is allowed to access the network when looking up
  1434. + # specifications or dependencies.
  1435. +
  1436. + def remote? # :nodoc:
  1437. + @remote
  1438. + end
  1439. +
  1440. end
  1441. diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb
  1442. index 3db637f..6e86707 100644
  1443. --- a/lib/rubygems/resolver/vendor_set.rb
  1444. +++ b/lib/rubygems/resolver/vendor_set.rb
  1445. @@ -21,6 +21,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
  1446. attr_reader :specs # :nodoc:
  1447. def initialize # :nodoc:
  1448. + super()
  1449. +
  1450. @directories = {}
  1451. @specs = {}
  1452. end
  1453. diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
  1454. index bfd6fd2..8c5fb7d 100644
  1455. --- a/lib/rubygems/security.rb
  1456. +++ b/lib/rubygems/security.rb
  1457. @@ -120,11 +120,11 @@ end
  1458. # * HighSecurity - Here's the bugger that got us into this mess.
  1459. # The HighSecurity policy is identical to the MediumSecurity policy,
  1460. # except that it does not allow unsigned gems. A malicious user
  1461. -# doesn't have a whole lot of options here; he can't modify the
  1462. -# package contents without invalidating the signature, and he can't
  1463. +# doesn't have a whole lot of options here; they can't modify the
  1464. +# package contents without invalidating the signature, and they can't
  1465. # modify or remove signature or the signing certificate chain, or
  1466. # RubyGems will simply refuse to install the package. Oh well, maybe
  1467. -# he'll have better luck causing problems for CPAN users instead :).
  1468. +# they'll have better luck causing problems for CPAN users instead :).
  1469. #
  1470. # The reason RubyGems refused to install your shiny new signed gem was because
  1471. # it was from an untrusted source. Well, your code is infallible (naturally),
  1472. diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
  1473. index 28178a5..2e3fa03 100644
  1474. --- a/lib/rubygems/source/git.rb
  1475. +++ b/lib/rubygems/source/git.rb
  1476. @@ -24,6 +24,11 @@ class Gem::Source::Git < Gem::Source
  1477. attr_reader :reference
  1478. ##
  1479. + # When false the cache for this repository will not be updated.
  1480. +
  1481. + attr_accessor :remote
  1482. +
  1483. + ##
  1484. # The git repository this gem is sourced from.
  1485. attr_reader :repository
  1486. @@ -53,6 +58,7 @@ class Gem::Source::Git < Gem::Source
  1487. @reference = reference
  1488. @need_submodules = submodules
  1489. + @remote = true
  1490. @root_dir = Gem.dir
  1491. @git = ENV['git'] || 'git'
  1492. end
  1493. @@ -85,6 +91,8 @@ class Gem::Source::Git < Gem::Source
  1494. def checkout # :nodoc:
  1495. cache
  1496. + return false unless File.exist? repo_cache_dir
  1497. +
  1498. unless File.exist? install_dir then
  1499. system @git, 'clone', '--quiet', '--no-checkout',
  1500. repo_cache_dir, install_dir
  1501. @@ -107,6 +115,8 @@ class Gem::Source::Git < Gem::Source
  1502. # Creates a local cache repository for the git gem.
  1503. def cache # :nodoc:
  1504. + return unless @remote
  1505. +
  1506. if File.exist? repo_cache_dir then
  1507. Dir.chdir repo_cache_dir do
  1508. system @git, 'fetch', '--quiet', '--force', '--tags',
  1509. @@ -142,6 +152,8 @@ class Gem::Source::Git < Gem::Source
  1510. # The directory where the git gem will be installed.
  1511. def install_dir # :nodoc:
  1512. + return unless File.exist? repo_cache_dir
  1513. +
  1514. File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
  1515. end
  1516. @@ -177,6 +189,8 @@ class Gem::Source::Git < Gem::Source
  1517. def specs
  1518. checkout
  1519. + return [] unless install_dir
  1520. +
  1521. Dir.chdir install_dir do
  1522. Dir['{,*,*/*}.gemspec'].map do |spec_file|
  1523. directory = File.dirname spec_file
  1524. diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
  1525. index 59d71d3..f4e609a 100644
  1526. --- a/lib/rubygems/specification.rb
  1527. +++ b/lib/rubygems/specification.rb
  1528. @@ -241,6 +241,28 @@ class Gem::Specification < Gem::BasicSpecification
  1529. attr_reader :summary
  1530. ##
  1531. + # Singular writer for #authors
  1532. + #
  1533. + # Usage:
  1534. + #
  1535. + # spec.author = 'John Jones'
  1536. +
  1537. + def author= o
  1538. + self.authors = [o]
  1539. + end
  1540. +
  1541. + ##
  1542. + # Sets the list of authors, ensuring it is an array.
  1543. + #
  1544. + # Usage:
  1545. + #
  1546. + # spec.authors = ['John Jones', 'Mary Smith']
  1547. +
  1548. + def authors= value
  1549. + @authors = Array(value).flatten.grep(String)
  1550. + end
  1551. +
  1552. + ##
  1553. # The platform this gem runs on.
  1554. #
  1555. # This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT.
  1556. @@ -327,7 +349,7 @@ class Gem::Specification < Gem::BasicSpecification
  1557. add_bindir(@executables),
  1558. @extra_rdoc_files,
  1559. @extensions,
  1560. - ].flatten.sort.uniq.compact
  1561. + ].flatten.uniq.compact.sort
  1562. end
  1563. ######################################################################
  1564. @@ -443,28 +465,6 @@ class Gem::Specification < Gem::BasicSpecification
  1565. end
  1566. ##
  1567. - # Singular writer for #authors
  1568. - #
  1569. - # Usage:
  1570. - #
  1571. - # spec.author = 'John Jones'
  1572. -
  1573. - def author= o
  1574. - self.authors = [o]
  1575. - end
  1576. -
  1577. - ##
  1578. - # Sets the list of authors, ensuring it is an array.
  1579. - #
  1580. - # Usage:
  1581. - #
  1582. - # spec.authors = ['John Jones', 'Mary Smith']
  1583. -
  1584. - def authors= value
  1585. - @authors = Array(value).flatten.grep(String)
  1586. - end
  1587. -
  1588. - ##
  1589. # Executables included in the gem.
  1590. #
  1591. # For example, the rake gem has rake as an executable. You don’t specify the
  1592. diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
  1593. index 8dc37d6..328731d 100644
  1594. --- a/lib/rubygems/test_case.rb
  1595. +++ b/lib/rubygems/test_case.rb
  1596. @@ -115,6 +115,23 @@ class Gem::TestCase < MiniTest::Unit::TestCase
  1597. assert File.exist?(path), msg
  1598. end
  1599. + ##
  1600. + # Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
  1601. + # the original value when the block ends
  1602. +
  1603. + def enable_shared value
  1604. + enable_shared = RbConfig::CONFIG['ENABLE_SHARED']
  1605. + RbConfig::CONFIG['ENABLE_SHARED'] = value
  1606. +
  1607. + yield
  1608. + ensure
  1609. + if enable_shared then
  1610. + RbConfig::CONFIG['enable_shared'] = enable_shared
  1611. + else
  1612. + RbConfig::CONFIG.delete 'enable_shared'
  1613. + end
  1614. + end
  1615. +
  1616. # TODO: move to minitest
  1617. def refute_path_exists path, msg = nil
  1618. msg = message(msg) { "Expected path '#{path}' to not exist" }
  1619. @@ -294,10 +311,10 @@ class Gem::TestCase < MiniTest::Unit::TestCase
  1620. Gem.searcher = nil
  1621. Gem::SpecFetcher.fetcher = nil
  1622. - @orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
  1623. - Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:ruby_install_name]
  1624. + @orig_BASERUBY = RbConfig::CONFIG['BASERUBY']
  1625. + RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name']
  1626. - @orig_arch = Gem::ConfigMap[:arch]
  1627. + @orig_arch = RbConfig::CONFIG['arch']
  1628. if win_platform?
  1629. util_set_arch 'i386-mswin32'
  1630. @@ -315,8 +332,12 @@ class Gem::TestCase < MiniTest::Unit::TestCase
  1631. def teardown
  1632. $LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
  1633. - Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY
  1634. - Gem::ConfigMap[:arch] = @orig_arch
  1635. + if @orig_BASERUBY
  1636. + RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY
  1637. + else
  1638. + RbConfig::CONFIG.delete('BASERUBY')
  1639. + end
  1640. + RbConfig::CONFIG['arch'] = @orig_arch
  1641. if defined? Gem::RemoteFetcher then
  1642. Gem::RemoteFetcher.fetcher = nil
  1643. @@ -898,7 +919,7 @@ Also, a list:
  1644. # Set the platform to +arch+
  1645. def util_set_arch(arch)
  1646. - Gem::ConfigMap[:arch] = arch
  1647. + RbConfig::CONFIG['arch'] = arch
  1648. platform = Gem::Platform.new arch
  1649. Gem.instance_variable_set :@platforms, nil
  1650. @@ -1245,10 +1266,17 @@ Also, a list:
  1651. class StaticSet
  1652. ##
  1653. + # A StaticSet ignores remote because it has a fixed set of gems.
  1654. +
  1655. + attr_accessor :remote
  1656. +
  1657. + ##
  1658. # Creates a new StaticSet for the given +specs+
  1659. def initialize(specs)
  1660. @specs = specs
  1661. +
  1662. + @remote = true
  1663. end
  1664. ##
  1665. diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
  1666. index 4cb2a1d..fa83833 100644
  1667. --- a/lib/rubygems/uninstaller.rb
  1668. +++ b/lib/rubygems/uninstaller.rb
  1669. @@ -237,7 +237,7 @@ class Gem::Uninstaller
  1670. unless path_ok?(@gem_home, spec) or
  1671. (@user_install and path_ok?(Gem.user_dir, spec)) then
  1672. e = Gem::GemNotInHomeException.new \
  1673. - "Gem is not installed in directory #{@gem_home}"
  1674. + "Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
  1675. e.spec = spec
  1676. raise e
  1677. diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
  1678. index fda8b0b..2066332 100644
  1679. --- a/lib/rubygems/version.rb
  1680. +++ b/lib/rubygems/version.rb
  1681. @@ -22,6 +22,11 @@
  1682. # 3. 1.0.a.2
  1683. # 4. 0.9
  1684. #
  1685. +# If you want to specify a version restriction that includes both prereleases
  1686. +# and regular releases of the 1.x series this is the best way:
  1687. +#
  1688. +# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0'
  1689. +#
  1690. # == How Software Changes
  1691. #
  1692. # Users expect to be able to specify a version constraint that gives them
  1693. @@ -81,8 +86,8 @@
  1694. #
  1695. # * Any "public" release of a gem should have a different version. Normally
  1696. # that means incrementing the build number. This means a developer can
  1697. -# generate builds all day long for himself, but as soon as he/she makes a
  1698. -# public release, the version must be updated.
  1699. +# generate builds all day long, but as soon as they make a public release,
  1700. +# the version must be updated.
  1701. #
  1702. # === Examples
  1703. #
  1704. @@ -99,26 +104,25 @@
  1705. # Version 1.1.1:: Fixed a bug in the linked list implementation.
  1706. # Version 1.1.2:: Fixed a bug introduced in the last fix.
  1707. #
  1708. -# Client A needs a stack with basic push/pop capability. He writes to the
  1709. -# original interface (no <tt>top</tt>), so his version constraint looks
  1710. -# like:
  1711. +# Client A needs a stack with basic push/pop capability. They write to the
  1712. +# original interface (no <tt>top</tt>), so their version constraint looks like:
  1713. #
  1714. # gem 'stack', '~> 0.0'
  1715. #
  1716. # Essentially, any version is OK with Client A. An incompatible change to
  1717. -# the library will cause him grief, but he is willing to take the chance (we
  1718. -# call Client A optimistic).
  1719. +# the library will cause them grief, but they are willing to take the chance
  1720. +# (we call Client A optimistic).
  1721. #
  1722. -# Client B is just like Client A except for two things: (1) He uses the
  1723. -# <tt>depth</tt> method and (2) he is worried about future
  1724. -# incompatibilities, so he writes his version constraint like this:
  1725. +# Client B is just like Client A except for two things: (1) They use the
  1726. +# <tt>depth</tt> method and (2) they are worried about future
  1727. +# incompatibilities, so they write their version constraint like this:
  1728. #
  1729. # gem 'stack', '~> 0.1'
  1730. #
  1731. # The <tt>depth</tt> method was introduced in version 0.1.0, so that version
  1732. # or anything later is fine, as long as the version stays below version 1.0
  1733. # where incompatibilities are introduced. We call Client B pessimistic
  1734. -# because he is worried about incompatible future changes (it is OK to be
  1735. +# because they are worried about incompatible future changes (it is OK to be
  1736. # pessimistic!).
  1737. #
  1738. # == Preventing Version Catastrophe:
  1739. @@ -185,6 +189,8 @@ class Gem::Version
  1740. @@all = {}
  1741. def self.new version # :nodoc:
  1742. + return super unless Gem::VERSION == self.class
  1743. +
  1744. @@all[version] ||= super
  1745. end
  1746. diff --git a/lib/timeout.rb b/lib/timeout.rb
  1747. index ad951d2..d805dce 100644
  1748. --- a/lib/timeout.rb
  1749. +++ b/lib/timeout.rb
  1750. @@ -26,16 +26,25 @@ module Timeout
  1751. class Error < RuntimeError
  1752. end
  1753. class ExitException < ::Exception # :nodoc:
  1754. - attr_reader :klass, :thread
  1755. + attr_reader :thread
  1756. - def initialize(*)
  1757. - super
  1758. - @thread = Thread.current
  1759. - freeze
  1760. + def self.catch(*args)
  1761. + exc = new(*args)
  1762. + exc.instance_variable_set(:@thread, Thread.current)
  1763. + exc.freeze
  1764. + ::Kernel.catch(exc) {yield exc}
  1765. end
  1766. def exception(*)
  1767. - throw(self, caller) if self.thread == Thread.current
  1768. + if self.thread == Thread.current
  1769. + bt = caller
  1770. + begin
  1771. + throw(self, bt)
  1772. + rescue ArgumentError => e
  1773. + raise unless e.message.start_with?("uncaught throw")
  1774. + raise Error, message, backtrace
  1775. + end
  1776. + end
  1777. self
  1778. end
  1779. end
  1780. @@ -67,7 +76,7 @@ module Timeout
  1781. return yield(sec) if sec == nil or sec.zero?
  1782. message = "execution expired"
  1783. e = Error
  1784. - bt = catch((klass||ExitException).new) do |exception|
  1785. + bl = proc do |exception|
  1786. begin
  1787. x = Thread.current
  1788. y = Thread.start {
  1789. @@ -80,8 +89,6 @@ module Timeout
  1790. end
  1791. }
  1792. return yield(sec)
  1793. - rescue (klass||ExitException) => e
  1794. - e.backtrace
  1795. ensure
  1796. if y
  1797. y.kill
  1798. @@ -89,6 +96,15 @@ module Timeout
  1799. end
  1800. end
  1801. end
  1802. + if klass
  1803. + begin
  1804. + bl.call(klass)
  1805. + rescue klass => e
  1806. + bt = e.backtrace
  1807. + end
  1808. + else
  1809. + bt = ExitException.catch(message, &bl)
  1810. + end
  1811. rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
  1812. bt.reject! {|m| rej =~ m}
  1813. level = -caller(CALLER_OFFSET).size
  1814. diff --git a/object.c b/object.c
  1815. index 466ec75..bb43b46 100644
  1816. --- a/object.c
  1817. +++ b/object.c
  1818. @@ -161,6 +161,7 @@ rb_obj_equal(VALUE obj1, VALUE obj2)
  1819. VALUE
  1820. rb_obj_hash(VALUE obj)
  1821. {
  1822. + long rb_objid_hash(st_index_t index);
  1823. VALUE oid = rb_obj_id(obj);
  1824. #if SIZEOF_LONG == SIZEOF_VOIDP
  1825. st_index_t index = NUM2LONG(oid);
  1826. @@ -169,8 +170,7 @@ rb_obj_hash(VALUE obj)
  1827. #else
  1828. # error not supported
  1829. #endif
  1830. - st_index_t h = rb_hash_end(rb_hash_start(index));
  1831. - return LONG2FIX(h);
  1832. + return LONG2FIX(rb_objid_hash(index));
  1833. }
  1834. /*
  1835. diff --git a/proc.c b/proc.c
  1836. index f8b2e3b..e52beaf 100644
  1837. --- a/proc.c
  1838. +++ b/proc.c
  1839. @@ -1171,10 +1171,6 @@ mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass,
  1840. goto again;
  1841. }
  1842. - if (RB_TYPE_P(defined_class, T_ICLASS)) {
  1843. - defined_class = RBASIC_CLASS(defined_class);
  1844. - }
  1845. -
  1846. klass = defined_class;
  1847. while (rclass != klass &&
  1848. @@ -1396,9 +1392,16 @@ static VALUE
  1849. method_owner(VALUE obj)
  1850. {
  1851. struct METHOD *data;
  1852. + VALUE defined_class;
  1853. TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
  1854. - return data->defined_class;
  1855. + defined_class = data->defined_class;
  1856. +
  1857. + if (RB_TYPE_P(defined_class, T_ICLASS)) {
  1858. + defined_class = RBASIC_CLASS(defined_class);
  1859. + }
  1860. +
  1861. + return defined_class;
  1862. }
  1863. void
  1864. diff --git a/string.c b/string.c
  1865. index 900f900..cc30786 100644
  1866. --- a/string.c
  1867. +++ b/string.c
  1868. @@ -1465,6 +1465,7 @@ rb_str_modify_expand(VALUE str, long expand)
  1869. int termlen = TERM_LEN(str);
  1870. if (!STR_EMBED_P(str)) {
  1871. REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa + termlen);
  1872. + STR_UNSET_NOCAPA(str);
  1873. RSTRING(str)->as.heap.aux.capa = capa;
  1874. }
  1875. else if (capa + termlen > RSTRING_EMBED_LEN_MAX + 1) {
  1876. diff --git a/struct.c b/struct.c
  1877. index 6be512e..2e026fb 100644
  1878. --- a/struct.c
  1879. +++ b/struct.c
  1880. @@ -156,7 +156,8 @@ rb_struct_set(VALUE obj, VALUE val)
  1881. for (i=0; i<len; i++) {
  1882. slot = RARRAY_AREF(members, i);
  1883. if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
  1884. - return RSTRUCT_SET(obj, i, val);
  1885. + RSTRUCT_SET(obj, i, val);
  1886. + return val;
  1887. }
  1888. }
  1889. rb_name_error(rb_frame_this_func(), "`%s' is not a struct member",
  1890. diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
  1891. index 6fdc422..02bb5a5 100644
  1892. --- a/test/bigdecimal/test_bigdecimal.rb
  1893. +++ b/test/bigdecimal/test_bigdecimal.rb
  1894. @@ -701,6 +701,10 @@ class TestBigDecimal < Test::Unit::TestCase
  1895. assert_equal(BigDecimal::SIGN_NEGATIVE_ZERO, (BigDecimal.new("-0") / 1).sign)
  1896. assert_equal(2, BigDecimal.new("2") / 1)
  1897. assert_equal(-2, BigDecimal.new("2") / -1)
  1898. +
  1899. + assert_equal(BigDecimal('1486.868686869'), BigDecimal('1472.0') / BigDecimal('0.99'), '[ruby-core:59365] [#9316]')
  1900. +
  1901. + assert_equal(4.124045235, BigDecimal('0.9932') / (700 * BigDecimal('0.344045') / BigDecimal('1000.0')), '[#9305]')
  1902. end
  1903. def test_div_with_float
  1904. diff --git a/test/dl/test_base.rb b/test/dl/test_base.rb
  1905. index a07056d..dafba6e 100644
  1906. --- a/test/dl/test_base.rb
  1907. +++ b/test/dl/test_base.rb
  1908. @@ -39,6 +39,9 @@ when /gnu/ #GNU/Hurd
  1909. when /mirbsd/
  1910. libc_so = "/usr/lib/libc.so.41.10"
  1911. libm_so = "/usr/lib/libm.so.7.0"
  1912. +when /freebsd/
  1913. + libc_so = "/lib/libc.so.7"
  1914. + libm_so = "/lib/libm.so.5"
  1915. when /bsd|dragonfly/
  1916. libc_so = "/usr/lib/libc.so"
  1917. libm_so = "/usr/lib/libm.so"
  1918. diff --git a/test/dl/test_handle.rb b/test/dl/test_handle.rb
  1919. index 4ef93ad..83b8af1 100644
  1920. --- a/test/dl/test_handle.rb
  1921. +++ b/test/dl/test_handle.rb
  1922. @@ -181,7 +181,7 @@ module DL
  1923. # In general uses of dlerror(3) should call it before use it.
  1924. require 'socket'
  1925. Socket.gethostbyname("localhost")
  1926. - DL.dlopen("/usr/lib/libc.so").sym('strcpy')
  1927. + DL.dlopen("/lib/libc.so.7").sym('strcpy')
  1928. end if /freebsd/=~ RUBY_PLATFORM
  1929. end
  1930. end
  1931. diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb
  1932. index 404c137..f58077e 100644
  1933. --- a/test/fiddle/helper.rb
  1934. +++ b/test/fiddle/helper.rb
  1935. @@ -40,6 +40,9 @@ when /gnu/ #GNU/Hurd
  1936. when /mirbsd/
  1937. libc_so = "/usr/lib/libc.so.41.10"
  1938. libm_so = "/usr/lib/libm.so.7.0"
  1939. +when /freebsd/
  1940. + libc_so = "/lib/libc.so.7"
  1941. + libm_so = "/lib/libm.so.5"
  1942. when /bsd|dragonfly/
  1943. libc_so = "/usr/lib/libc.so"
  1944. libm_so = "/usr/lib/libm.so"
  1945. diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb
  1946. index 2af3e5c..c598cc3 100644
  1947. --- a/test/fiddle/test_handle.rb
  1948. +++ b/test/fiddle/test_handle.rb
  1949. @@ -183,7 +183,7 @@ module Fiddle
  1950. # In general uses of dlerror(3) should call it before use it.
  1951. require 'socket'
  1952. Socket.gethostbyname("localhost")
  1953. - Fiddle.dlopen("/usr/lib/libc.so").sym('strcpy')
  1954. + Fiddle.dlopen("/lib/libc.so.7").sym('strcpy')
  1955. end if /freebsd/=~ RUBY_PLATFORM
  1956. end
  1957. end if defined?(Fiddle)
  1958. diff --git a/test/net/imap/cacert.pem b/test/net/imap/cacert.pem
  1959. index bd7e68a..7073387 100644
  1960. --- a/test/net/imap/cacert.pem
  1961. +++ b/test/net/imap/cacert.pem
  1962. @@ -2,59 +2,65 @@ Certificate:
  1963. Data:
  1964. Version: 3 (0x2)
  1965. Serial Number:
  1966. - 9f:dc:f7:94:98:05:43:4c
  1967. + b9:90:a2:bf:62:69:17:9c
  1968. Signature Algorithm: sha1WithRSAEncryption
  1969. Issuer: C=JP, ST=Shimane, L=Matz-e city, O=Ruby Core Team, CN=Ruby Test CA/emailAddress=security@ruby-lang.org
  1970. Validity
  1971. - Not Before: Dec 23 10:21:33 2010 GMT
  1972. - Not After : Jan 1 10:21:33 2014 GMT
  1973. + Not Before: Jan 3 01:34:17 2014 GMT
  1974. + Not After : Jan 2 01:34:17 2019 GMT
  1975. Subject: C=JP, ST=Shimane, L=Matz-e city, O=Ruby Core Team, CN=Ruby Test CA/emailAddress=security@ruby-lang.org
  1976. Subject Public Key Info:
  1977. Public Key Algorithm: rsaEncryption
  1978. - Public-Key: (1024 bit)
  1979. - Modulus:
  1980. - 00:ce:be:2c:9f:47:ba:db:9c:9c:5b:f0:38:3b:f3:
  1981. - 74:20:37:76:23:9f:84:1c:81:90:b4:3e:00:20:34:
  1982. - 98:7e:81:69:50:a1:c3:65:96:ea:fa:00:da:8c:cc:
  1983. - 53:3f:ba:3c:d0:50:7a:5a:b4:6b:ac:d3:2e:18:ca:
  1984. - 2a:69:b3:6a:6f:38:c2:32:a8:06:b6:0a:30:a9:ee:
  1985. - 03:38:e9:05:a5:19:23:54:a8:3c:b9:08:ad:2b:72:
  1986. - 23:df:93:22:c4:46:a8:ea:f1:a6:e9:30:4a:3f:83:
  1987. - 39:e9:62:8e:8b:a3:5e:67:89:1d:7c:75:de:05:aa:
  1988. - 58:b1:b7:79:7c:10:80:6d:87
  1989. + RSA Public Key: (1024 bit)
  1990. + Modulus (1024 bit):
  1991. + 00:db:75:d0:45:de:b1:df:bf:71:a0:0e:b0:a5:e6:
  1992. + bc:f4:1c:9d:e5:25:67:64:c5:7b:cb:f1:af:c6:be:
  1993. + 9a:aa:ea:7e:0f:cc:05:af:ef:40:69:06:b2:c9:13:
  1994. + 9d:7e:eb:a2:06:e2:ea:7d:07:c7:c7:99:c7:fb:d5:
  1995. + b8:eb:63:77:62:2b:18:12:c3:53:58:d0:f5:c7:40:
  1996. + 0c:01:d1:26:82:34:16:09:e3:dc:65:f4:dc:bb:5d:
  1997. + a5:41:60:e7:a9:74:ba:d7:4c:b6:a3:9c:c5:8c:89:
  1998. + af:cb:e8:9f:05:fe:ea:fe:64:24:bf:e7:ed:e3:f6:
  1999. + d0:fc:d6:eb:fc:06:82:10:fb
  2000. Exponent: 65537 (0x10001)
  2001. X509v3 extensions:
  2002. X509v3 Subject Key Identifier:
  2003. - 41:C9:49:37:B1:FA:61:E3:BA:D7:19:3D:D9:DA:8C:B9:82:C9:B4:6A
  2004. + E8:7E:58:AC:13:7B:03:22:8D:9E:AF:32:0B:84:89:80:80:0C:1E:C2
  2005. X509v3 Authority Key Identifier:
  2006. - keyid:41:C9:49:37:B1:FA:61:E3:BA:D7:19:3D:D9:DA:8C:B9:82:C9:B4:6A
  2007. + keyid:E8:7E:58:AC:13:7B:03:22:8D:9E:AF:32:0B:84:89:80:80:0C:1E:C2
  2008. + DirName:/C=JP/ST=Shimane/L=Matz-e city/O=Ruby Core Team/CN=Ruby Test CA/emailAddress=security@ruby-lang.org
  2009. + serial:B9:90:A2:BF:62:69:17:9C
  2010. X509v3 Basic Constraints:
  2011. CA:TRUE
  2012. Signature Algorithm: sha1WithRSAEncryption
  2013. - 86:00:33:b9:dd:ff:5f:83:59:5f:c3:29:3c:d7:11:db:10:b3:
  2014. - d7:d1:70:fb:0a:c6:74:85:c6:ea:e1:15:c4:92:f8:0e:11:cc:
  2015. - ff:a6:3c:31:c2:2c:66:d8:fe:63:93:9f:b0:97:e6:f5:bc:5c:
  2016. - 80:68:96:5d:eb:77:b9:23:dd:68:a7:49:03:ff:22:48:55:f1:
  2017. - 39:7c:20:21:ff:64:52:e1:f6:cf:3c:b3:4d:2c:5c:03:62:ea:
  2018. - c5:49:99:07:fa:8d:ff:7b:c2:75:0c:ca:24:b5:0b:f5:b7:57:
  2019. - 3a:10:f0:8a:bb:9a:e8:92:4d:d5:6f:c2:a2:29:36:61:78:a4:
  2020. - dc:7b
  2021. + 8f:77:06:4e:31:72:12:ee:68:09:70:27:d4:31:85:ef:10:95:
  2022. + f9:0f:2b:66:63:08:37:88:6e:b7:9b:40:3e:18:77:33:86:e8:
  2023. + 61:6a:b7:3c:cb:c7:a6:d6:d5:92:6a:1f:56:d0:9f:5c:32:56:
  2024. + d3:37:52:fe:0e:20:c2:7a:0d:fe:2d:3c:81:da:b8:7f:4d:6a:
  2025. + 08:01:d9:be:7a:a2:15:be:a6:ce:49:64:90:8c:9a:ca:6e:2e:
  2026. + 84:48:1d:94:19:56:94:46:aa:25:9b:68:c2:80:60:bf:cb:2e:
  2027. + 35:03:ea:0a:65:5a:33:38:c6:cc:81:46:c0:bc:36:86:96:39:
  2028. + 10:7d
  2029. -----BEGIN CERTIFICATE-----
  2030. -MIIC6DCCAlGgAwIBAgIJAJ/c95SYBUNMMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYD
  2031. -VQQGEwJKUDEQMA4GA1UECAwHU2hpbWFuZTEUMBIGA1UEBwwLTWF0ei1lIGNpdHkx
  2032. -FzAVBgNVBAoMDlJ1YnkgQ29yZSBUZWFtMRUwEwYDVQQDDAxSdWJ5IFRlc3QgQ0Ex
  2033. -JTAjBgkqhkiG9w0BCQEWFnNlY3VyaXR5QHJ1YnktbGFuZy5vcmcwHhcNMTAxMjIz
  2034. -MTAyMTMzWhcNMTQwMTAxMTAyMTMzWjCBjDELMAkGA1UEBhMCSlAxEDAOBgNVBAgM
  2035. -B1NoaW1hbmUxFDASBgNVBAcMC01hdHotZSBjaXR5MRcwFQYDVQQKDA5SdWJ5IENv
  2036. -cmUgVGVhbTEVMBMGA1UEAwwMUnVieSBUZXN0IENBMSUwIwYJKoZIhvcNAQkBFhZz
  2037. +MIIDjTCCAvagAwIBAgIJALmQor9iaRecMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYD
  2038. +VQQGEwJKUDEQMA4GA1UECBMHU2hpbWFuZTEUMBIGA1UEBxMLTWF0ei1lIGNpdHkx
  2039. +FzAVBgNVBAoTDlJ1YnkgQ29yZSBUZWFtMRUwEwYDVQQDEwxSdWJ5IFRlc3QgQ0Ex
  2040. +JTAjBgkqhkiG9w0BCQEWFnNlY3VyaXR5QHJ1YnktbGFuZy5vcmcwHhcNMTQwMTAz
  2041. +MDEzNDE3WhcNMTkwMTAyMDEzNDE3WjCBjDELMAkGA1UEBhMCSlAxEDAOBgNVBAgT
  2042. +B1NoaW1hbmUxFDASBgNVBAcTC01hdHotZSBjaXR5MRcwFQYDVQQKEw5SdWJ5IENv
  2043. +cmUgVGVhbTEVMBMGA1UEAxMMUnVieSBUZXN0IENBMSUwIwYJKoZIhvcNAQkBFhZz
  2044. ZWN1cml0eUBydWJ5LWxhbmcub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
  2045. -gQDOviyfR7rbnJxb8Dg783QgN3Yjn4QcgZC0PgAgNJh+gWlQocNllur6ANqMzFM/
  2046. -ujzQUHpatGus0y4Yyipps2pvOMIyqAa2CjCp7gM46QWlGSNUqDy5CK0rciPfkyLE
  2047. -Rqjq8abpMEo/gznpYo6Lo15niR18dd4Fqlixt3l8EIBthwIDAQABo1AwTjAdBgNV
  2048. -HQ4EFgQUQclJN7H6YeO61xk92dqMuYLJtGowHwYDVR0jBBgwFoAUQclJN7H6YeO6
  2049. -1xk92dqMuYLJtGowDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCGADO5
  2050. -3f9fg1lfwyk81xHbELPX0XD7CsZ0hcbq4RXEkvgOEcz/pjwxwixm2P5jk5+wl+b1
  2051. -vFyAaJZd63e5I91op0kD/yJIVfE5fCAh/2RS4fbPPLNNLFwDYurFSZkH+o3/e8J1
  2052. -DMoktQv1t1c6EPCKu5rokk3Vb8KiKTZheKTcew==
  2053. +gQDbddBF3rHfv3GgDrCl5rz0HJ3lJWdkxXvL8a/Gvpqq6n4PzAWv70BpBrLJE51+
  2054. +66IG4up9B8fHmcf71bjrY3diKxgSw1NY0PXHQAwB0SaCNBYJ49xl9Ny7XaVBYOep
  2055. +dLrXTLajnMWMia/L6J8F/ur+ZCS/5+3j9tD81uv8BoIQ+wIDAQABo4H0MIHxMB0G
  2056. +A1UdDgQWBBToflisE3sDIo2erzILhImAgAwewjCBwQYDVR0jBIG5MIG2gBToflis
  2057. +E3sDIo2erzILhImAgAwewqGBkqSBjzCBjDELMAkGA1UEBhMCSlAxEDAOBgNVBAgT
  2058. +B1NoaW1hbmUxFDASBgNVBAcTC01hdHotZSBjaXR5MRcwFQYDVQQKEw5SdWJ5IENv
  2059. +cmUgVGVhbTEVMBMGA1UEAxMMUnVieSBUZXN0IENBMSUwIwYJKoZIhvcNAQkBFhZz
  2060. +ZWN1cml0eUBydWJ5LWxhbmcub3JnggkAuZCiv2JpF5wwDAYDVR0TBAUwAwEB/zAN
  2061. +BgkqhkiG9w0BAQUFAAOBgQCPdwZOMXIS7mgJcCfUMYXvEJX5DytmYwg3iG63m0A+
  2062. +GHczhuhharc8y8em1tWSah9W0J9cMlbTN1L+DiDCeg3+LTyB2rh/TWoIAdm+eqIV
  2063. +vqbOSWSQjJrKbi6ESB2UGVaURqolm2jCgGC/yy41A+oKZVozOMbMgUbAvDaGljkQ
  2064. +fQ==
  2065. -----END CERTIFICATE-----
  2066. diff --git a/test/net/imap/server.crt b/test/net/imap/server.crt
  2067. index d848b26..fa4f994 100644
  2068. --- a/test/net/imap/server.crt
  2069. +++ b/test/net/imap/server.crt
  2070. @@ -1,17 +1,17 @@
  2071. Certificate:
  2072. Data:
  2073. - Version: 3 (0x2)
  2074. + Version: 1 (0x0)
  2075. Serial Number: 0 (0x0)
  2076. Signature Algorithm: sha1WithRSAEncryption
  2077. Issuer: C=JP, ST=Shimane, L=Matz-e city, O=Ruby Core Team, CN=Ruby Test CA/emailAddress=security@ruby-lang.org
  2078. Validity
  2079. - Not Before: Dec 23 10:23:52 2010 GMT
  2080. - Not After : Jan 1 10:23:52 2014 GMT
  2081. + Not Before: Jan 3 01:34:17 2014 GMT
  2082. + Not After : Jan 2 01:34:17 2019 GMT
  2083. Subject: C=JP, ST=Shimane, O=Ruby Core Team, OU=Ruby Test, CN=localhost
  2084. Subject Public Key Info:
  2085. Public Key Algorithm: rsaEncryption
  2086. - Public-Key: (1024 bit)
  2087. - Modulus:
  2088. + RSA Public Key: (1024 bit)
  2089. + Modulus (1024 bit):
  2090. 00:db:75:d0:45:de:b1:df:bf:71:a0:0e:b0:a5:e6:
  2091. bc:f4:1c:9d:e5:25:67:64:c5:7b:cb:f1:af:c6:be:
  2092. 9a:aa:ea:7e:0f:cc:05:af:ef:40:69:06:b2:c9:13:
  2093. @@ -22,40 +22,27 @@ Certificate:
  2094. af:cb:e8:9f:05:fe:ea:fe:64:24:bf:e7:ed:e3:f6:
  2095. d0:fc:d6:eb:fc:06:82:10:fb
  2096. Exponent: 65537 (0x10001)
  2097. - X509v3 extensions:
  2098. - X509v3 Basic Constraints:
  2099. - CA:FALSE
  2100. - Netscape Comment:
  2101. - OpenSSL Generated Certificate
  2102. - X509v3 Subject Key Identifier:
  2103. - E8:7E:58:AC:13:7B:03:22:8D:9E:AF:32:0B:84:89:80:80:0C:1E:C2
  2104. - X509v3 Authority Key Identifier:
  2105. - keyid:41:C9:49:37:B1:FA:61:E3:BA:D7:19:3D:D9:DA:8C:B9:82:C9:B4:6A
  2106. -
  2107. Signature Algorithm: sha1WithRSAEncryption
  2108. - ae:ee:cd:fe:c9:af:48:0b:50:37:ac:6a:f6:68:90:9b:67:df:
  2109. - 6f:2d:17:c9:3c:a5:da:ad:39:dc:2a:5b:07:88:26:38:19:30:
  2110. - d6:95:cf:10:69:c7:92:14:83:be:f1:b5:8e:6f:d9:91:51:c5:
  2111. - 63:ae:1c:89:ac:27:bf:4f:2a:8f:4e:0c:57:42:0a:c9:8e:0c:
  2112. - f4:f3:02:f7:ea:44:b6:e4:47:05:af:4e:74:e4:87:87:d9:c8:
  2113. - 76:ed:ab:32:7c:f0:31:34:10:14:bc:a6:37:cd:d7:dc:33:da:
  2114. - 82:d3:d4:9b:e9:d5:cd:38:cc:fa:81:5f:4e:fd:5f:53:05:5d:
  2115. - 76:f9
  2116. + 85:f5:d3:05:8b:8c:f4:43:1c:88:f2:8f:b2:f2:93:77:b7:3d:
  2117. + 95:c6:a0:34:bc:33:6a:d8:85:5f:3e:86:08:10:c5:5c:c1:76:
  2118. + a3:53:3c:dc:38:98:23:97:e7:da:21:ac:e8:4d:3c:96:70:29:
  2119. + ff:ff:1e:4a:9a:17:2b:db:04:62:b9:ef:ab:ea:a7:a5:e8:7c:
  2120. + b1:d5:ed:30:a8:6c:78:de:51:7e:e3:8a:c2:a4:64:a8:63:a2:
  2121. + bc:fd:43:9c:f3:55:7d:54:c9:6a:d8:53:1c:4b:6b:03:aa:b6:
  2122. + 19:e6:a4:4f:47:00:96:c5:42:59:85:4e:c3:4e:cd:41:82:53:
  2123. + 10:f8
  2124. -----BEGIN CERTIFICATE-----
  2125. -MIIC3jCCAkegAwIBAgIBADANBgkqhkiG9w0BAQUFADCBjDELMAkGA1UEBhMCSlAx
  2126. -EDAOBgNVBAgMB1NoaW1hbmUxFDASBgNVBAcMC01hdHotZSBjaXR5MRcwFQYDVQQK
  2127. -DA5SdWJ5IENvcmUgVGVhbTEVMBMGA1UEAwwMUnVieSBUZXN0IENBMSUwIwYJKoZI
  2128. -hvcNAQkBFhZzZWN1cml0eUBydWJ5LWxhbmcub3JnMB4XDTEwMTIyMzEwMjM1MloX
  2129. -DTE0MDEwMTEwMjM1MlowYDELMAkGA1UEBhMCSlAxEDAOBgNVBAgMB1NoaW1hbmUx
  2130. -FzAVBgNVBAoMDlJ1YnkgQ29yZSBUZWFtMRIwEAYDVQQLDAlSdWJ5IFRlc3QxEjAQ
  2131. -BgNVBAMMCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA23XQ
  2132. -Rd6x379xoA6wpea89Byd5SVnZMV7y/Gvxr6aqup+D8wFr+9AaQayyROdfuuiBuLq
  2133. -fQfHx5nH+9W462N3YisYEsNTWND1x0AMAdEmgjQWCePcZfTcu12lQWDnqXS610y2
  2134. -o5zFjImvy+ifBf7q/mQkv+ft4/bQ/Nbr/AaCEPsCAwEAAaN7MHkwCQYDVR0TBAIw
  2135. -ADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUw
  2136. -HQYDVR0OBBYEFOh+WKwTewMijZ6vMguEiYCADB7CMB8GA1UdIwQYMBaAFEHJSTex
  2137. -+mHjutcZPdnajLmCybRqMA0GCSqGSIb3DQEBBQUAA4GBAK7uzf7Jr0gLUDesavZo
  2138. -kJtn328tF8k8pdqtOdwqWweIJjgZMNaVzxBpx5IUg77xtY5v2ZFRxWOuHImsJ79P
  2139. -Ko9ODFdCCsmODPTzAvfqRLbkRwWvTnTkh4fZyHbtqzJ88DE0EBS8pjfN19wz2oLT
  2140. -1Jvp1c04zPqBX079X1MFXXb5
  2141. +MIICXDCCAcUCAQAwDQYJKoZIhvcNAQEFBQAwgYwxCzAJBgNVBAYTAkpQMRAwDgYD
  2142. +VQQIEwdTaGltYW5lMRQwEgYDVQQHEwtNYXR6LWUgY2l0eTEXMBUGA1UEChMOUnVi
  2143. +eSBDb3JlIFRlYW0xFTATBgNVBAMTDFJ1YnkgVGVzdCBDQTElMCMGCSqGSIb3DQEJ
  2144. +ARYWc2VjdXJpdHlAcnVieS1sYW5nLm9yZzAeFw0xNDAxMDMwMTM0MTdaFw0xOTAx
  2145. +MDIwMTM0MTdaMGAxCzAJBgNVBAYTAkpQMRAwDgYDVQQIEwdTaGltYW5lMRcwFQYD
  2146. +VQQKEw5SdWJ5IENvcmUgVGVhbTESMBAGA1UECxMJUnVieSBUZXN0MRIwEAYDVQQD
  2147. +Ewlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANt10EXesd+/
  2148. +caAOsKXmvPQcneUlZ2TFe8vxr8a+mqrqfg/MBa/vQGkGsskTnX7rogbi6n0Hx8eZ
  2149. +x/vVuOtjd2IrGBLDU1jQ9cdADAHRJoI0Fgnj3GX03LtdpUFg56l0utdMtqOcxYyJ
  2150. +r8vonwX+6v5kJL/n7eP20PzW6/wGghD7AgMBAAEwDQYJKoZIhvcNAQEFBQADgYEA
  2151. +hfXTBYuM9EMciPKPsvKTd7c9lcagNLwzatiFXz6GCBDFXMF2o1M83DiYI5fn2iGs
  2152. +6E08lnAp//8eSpoXK9sEYrnvq+qnpeh8sdXtMKhseN5RfuOKwqRkqGOivP1DnPNV
  2153. +fVTJathTHEtrA6q2GeakT0cAlsVCWYVOw07NQYJTEPg=
  2154. -----END CERTIFICATE-----
  2155. diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb
  2156. index cef39d6..956fdb4 100644
  2157. --- a/test/ruby/test_alias.rb
  2158. +++ b/test/ruby/test_alias.rb
  2159. @@ -121,7 +121,7 @@ class TestAlias < Test::Unit::TestCase
  2160. assert_equal([:Base, :M], SuperInAliasedModuleMethod::Derived.new.bar)
  2161. end
  2162. - def test_alias
  2163. + def test_alias_wb_miss
  2164. assert_normal_exit %q{
  2165. require 'stringio'
  2166. GC.verify_internal_consistency
  2167. diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
  2168. index b648c40..6ff304a 100644
  2169. --- a/test/ruby/test_array.rb
  2170. +++ b/test/ruby/test_array.rb
  2171. @@ -1524,6 +1524,11 @@ class TestArray < Test::Unit::TestCase
  2172. assert(a.none?(&:frozen?))
  2173. assert_equal(%w(a), b)
  2174. assert(b.none?(&:frozen?))
  2175. +
  2176. + bug9340 = "[ruby-core:59457]"
  2177. + ary = [bug9340, bug9340.dup, bug9340.dup]
  2178. + assert_equal 1, ary.uniq.size
  2179. + assert_same bug9340, ary.uniq[0]
  2180. end
  2181. def test_uniq_with_block
  2182. diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb
  2183. index aded544..6ec13e4 100644
  2184. --- a/test/ruby/test_backtrace.rb
  2185. +++ b/test/ruby/test_backtrace.rb
  2186. @@ -19,17 +19,16 @@ class TestBacktrace < Test::Unit::TestCase
  2187. end
  2188. def test_exception_backtrace_locations
  2189. - bt = Fiber.new{
  2190. + backtrace, backtrace_locations = Fiber.new{
  2191. begin
  2192. raise
  2193. rescue => e
  2194. - e.backtrace_locations
  2195. + [e.backtrace, e.backtrace_locations]
  2196. end
  2197. }.resume
  2198. - assert_equal(1, bt.size)
  2199. - assert_match(/.+:\d+:.+/, bt[0].to_s)
  2200. + assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
  2201. - bt = Fiber.new{
  2202. + backtrace, backtrace_locations = Fiber.new{
  2203. begin
  2204. begin
  2205. helper_test_exception_backtrace_locations
  2206. @@ -37,11 +36,34 @@ class TestBacktrace < Test::Unit::TestCase
  2207. raise
  2208. end
  2209. rescue => e
  2210. - e.backtrace_locations
  2211. + [e.backtrace, e.backtrace_locations]
  2212. + end
  2213. + }.resume
  2214. + assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
  2215. + end
  2216. +
  2217. + def call_helper_test_exception_backtrace_locations
  2218. + helper_test_exception_backtrace_locations(:bad_argument)
  2219. + end
  2220. +
  2221. + def test_argument_error_backtrace_locations
  2222. + backtrace, backtrace_locations = Fiber.new{
  2223. + begin
  2224. + helper_test_exception_backtrace_locations(1)
  2225. + rescue ArgumentError => e
  2226. + [e.backtrace, e.backtrace_locations]
  2227. + end
  2228. + }.resume
  2229. + assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
  2230. +
  2231. + backtrace, backtrace_locations = Fiber.new{
  2232. + begin
  2233. + call_helper_test_exception_backtrace_locations
  2234. + rescue ArgumentError => e
  2235. + [e.backtrace, e.backtrace_locations]
  2236. end
  2237. }.resume
  2238. - assert_equal(2, bt.size)
  2239. - assert_match(/helper_test_exception_backtrace_locations/, bt[0].to_s)
  2240. + assert_equal(backtrace, backtrace_locations.map{|e| e.to_s})
  2241. end
  2242. def test_caller_lev
  2243. diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
  2244. index 169157b..c872b11 100644
  2245. --- a/test/ruby/test_hash.rb
  2246. +++ b/test/ruby/test_hash.rb
  2247. @@ -558,12 +558,23 @@ class TestHash < Test::Unit::TestCase
  2248. assert_equal(h3, h.reject {|k,v| v })
  2249. assert_equal(base, h)
  2250. - return unless RUBY_VERSION > "2.1.0"
  2251. + unless RUBY_VERSION >= "2.2.0"
  2252. + # [ruby-core:59154] [Bug #9223]
  2253. + if @cls == Hash
  2254. + assert_empty(EnvUtil.verbose_warning {h.reject {false}})
  2255. + bug9275 = '[ruby-core:59254] [Bug #9275]'
  2256. + c = Class.new(Hash)
  2257. + assert_empty(EnvUtil.verbose_warning {c.new.reject {false}}, bug9275)
  2258. + else
  2259. + assert_match(/extra states/, EnvUtil.verbose_warning {h.reject {false}})
  2260. + end
  2261. + return
  2262. + end
  2263. h.instance_variable_set(:@foo, :foo)
  2264. h.default = 42
  2265. h.taint
  2266. - h = h.reject {false}
  2267. + h = EnvUtil.suppress_warning {h.reject {false}}
  2268. assert_instance_of(Hash, h)
  2269. assert_not_predicate(h, :tainted?)
  2270. assert_nil(h.default)
  2271. @@ -1217,8 +1228,32 @@ class TestHash < Test::Unit::TestCase
  2272. assert_no_memory_leak([], prepare, code, bug9187)
  2273. end
  2274. + def test_wrapper_of_special_const
  2275. + bug9381 = '[ruby-core:59638] [Bug #9381]'
  2276. +
  2277. + wrapper = Class.new do
  2278. + def initialize(obj)
  2279. + @obj = obj
  2280. + end
  2281. +
  2282. + def hash
  2283. + @obj.hash
  2284. + end
  2285. +
  2286. + def eql?(other)
  2287. + @obj.eql?(other)
  2288. + end
  2289. + end
  2290. +
  2291. + hash = {5 => bug9381}
  2292. + assert_equal(bug9381, hash[wrapper.new(5)])
  2293. + end
  2294. +
  2295. class TestSubHash < TestHash
  2296. class SubHash < Hash
  2297. + def reject(*)
  2298. + super
  2299. + end
  2300. end
  2301. def setup
  2302. diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
  2303. index 621a06b..3f0931b 100644
  2304. --- a/test/ruby/test_pack.rb
  2305. +++ b/test/ruby/test_pack.rb
  2306. @@ -181,6 +181,7 @@ class TestPack < Test::Unit::TestCase
  2307. assert_equal a[0], a.pack("p").unpack("p")[0]
  2308. assert_equal a, a.pack("p").freeze.unpack("p*")
  2309. assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") }
  2310. + assert_raise(ArgumentError) { (a.pack("p") << "d").unpack("p*") }
  2311. end
  2312. def test_format_string_modified
  2313. diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
  2314. index 8aa99c5..e23b5b0 100644
  2315. --- a/test/ruby/test_struct.rb
  2316. +++ b/test/ruby/test_struct.rb
  2317. @@ -298,6 +298,12 @@ module TestStruct
  2318. assert_same(x, o.b!)
  2319. end
  2320. + def test_setter_method_returns_value
  2321. + klass = @Struct.new(:a)
  2322. + x = klass.new
  2323. + assert_equal "[Bug #9353]", x.send(:a=, "[Bug #9353]")
  2324. + end
  2325. +
  2326. class TopStruct < Test::Unit::TestCase
  2327. include TestStruct
  2328. diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
  2329. index 846f409..82d6e19 100644
  2330. --- a/test/ruby/test_super.rb
  2331. +++ b/test/ruby/test_super.rb
  2332. @@ -407,4 +407,50 @@ class TestSuper < Test::Unit::TestCase
  2333. assert_equal([false, false], y.foo(false, false))
  2334. assert_equal([1, 2, 3, false, 5], y.foo(1, 2, 3, false, 5))
  2335. end
  2336. +
  2337. + def test_missing_super_in_method_module
  2338. + bug9315 = '[ruby-core:59358] [Bug #9315]'
  2339. + a = Module.new do
  2340. + def foo
  2341. + super
  2342. + end
  2343. + end
  2344. + b = Class.new do
  2345. + include a
  2346. + end
  2347. + assert_raise(NoMethodError, bug9315) do
  2348. + b.new.method(:foo).call
  2349. + end
  2350. + end
  2351. +
  2352. + def test_module_super_in_method_module
  2353. + bug9315 = '[ruby-core:59589] [Bug #9315]'
  2354. + a = Module.new do
  2355. + def foo
  2356. + super
  2357. + end
  2358. + end
  2359. + c = Class.new do
  2360. + def foo
  2361. + :ok
  2362. + end
  2363. + end
  2364. + o = c.new.extend(a)
  2365. + assert_nothing_raised(NoMethodError, bug9315) do
  2366. + assert_equal(:ok, o.method(:foo).call, bug9315)
  2367. + end
  2368. + end
  2369. +
  2370. + def test_missing_super_in_module_unbound_method
  2371. + bug9377 = '[ruby-core:59619] [Bug #9377]'
  2372. +
  2373. + a = Module.new do
  2374. + def foo; super end
  2375. + end
  2376. +
  2377. + m = a.instance_method(:foo).bind(Object.new)
  2378. + assert_raise(NoMethodError, bug9377) do
  2379. + m.call
  2380. + end
  2381. + end
  2382. end
  2383. diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
  2384. index 759c2fe..e337420 100644
  2385. --- a/test/rubygems/test_gem.rb
  2386. +++ b/test/rubygems/test_gem.rb
  2387. @@ -199,30 +199,21 @@ class TestGem < Gem::TestCase
  2388. end
  2389. def test_self_default_exec_format
  2390. - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name]
  2391. - Gem::ConfigMap[:ruby_install_name] = 'ruby'
  2392. -
  2393. - assert_equal '%s', Gem.default_exec_format
  2394. - ensure
  2395. - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME
  2396. + ruby_install_name 'ruby' do
  2397. + assert_equal '%s', Gem.default_exec_format
  2398. + end
  2399. end
  2400. def test_self_default_exec_format_18
  2401. - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name]
  2402. - Gem::ConfigMap[:ruby_install_name] = 'ruby18'
  2403. -
  2404. - assert_equal '%s18', Gem.default_exec_format
  2405. - ensure
  2406. - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME
  2407. + ruby_install_name 'ruby18' do
  2408. + assert_equal '%s18', Gem.default_exec_format
  2409. + end
  2410. end
  2411. def test_self_default_exec_format_jruby
  2412. - orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:ruby_install_name]
  2413. - Gem::ConfigMap[:ruby_install_name] = 'jruby'
  2414. -
  2415. - assert_equal 'j%s', Gem.default_exec_format
  2416. - ensure
  2417. - Gem::ConfigMap[:ruby_install_name] = orig_RUBY_INSTALL_NAME
  2418. + ruby_install_name 'jruby' do
  2419. + assert_equal 'j%s', Gem.default_exec_format
  2420. + end
  2421. end
  2422. def test_self_default_sources
  2423. @@ -230,6 +221,7 @@ class TestGem < Gem::TestCase
  2424. end
  2425. def test_self_detect_gemdeps
  2426. + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
  2427. rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
  2428. FileUtils.mkdir_p 'detect/a/b'
  2429. @@ -339,21 +331,15 @@ class TestGem < Gem::TestCase
  2430. end
  2431. def test_self_extension_dir_shared
  2432. - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
  2433. - RbConfig::CONFIG['ENABLE_SHARED'], 'yes'
  2434. -
  2435. - assert_equal Gem.ruby_api_version, Gem.extension_api_version
  2436. - ensure
  2437. - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
  2438. + enable_shared 'yes' do
  2439. + assert_equal Gem.ruby_api_version, Gem.extension_api_version
  2440. + end
  2441. end
  2442. def test_self_extension_dir_static
  2443. - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
  2444. - RbConfig::CONFIG['ENABLE_SHARED'], 'no'
  2445. -
  2446. - assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
  2447. - ensure
  2448. - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
  2449. + enable_shared 'no' do
  2450. + assert_equal "#{Gem.ruby_api_version}-static", Gem.extension_api_version
  2451. + end
  2452. end
  2453. def test_self_find_files
  2454. @@ -565,24 +551,43 @@ class TestGem < Gem::TestCase
  2455. end
  2456. def test_self_prefix_libdir
  2457. - orig_libdir = Gem::ConfigMap[:libdir]
  2458. - Gem::ConfigMap[:libdir] = @@project_dir
  2459. + orig_libdir = RbConfig::CONFIG['libdir']
  2460. + RbConfig::CONFIG['libdir'] = @@project_dir
  2461. assert_nil Gem.prefix
  2462. ensure
  2463. - Gem::ConfigMap[:libdir] = orig_libdir
  2464. + RbConfig::CONFIG['libdir'] = orig_libdir
  2465. end
  2466. def test_self_prefix_sitelibdir
  2467. - orig_sitelibdir = Gem::ConfigMap[:sitelibdir]
  2468. - Gem::ConfigMap[:sitelibdir] = @@project_dir
  2469. + orig_sitelibdir = RbConfig::CONFIG['sitelibdir']
  2470. + RbConfig::CONFIG['sitelibdir'] = @@project_dir
  2471. assert_nil Gem.prefix
  2472. ensure
  2473. - Gem::ConfigMap[:sitelibdir] = orig_sitelibdir
  2474. + RbConfig::CONFIG['sitelibdir'] = orig_sitelibdir
  2475. + end
  2476. +
  2477. + def test_self_read_binary
  2478. + open 'test', 'w' do |io|
  2479. + io.write "\xCF\x80"
  2480. + end
  2481. +
  2482. + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a
  2483. +
  2484. + skip 'chmod not supported' if Gem.win_platform?
  2485. +
  2486. + begin
  2487. + File.chmod 0444, 'test'
  2488. +
  2489. + assert_equal ["\xCF", "\x80"], Gem.read_binary('test').chars.to_a
  2490. + ensure
  2491. + File.chmod 0644, 'test'
  2492. + end
  2493. end
  2494. def test_self_refresh
  2495. + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7"
  2496. util_make_gems
  2497. a1_spec = @a1.spec_file
  2498. @@ -602,6 +607,7 @@ class TestGem < Gem::TestCase
  2499. end
  2500. def test_self_refresh_keeps_loaded_specs_activated
  2501. + skip 'Insecure operation - mkdir' if RUBY_VERSION <= "1.8.7"
  2502. util_make_gems
  2503. a1_spec = @a1.spec_file
  2504. @@ -624,46 +630,44 @@ class TestGem < Gem::TestCase
  2505. def test_self_ruby_escaping_spaces_in_path
  2506. orig_ruby = Gem.ruby
  2507. - orig_bindir = Gem::ConfigMap[:bindir]
  2508. - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name]
  2509. - orig_exe_ext = Gem::ConfigMap[:EXEEXT]
  2510. + orig_bindir = RbConfig::CONFIG['bindir']
  2511. + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
  2512. + orig_exe_ext = RbConfig::CONFIG['EXEEXT']
  2513. - Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin"
  2514. - Gem::ConfigMap[:ruby_install_name] = "ruby"
  2515. - Gem::ConfigMap[:EXEEXT] = ".exe"
  2516. + RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin"
  2517. + RbConfig::CONFIG['ruby_install_name'] = "ruby"
  2518. + RbConfig::CONFIG['EXEEXT'] = ".exe"
  2519. Gem.instance_variable_set("@ruby", nil)
  2520. assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
  2521. ensure
  2522. Gem.instance_variable_set("@ruby", orig_ruby)
  2523. - Gem::ConfigMap[:bindir] = orig_bindir
  2524. - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name
  2525. - Gem::ConfigMap[:EXEEXT] = orig_exe_ext
  2526. + RbConfig::CONFIG['bindir'] = orig_bindir
  2527. + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
  2528. + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
  2529. end
  2530. def test_self_ruby_path_without_spaces
  2531. orig_ruby = Gem.ruby
  2532. - orig_bindir = Gem::ConfigMap[:bindir]
  2533. - orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name]
  2534. - orig_exe_ext = Gem::ConfigMap[:EXEEXT]
  2535. + orig_bindir = RbConfig::CONFIG['bindir']
  2536. + orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name']
  2537. + orig_exe_ext = RbConfig::CONFIG['EXEEXT']
  2538. - Gem::ConfigMap[:bindir] = "C:/Ruby18/bin"
  2539. - Gem::ConfigMap[:ruby_install_name] = "ruby"
  2540. - Gem::ConfigMap[:EXEEXT] = ".exe"
  2541. + RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin"
  2542. + RbConfig::CONFIG['ruby_install_name'] = "ruby"
  2543. + RbConfig::CONFIG['EXEEXT'] = ".exe"
  2544. Gem.instance_variable_set("@ruby", nil)
  2545. assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
  2546. ensure
  2547. Gem.instance_variable_set("@ruby", orig_ruby)
  2548. - Gem::ConfigMap[:bindir] = orig_bindir
  2549. - Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name
  2550. - Gem::ConfigMap[:EXEEXT] = orig_exe_ext
  2551. + RbConfig::CONFIG['bindir'] = orig_bindir
  2552. + RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name
  2553. + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
  2554. end
  2555. def test_self_ruby_api_version
  2556. - orig_MAJOR, Gem::ConfigMap[:MAJOR] = Gem::ConfigMap[:MAJOR], '1'
  2557. - orig_MINOR, Gem::ConfigMap[:MINOR] = Gem::ConfigMap[:MINOR], '2'
  2558. - orig_TEENY, Gem::ConfigMap[:TEENY] = Gem::ConfigMap[:TEENY], '3'
  2559. + orig_ruby_version, RbConfig::CONFIG['ruby_version'] = RbConfig::CONFIG['ruby_version'], '1.2.3'
  2560. Gem.instance_variable_set :@ruby_api_version, nil
  2561. @@ -671,9 +675,7 @@ class TestGem < Gem::TestCase
  2562. ensure
  2563. Gem.instance_variable_set :@ruby_api_version, nil
  2564. - Gem::ConfigMap[:MAJOR] = orig_MAJOR
  2565. - Gem::ConfigMap[:MINOR] = orig_MINOR
  2566. - Gem::ConfigMap[:TEENY] = orig_TEENY
  2567. + RbConfig::CONFIG['ruby_version'] = orig_ruby_version
  2568. end
  2569. def test_self_ruby_version_1_8_5
  2570. @@ -825,7 +827,7 @@ class TestGem < Gem::TestCase
  2571. def test_self_user_dir
  2572. parts = [@userhome, '.gem', Gem.ruby_engine]
  2573. - parts << Gem::ConfigMap[:ruby_version] unless Gem::ConfigMap[:ruby_version].empty?
  2574. + parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
  2575. assert_equal File.join(parts), Gem.user_dir
  2576. end
  2577. @@ -857,6 +859,7 @@ class TestGem < Gem::TestCase
  2578. end
  2579. def test_self_needs_picks_up_unresolved_deps
  2580. + skip 'loading from unsafe file' if RUBY_VERSION <= "1.8.7"
  2581. save_loaded_features do
  2582. util_clear_gems
  2583. a = util_spec "a", "1"
  2584. @@ -949,6 +952,7 @@ class TestGem < Gem::TestCase
  2585. end
  2586. def test_load_plugins
  2587. + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
  2588. plugin_path = File.join "lib", "rubygems_plugin.rb"
  2589. Dir.chdir @tempdir do
  2590. @@ -1102,6 +1106,7 @@ class TestGem < Gem::TestCase
  2591. end
  2592. def test_auto_activation_of_detected_gemdeps_file
  2593. + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
  2594. util_clear_gems
  2595. a = new_spec "a", "1", nil, "lib/a.rb"
  2596. @@ -1264,6 +1269,7 @@ class TestGem < Gem::TestCase
  2597. end
  2598. def test_use_gemdeps_automatic
  2599. + skip 'Insecure operation - chdir' if RUBY_VERSION <= "1.8.7"
  2600. rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], '-'
  2601. spec = util_spec 'a', 1
  2602. @@ -1300,6 +1306,7 @@ class TestGem < Gem::TestCase
  2603. end
  2604. def test_use_gemdeps_specific
  2605. + skip 'Insecure operation - read' if RUBY_VERSION <= "1.8.7"
  2606. rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], 'x'
  2607. spec = util_spec 'a', 1
  2608. @@ -1317,6 +1324,19 @@ class TestGem < Gem::TestCase
  2609. ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
  2610. end
  2611. + def ruby_install_name name
  2612. + orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name']
  2613. + RbConfig::CONFIG['ruby_install_name'] = name
  2614. +
  2615. + yield
  2616. + ensure
  2617. + if orig_RUBY_INSTALL_NAME then
  2618. + RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME
  2619. + else
  2620. + RbConfig::CONFIG.delete 'ruby_install_name'
  2621. + end
  2622. + end
  2623. +
  2624. def with_plugin(path)
  2625. test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}",
  2626. @@project_dir)
  2627. diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb
  2628. index d87e84f..7f5cf22 100644
  2629. --- a/test/rubygems/test_gem_commands_contents_command.rb
  2630. +++ b/test/rubygems/test_gem_commands_contents_command.rb
  2631. @@ -169,9 +169,9 @@ lib/foo.rb
  2632. end
  2633. expected = [
  2634. - File.join(Gem::ConfigMap[:bindir], 'default_command'),
  2635. - File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'),
  2636. - File.join(Gem::ConfigMap[:archdir], 'default_gem.so')
  2637. + File.join(RbConfig::CONFIG['bindir'], 'default_command'),
  2638. + File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'),
  2639. + File.join(RbConfig::CONFIG['archdir'], 'default_gem.so')
  2640. ].sort.join "\n"
  2641. assert_equal expected, @ui.output.chomp
  2642. diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
  2643. index 253c459..bb7589f 100644
  2644. --- a/test/rubygems/test_gem_commands_environment_command.rb
  2645. +++ b/test/rubygems/test_gem_commands_environment_command.rb
  2646. @@ -26,7 +26,7 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase
  2647. assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
  2648. @ui.output
  2649. assert_match %r|RUBYGEMS PREFIX: |, @ui.output
  2650. - assert_match %r|RUBY EXECUTABLE:.*#{Gem::ConfigMap[:ruby_install_name]}|,
  2651. + assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|,
  2652. @ui.output
  2653. assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output
  2654. assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
  2655. diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
  2656. index 00bbf7b..6315cb5 100644
  2657. --- a/test/rubygems/test_gem_commands_install_command.rb
  2658. +++ b/test/rubygems/test_gem_commands_install_command.rb
  2659. @@ -316,6 +316,7 @@ ERROR: Possible alternatives: non_existent_with_hint
  2660. end
  2661. def test_execute_rdoc
  2662. + skip if RUBY_VERSION <= "1.8.7"
  2663. specs = spec_fetcher do |fetcher|
  2664. fetcher.gem 'a', 2
  2665. end
  2666. @@ -559,6 +560,20 @@ ERROR: Possible alternatives: non_existent_with_hint
  2667. assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
  2668. end
  2669. + def test_install_gem_ignore_dependencies_specific_file
  2670. + spec = quick_spec 'a', 2
  2671. +
  2672. + util_build_gem spec
  2673. +
  2674. + FileUtils.mv spec.cache_file, @tempdir
  2675. +
  2676. + @cmd.options[:ignore_dependencies] = true
  2677. +
  2678. + @cmd.install_gem File.join(@tempdir, spec.file_name), nil
  2679. +
  2680. + assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name }
  2681. + end
  2682. +
  2683. def test_parses_requirement_from_gemname
  2684. spec_fetcher do |fetcher|
  2685. fetcher.gem 'a', 2
  2686. diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
  2687. index 7537c1c..d259383 100644
  2688. --- a/test/rubygems/test_gem_commands_update_command.rb
  2689. +++ b/test/rubygems/test_gem_commands_update_command.rb
  2690. @@ -217,6 +217,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
  2691. end
  2692. def test_execute_rdoc
  2693. + skip if RUBY_VERSION <= "1.8.7"
  2694. spec_fetcher do |fetcher|
  2695. fetcher.gem 'a', 2
  2696. @@ -239,7 +240,6 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
  2697. a2 = @specs['a-2']
  2698. - assert_path_exists File.join(a2.doc_dir, 'ri')
  2699. assert_path_exists File.join(a2.doc_dir, 'rdoc')
  2700. end
  2701. diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
  2702. index 0a82fa6..352ebbb 100644
  2703. --- a/test/rubygems/test_gem_dependency_installer.rb
  2704. +++ b/test/rubygems/test_gem_dependency_installer.rb
  2705. @@ -551,7 +551,7 @@ class TestGemDependencyInstaller < Gem::TestCase
  2706. env = "/\\S+/env" unless Gem.win_platform?
  2707. - assert_match %r|\A#!#{env} #{Gem::ConfigMap[:ruby_install_name]}\n|,
  2708. + assert_match %r|\A#!#{env} #{RbConfig::CONFIG['ruby_install_name']}\n|,
  2709. File.read(File.join(@gemhome, 'bin', 'a_bin'))
  2710. end
  2711. diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb
  2712. index aa9008c..367c933 100644
  2713. --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb
  2714. +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb
  2715. @@ -42,47 +42,46 @@ class TestGemExtExtConfBuilder < Gem::TestCase
  2716. end
  2717. def test_class_build_rbconfig_make_prog
  2718. - configure_args = RbConfig::CONFIG['configure_args']
  2719. + configure_args do
  2720. - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
  2721. - extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
  2722. - end
  2723. + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
  2724. + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
  2725. + end
  2726. - output = []
  2727. + output = []
  2728. - Dir.chdir @ext do
  2729. - Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
  2730. - end
  2731. + Dir.chdir @ext do
  2732. + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
  2733. + end
  2734. - assert_equal "creating Makefile\n", output[1]
  2735. - assert_contains_make_command 'clean', output[2]
  2736. - assert_contains_make_command '', output[4]
  2737. - assert_contains_make_command 'install', output[6]
  2738. - ensure
  2739. - RbConfig::CONFIG['configure_args'] = configure_args
  2740. + assert_equal "creating Makefile\n", output[1]
  2741. + assert_contains_make_command 'clean', output[2]
  2742. + assert_contains_make_command '', output[4]
  2743. + assert_contains_make_command 'install', output[6]
  2744. + end
  2745. end
  2746. def test_class_build_env_make
  2747. - configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make')
  2748. - RbConfig::CONFIG['configure_args'] = ''
  2749. + env_make = ENV.delete 'make'
  2750. ENV['make'] = 'anothermake'
  2751. - File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
  2752. - extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
  2753. - end
  2754. + configure_args '' do
  2755. + File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
  2756. + extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
  2757. + end
  2758. - output = []
  2759. + output = []
  2760. - assert_raises Gem::InstallError do
  2761. - Dir.chdir @ext do
  2762. - Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
  2763. + assert_raises Gem::InstallError do
  2764. + Dir.chdir @ext do
  2765. + Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
  2766. + end
  2767. end
  2768. - end
  2769. - assert_equal "creating Makefile\n", output[1]
  2770. - assert_contains_make_command 'clean', output[2]
  2771. + assert_equal "creating Makefile\n", output[1]
  2772. + assert_contains_make_command 'clean', output[2]
  2773. + end
  2774. ensure
  2775. - RbConfig::CONFIG['configure_args'] = configure_args
  2776. ENV['make'] = env_make
  2777. end
  2778. @@ -108,6 +107,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase
  2779. assert_equal 'extconf failed, exit code 1', error.message
  2780. assert_equal("#{Gem.ruby} extconf.rb", output[0])
  2781. + assert_path_exists File.join @dest_path, 'mkmf.log'
  2782. end
  2783. def test_class_build_unconventional
  2784. @@ -188,5 +188,19 @@ end
  2785. assert_equal 'Makefile not found', error.message
  2786. end
  2787. + def configure_args args = nil
  2788. + configure_args = RbConfig::CONFIG['configure_args']
  2789. + RbConfig::CONFIG['configure_args'] = args if args
  2790. +
  2791. + yield
  2792. +
  2793. + ensure
  2794. + if configure_args then
  2795. + RbConfig::CONFIG['configure_args'] = configure_args
  2796. + else
  2797. + RbConfig::CONFIG.delete 'configure_args'
  2798. + end
  2799. + end
  2800. +
  2801. end
  2802. diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
  2803. index 615a9b5..eff62ab 100644
  2804. --- a/test/rubygems/test_gem_installer.rb
  2805. +++ b/test/rubygems/test_gem_installer.rb
  2806. @@ -41,7 +41,7 @@ version = \">= 0\"
  2807. if ARGV.first
  2808. str = ARGV.first
  2809. str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  2810. - if str =~ /\\A_(.*)_\\z/
  2811. + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
  2812. version = $1
  2813. ARGV.shift
  2814. end
  2815. @@ -84,8 +84,8 @@ load Gem.bin_path('a', 'executable', version)
  2816. orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
  2817. Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
  2818. end
  2819. - orig_bindir = Gem::ConfigMap[:bindir]
  2820. - Gem::ConfigMap[:bindir] = Gem.bindir
  2821. + orig_bindir = RbConfig::CONFIG['bindir']
  2822. + RbConfig::CONFIG['bindir'] = Gem.bindir
  2823. util_conflict_executable false
  2824. @@ -102,7 +102,11 @@ load Gem.bin_path('a', 'executable', version)
  2825. ensure
  2826. Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
  2827. orig_RUBY_FRAMEWORK_VERSION
  2828. - Gem::ConfigMap[:bindir] = orig_bindir
  2829. + if orig_bindir then
  2830. + RbConfig::CONFIG['bindir'] = orig_bindir
  2831. + else
  2832. + RbConfig::CONFIG.delete 'bindir'
  2833. + end
  2834. end
  2835. def test_check_executable_overwrite_format_executable
  2836. @@ -1192,7 +1196,7 @@ gem 'other', version
  2837. env_shebang = "/usr/bin/env" unless Gem.win_platform?
  2838. - assert_equal("#!#{env_shebang} #{Gem::ConfigMap[:ruby_install_name]}",
  2839. + assert_equal("#!#{env_shebang} #{RbConfig::CONFIG['ruby_install_name']}",
  2840. shebang)
  2841. end
  2842. diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb
  2843. index 5d85543..8f1f0c4 100644
  2844. --- a/test/rubygems/test_gem_package_tar_header.rb
  2845. +++ b/test/rubygems/test_gem_package_tar_header.rb
  2846. @@ -72,6 +72,20 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
  2847. end
  2848. end
  2849. + def test_initialize_typeflag
  2850. + header = {
  2851. + :mode => '',
  2852. + :name => '',
  2853. + :prefix => '',
  2854. + :size => '',
  2855. + :typeflag => '',
  2856. + }
  2857. +
  2858. + tar_header = Gem::Package::TarHeader.new header
  2859. +
  2860. + assert_equal '0', tar_header.typeflag
  2861. + end
  2862. +
  2863. def test_empty_eh
  2864. refute_empty @tar_header
  2865. diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
  2866. index 5966710..17577dc 100644
  2867. --- a/test/rubygems/test_gem_platform.rb
  2868. +++ b/test/rubygems/test_gem_platform.rb
  2869. @@ -116,7 +116,11 @@ class TestGemPlatform < Gem::TestCase
  2870. assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
  2871. ensure
  2872. - RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
  2873. + if orig_RUBY_SO_NAME then
  2874. + RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
  2875. + else
  2876. + RbConfig::CONFIG.delete 'RUBY_SO_NAME'
  2877. + end
  2878. end
  2879. def test_initialize_platform
  2880. diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
  2881. index 7e6d9c7..79f3a58 100644
  2882. --- a/test/rubygems/test_gem_remote_fetcher.rb
  2883. +++ b/test/rubygems/test_gem_remote_fetcher.rb
  2884. @@ -208,15 +208,15 @@ gems:
  2885. fetcher.instance_variable_set :@test_data, data
  2886. unless blow then
  2887. - def fetcher.fetch_path arg
  2888. + def fetcher.fetch_path arg, *rest
  2889. @test_arg = arg
  2890. @test_data
  2891. end
  2892. else
  2893. - def fetcher.fetch_path arg
  2894. + def fetcher.fetch_path arg, *rest
  2895. # OMG I'm such an ass
  2896. class << self; remove_method :fetch_path; end
  2897. - def self.fetch_path arg
  2898. + def self.fetch_path arg, *rest
  2899. @test_arg = arg
  2900. @test_data
  2901. end
  2902. diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb
  2903. index 04ff507..bcbbcf1 100644
  2904. --- a/test/rubygems/test_gem_request.rb
  2905. +++ b/test/rubygems/test_gem_request.rb
  2906. @@ -1,9 +1,16 @@
  2907. require 'rubygems/test_case'
  2908. require 'rubygems/request'
  2909. require 'ostruct'
  2910. +require 'base64'
  2911. class TestGemRequest < Gem::TestCase
  2912. + CA_CERT_FILE = cert_path 'ca'
  2913. + CHILD_CERT = load_cert 'child'
  2914. + PUBLIC_CERT = load_cert 'public'
  2915. + PUBLIC_CERT_FILE = cert_path 'public'
  2916. + SSL_CERT = load_cert 'ssl'
  2917. +
  2918. def setup
  2919. @proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY]
  2920. @old_proxies = @proxies.map {|k| ENV[k] }
  2921. @@ -62,6 +69,44 @@ class TestGemRequest < Gem::TestCase
  2922. assert_equal URI(@proxy_uri), proxy
  2923. end
  2924. + def test_configure_connection_for_https
  2925. + connection = Net::HTTP.new 'localhost', 443
  2926. +
  2927. + request = Gem::Request.new URI('https://example'), nil, nil, nil
  2928. +
  2929. + def request.add_rubygems_trusted_certs store
  2930. + store.add_cert TestGemRequest::PUBLIC_CERT
  2931. + end
  2932. +
  2933. + request.configure_connection_for_https connection
  2934. +
  2935. + cert_store = connection.cert_store
  2936. +
  2937. + assert cert_store.verify CHILD_CERT
  2938. + end
  2939. +
  2940. + def test_configure_connection_for_https_ssl_ca_cert
  2941. + ssl_ca_cert, Gem.configuration.ssl_ca_cert =
  2942. + Gem.configuration.ssl_ca_cert, CA_CERT_FILE
  2943. +
  2944. + connection = Net::HTTP.new 'localhost', 443
  2945. +
  2946. + request = Gem::Request.new URI('https://example'), nil, nil, nil
  2947. +
  2948. + def request.add_rubygems_trusted_certs store
  2949. + store.add_cert TestGemRequest::PUBLIC_CERT
  2950. + end
  2951. +
  2952. + request.configure_connection_for_https connection
  2953. +
  2954. + cert_store = connection.cert_store
  2955. +
  2956. + assert cert_store.verify CHILD_CERT
  2957. + assert cert_store.verify SSL_CERT
  2958. + ensure
  2959. + Gem.configuration.ssl_ca_cert = ssl_ca_cert
  2960. + end
  2961. +
  2962. def test_get_proxy_from_env_fallback
  2963. ENV['http_proxy'] = @proxy_uri
  2964. @@ -124,6 +169,30 @@ class TestGemRequest < Gem::TestCase
  2965. assert_equal :junk, response.body
  2966. end
  2967. + def test_fetch_basic_auth
  2968. + uri = URI.parse "https://user:pass@example.rubygems/specs.#{Gem.marshal_version}"
  2969. + @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
  2970. + conn = util_stub_connection_for :body => :junk, :code => 200
  2971. +
  2972. + @request.fetch
  2973. +
  2974. + auth_header = conn.payload['Authorization']
  2975. +
  2976. + assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header
  2977. + end
  2978. +
  2979. + def test_fetch_basic_auth_encoded
  2980. + uri = URI.parse "https://user:%7BDEScede%7Dpass@example.rubygems/specs.#{Gem.marshal_version}"
  2981. + @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
  2982. + conn = util_stub_connection_for :body => :junk, :code => 200
  2983. +
  2984. + @request.fetch
  2985. +
  2986. + auth_header = conn.payload['Authorization']
  2987. +
  2988. + assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header
  2989. + end
  2990. +
  2991. def test_fetch_head
  2992. uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
  2993. @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
  2994. diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb
  2995. index 8275795..a5fcdcc 100644
  2996. --- a/test/rubygems/test_gem_request_set.rb
  2997. +++ b/test/rubygems/test_gem_request_set.rb
  2998. @@ -59,6 +59,8 @@ class TestGemRequestSet < Gem::TestCase
  2999. assert_includes installed, 'a-2'
  3000. assert_path_exists File.join @gemhome, 'gems', 'a-2'
  3001. assert_path_exists 'gem.deps.rb.lock'
  3002. +
  3003. + assert rs.remote
  3004. end
  3005. def test_install_from_gemdeps_install_dir
  3006. @@ -89,6 +91,25 @@ class TestGemRequestSet < Gem::TestCase
  3007. refute_path_exists File.join Gem.dir, 'gems', 'a-2'
  3008. end
  3009. + def test_install_from_gemdeps_local
  3010. + spec_fetcher do |fetcher|
  3011. + fetcher.gem 'a', 2
  3012. + end
  3013. +
  3014. + rs = Gem::RequestSet.new
  3015. +
  3016. + open 'gem.deps.rb', 'w' do |io|
  3017. + io.puts 'gem "a"'
  3018. + io.flush
  3019. +
  3020. + assert_raises Gem::UnsatisfiableDependencyError do
  3021. + rs.install_from_gemdeps :gemdeps => io.path, :domain => :local
  3022. + end
  3023. + end
  3024. +
  3025. + refute rs.remote
  3026. + end
  3027. +
  3028. def test_install_from_gemdeps_lockfile
  3029. spec_fetcher do |fetcher|
  3030. fetcher.gem 'a', 1
  3031. diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb
  3032. index 9e0cab4..0be69bf 100644
  3033. --- a/test/rubygems/test_gem_request_set_lockfile.rb
  3034. +++ b/test/rubygems/test_gem_request_set_lockfile.rb
  3035. @@ -218,6 +218,7 @@ GEM
  3036. c (~> 4)
  3037. d
  3038. e (~> 5.0, >= 5.0.1)
  3039. + b (3-x86_64-linux)
  3040. PLATFORMS
  3041. #{Gem::Platform::RUBY}
  3042. @@ -238,7 +239,14 @@ DEPENDENCIES
  3043. assert lockfile_set, 'could not find a LockSet'
  3044. - assert_equal %w[a-2], lockfile_set.specs.map { |tuple| tuple.full_name }
  3045. + assert_equal %w[a-2 b-3], lockfile_set.specs.map { |tuple| tuple.full_name }
  3046. +
  3047. + expected = [
  3048. + Gem::Platform::RUBY,
  3049. + Gem::Platform.new('x86_64-linux'),
  3050. + ]
  3051. +
  3052. + assert_equal expected, lockfile_set.specs.map { |tuple| tuple.platform }
  3053. spec = lockfile_set.specs.first
  3054. diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
  3055. index 7d3311c..c97e9e7 100644
  3056. --- a/test/rubygems/test_gem_resolver.rb
  3057. +++ b/test/rubygems/test_gem_resolver.rb
  3058. @@ -33,6 +33,14 @@ class TestGemResolver < Gem::TestCase
  3059. assert_same Gem::Resolver, Gem::DependencyResolver
  3060. end
  3061. + def test_self_compose_sets_best_set
  3062. + best_set = @DR::BestSet.new
  3063. +
  3064. + composed = @DR.compose_sets best_set
  3065. +
  3066. + assert_equal best_set, composed
  3067. + end
  3068. +
  3069. def test_self_compose_sets_multiple
  3070. index_set = @DR::IndexSet.new
  3071. vendor_set = @DR::VendorSet.new
  3072. diff --git a/test/rubygems/test_gem_resolver_api_set.rb b/test/rubygems/test_gem_resolver_api_set.rb
  3073. index 288f496..245f6c1 100644
  3074. --- a/test/rubygems/test_gem_resolver_api_set.rb
  3075. +++ b/test/rubygems/test_gem_resolver_api_set.rb
  3076. @@ -17,6 +17,14 @@ class TestGemResolverAPISet < Gem::TestCase
  3077. assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source
  3078. end
  3079. + def test_initialize_deeper_uri
  3080. + set = @DR::APISet.new 'https://rubygemsserver.com/mygems/api/v1/dependencies'
  3081. +
  3082. + assert_equal URI('https://rubygemsserver.com/mygems/api/v1/dependencies'), set.dep_uri
  3083. + assert_equal URI('https://rubygemsserver.com/mygems/'), set.uri
  3084. + assert_equal Gem::Source.new(URI('https://rubygemsserver.com/mygems/')), set.source
  3085. + end
  3086. +
  3087. def test_initialize_uri
  3088. set = @DR::APISet.new @dep_uri
  3089. @@ -74,6 +82,15 @@ class TestGemResolverAPISet < Gem::TestCase
  3090. assert_equal expected, set.find_all(a_dep)
  3091. end
  3092. + def test_find_all_local
  3093. + set = @DR::APISet.new @dep_uri
  3094. + set.remote = false
  3095. +
  3096. + a_dep = @DR::DependencyRequest.new dep('a'), nil
  3097. +
  3098. + assert_empty set.find_all(a_dep)
  3099. + end
  3100. +
  3101. def test_find_all_missing
  3102. spec_fetcher
  3103. @@ -163,5 +180,29 @@ class TestGemResolverAPISet < Gem::TestCase
  3104. set.prefetch [a_dep, b_dep]
  3105. end
  3106. + def test_prefetch_local
  3107. + spec_fetcher
  3108. +
  3109. + data = [
  3110. + { :name => 'a',
  3111. + :number => '1',
  3112. + :platform => 'ruby',
  3113. + :dependencies => [], },
  3114. + ]
  3115. +
  3116. + @fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
  3117. + @fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump []
  3118. +
  3119. + set = @DR::APISet.new @dep_uri
  3120. + set.remote = false
  3121. +
  3122. + a_dep = @DR::DependencyRequest.new dep('a'), nil
  3123. + b_dep = @DR::DependencyRequest.new dep('b'), nil
  3124. +
  3125. + set.prefetch [a_dep, b_dep]
  3126. +
  3127. + assert_empty set.instance_variable_get :@data
  3128. + end
  3129. +
  3130. end
  3131. diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb
  3132. index 5bcff4a..2d16f8b 100644
  3133. --- a/test/rubygems/test_gem_resolver_best_set.rb
  3134. +++ b/test/rubygems/test_gem_resolver_best_set.rb
  3135. @@ -8,6 +8,12 @@ class TestGemResolverBestSet < Gem::TestCase
  3136. @DR = Gem::Resolver
  3137. end
  3138. + def test_initialize
  3139. + set = @DR::BestSet.new
  3140. +
  3141. + assert_empty set.sets
  3142. + end
  3143. +
  3144. def test_find_all_index
  3145. spec_fetcher do |fetcher|
  3146. fetcher.spec 'a', 1
  3147. @@ -26,5 +32,49 @@ class TestGemResolverBestSet < Gem::TestCase
  3148. assert_equal %w[a-1], found.map { |s| s.full_name }
  3149. end
  3150. + def test_find_all_local
  3151. + spec_fetcher do |fetcher|
  3152. + fetcher.spec 'a', 1
  3153. + fetcher.spec 'a', 2
  3154. + fetcher.spec 'b', 1
  3155. + end
  3156. +
  3157. + set = @DR::BestSet.new
  3158. + set.remote = false
  3159. +
  3160. + dependency = dep 'a', '~> 1'
  3161. +
  3162. + req = @DR::DependencyRequest.new dependency, nil
  3163. +
  3164. + found = set.find_all req
  3165. +
  3166. + assert_empty found
  3167. + end
  3168. +
  3169. + def test_prefetch
  3170. + spec_fetcher do |fetcher|
  3171. + fetcher.spec 'a', 1
  3172. + end
  3173. +
  3174. + set = @DR::BestSet.new
  3175. +
  3176. + set.prefetch []
  3177. +
  3178. + refute_empty set.sets
  3179. + end
  3180. +
  3181. + def test_prefetch_local
  3182. + spec_fetcher do |fetcher|
  3183. + fetcher.spec 'a', 1
  3184. + end
  3185. +
  3186. + set = @DR::BestSet.new
  3187. + set.remote = false
  3188. +
  3189. + set.prefetch []
  3190. +
  3191. + assert_empty set.sets
  3192. + end
  3193. +
  3194. end
  3195. diff --git a/test/rubygems/test_gem_resolver_git_set.rb b/test/rubygems/test_gem_resolver_git_set.rb
  3196. index 4643624..f82b942 100644
  3197. --- a/test/rubygems/test_gem_resolver_git_set.rb
  3198. +++ b/test/rubygems/test_gem_resolver_git_set.rb
  3199. @@ -70,6 +70,21 @@ class TestGemResolverGitSet < Gem::TestCase
  3200. assert_equal [@set.specs['a']], found
  3201. end
  3202. + def test_find_all_local
  3203. + name, _, repository, = git_gem
  3204. +
  3205. + @set.add_git_gem name, repository, 'master', false
  3206. + @set.remote = false
  3207. +
  3208. + dependency = dep 'a', '~> 1.0'
  3209. + req = Gem::Resolver::DependencyRequest.new dependency, nil
  3210. + @reqs.add req
  3211. +
  3212. + @set.prefetch @reqs
  3213. +
  3214. + assert_empty @set.find_all dependency
  3215. + end
  3216. +
  3217. def test_root_dir
  3218. assert_equal Gem.dir, @set.root_dir
  3219. diff --git a/test/rubygems/test_gem_resolver_index_set.rb b/test/rubygems/test_gem_resolver_index_set.rb
  3220. index 137e9b5..b0adc51 100644
  3221. --- a/test/rubygems/test_gem_resolver_index_set.rb
  3222. +++ b/test/rubygems/test_gem_resolver_index_set.rb
  3223. @@ -24,5 +24,40 @@ class TestGemResolverIndexSet < Gem::TestCase
  3224. refute_same Gem::SpecFetcher.fetcher, fetcher
  3225. end
  3226. + def test_find_all
  3227. + spec_fetcher do |fetcher|
  3228. + fetcher.spec 'a', 1
  3229. + fetcher.spec 'a', 2
  3230. + fetcher.spec 'b', 1
  3231. + end
  3232. +
  3233. + set = @DR::BestSet.new
  3234. +
  3235. + dependency = dep 'a', '~> 1'
  3236. +
  3237. + req = @DR::DependencyRequest.new dependency, nil
  3238. +
  3239. + found = set.find_all req
  3240. +
  3241. + assert_equal %w[a-1], found.map { |s| s.full_name }
  3242. + end
  3243. +
  3244. + def test_find_all_local
  3245. + spec_fetcher do |fetcher|
  3246. + fetcher.spec 'a', 1
  3247. + fetcher.spec 'a', 2
  3248. + fetcher.spec 'b', 1
  3249. + end
  3250. +
  3251. + set = @DR::BestSet.new
  3252. + set.remote = false
  3253. +
  3254. + dependency = dep 'a', '~> 1'
  3255. +
  3256. + req = @DR::DependencyRequest.new dependency, nil
  3257. +
  3258. + assert_empty set.find_all req
  3259. + end
  3260. +
  3261. end
  3262. diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb
  3263. index af4db64..258f9bc 100644
  3264. --- a/test/rubygems/test_gem_resolver_installer_set.rb
  3265. +++ b/test/rubygems/test_gem_resolver_installer_set.rb
  3266. @@ -2,6 +2,34 @@ require 'rubygems/test_case'
  3267. class TestGemResolverInstallerSet < Gem::TestCase
  3268. + def test_consider_local_eh
  3269. + set = Gem::Resolver::InstallerSet.new :remote
  3270. +
  3271. + refute set.consider_local?
  3272. +
  3273. + set = Gem::Resolver::InstallerSet.new :both
  3274. +
  3275. + assert set.consider_local?
  3276. +
  3277. + set = Gem::Resolver::InstallerSet.new :local
  3278. +
  3279. + assert set.consider_local?
  3280. + end
  3281. +
  3282. + def test_consider_remote_eh
  3283. + set = Gem::Resolver::InstallerSet.new :remote
  3284. +
  3285. + assert set.consider_remote?
  3286. +
  3287. + set = Gem::Resolver::InstallerSet.new :both
  3288. +
  3289. + assert set.consider_remote?
  3290. +
  3291. + set = Gem::Resolver::InstallerSet.new :local
  3292. +
  3293. + refute set.consider_remote?
  3294. + end
  3295. +
  3296. def test_load_spec
  3297. specs = spec_fetcher do |fetcher|
  3298. fetcher.spec 'a', 2
  3299. @@ -18,5 +46,47 @@ class TestGemResolverInstallerSet < Gem::TestCase
  3300. assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
  3301. end
  3302. + def test_remote_equals_both
  3303. + set = Gem::Resolver::InstallerSet.new :both
  3304. + set.remote = true
  3305. +
  3306. + assert set.consider_local?
  3307. + assert set.consider_remote?
  3308. +
  3309. + set = Gem::Resolver::InstallerSet.new :both
  3310. + set.remote = false
  3311. +
  3312. + assert set.consider_local?
  3313. + refute set.consider_remote?
  3314. + end
  3315. +
  3316. + def test_remote_equals_local
  3317. + set = Gem::Resolver::InstallerSet.new :local
  3318. + set.remote = true
  3319. +
  3320. + assert set.consider_local?
  3321. + assert set.consider_remote?
  3322. +
  3323. + set = Gem::Resolver::InstallerSet.new :local
  3324. + set.remote = false
  3325. +
  3326. + assert set.consider_local?
  3327. + refute set.consider_remote?
  3328. + end
  3329. +
  3330. + def test_remote_equals_remote
  3331. + set = Gem::Resolver::InstallerSet.new :remote
  3332. + set.remote = true
  3333. +
  3334. + refute set.consider_local?
  3335. + assert set.consider_remote?
  3336. +
  3337. + set = Gem::Resolver::InstallerSet.new :remote
  3338. + set.remote = false
  3339. +
  3340. + refute set.consider_local?
  3341. + refute set.consider_remote?
  3342. + end
  3343. +
  3344. end
  3345. diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
  3346. index 026492e..58bff84 100644
  3347. --- a/test/rubygems/test_gem_source_git.rb
  3348. +++ b/test/rubygems/test_gem_source_git.rb
  3349. @@ -27,6 +27,26 @@ class TestGemSourceGit < Gem::TestCase
  3350. assert_path_exists File.join @source.install_dir, 'a.gemspec'
  3351. end
  3352. + def test_checkout_local
  3353. + @source.remote = false
  3354. +
  3355. + @source.checkout
  3356. +
  3357. + install_dir = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}"
  3358. +
  3359. + refute_path_exists File.join install_dir, 'a.gemspec'
  3360. + end
  3361. +
  3362. + def test_checkout_local_cached
  3363. + @source.cache
  3364. +
  3365. + @source.remote = false
  3366. +
  3367. + @source.checkout
  3368. +
  3369. + assert_path_exists File.join @source.install_dir, 'a.gemspec'
  3370. + end
  3371. +
  3372. def test_checkout_submodules
  3373. source = Gem::Source::Git.new @name, @repository, 'master', true
  3374. @@ -54,6 +74,14 @@ class TestGemSourceGit < Gem::TestCase
  3375. end
  3376. end
  3377. + def test_cache_local
  3378. + @source.remote = false
  3379. +
  3380. + @source.cache
  3381. +
  3382. + refute_path_exists @source.repo_cache_dir
  3383. + end
  3384. +
  3385. def test_dir_shortref
  3386. @source.cache
  3387. @@ -99,6 +127,12 @@ class TestGemSourceGit < Gem::TestCase
  3388. assert_equal expected, @source.install_dir
  3389. end
  3390. + def test_install_dir_local
  3391. + @source.remote = false
  3392. +
  3393. + assert_nil @source.install_dir
  3394. + end
  3395. +
  3396. def test_repo_cache_dir
  3397. expected =
  3398. File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}"
  3399. @@ -211,6 +245,15 @@ class TestGemSourceGit < Gem::TestCase
  3400. assert_equal extension_dir, b_spec.extension_dir
  3401. end
  3402. + def test_specs_local
  3403. + source = Gem::Source::Git.new @name, @repository, 'master', true
  3404. + source.remote = false
  3405. +
  3406. + capture_io do
  3407. + assert_empty source.specs
  3408. + end
  3409. + end
  3410. +
  3411. def test_uri_hash
  3412. assert_equal @hash, @source.uri_hash
  3413. diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
  3414. index 7aa9d5a..1afb5ba 100644
  3415. --- a/test/rubygems/test_gem_specification.rb
  3416. +++ b/test/rubygems/test_gem_specification.rb
  3417. @@ -999,8 +999,8 @@ dependencies: []
  3418. assert_equal 'summary', spec.summary
  3419. assert_same spec.summary, new_spec.summary
  3420. - assert_equal %w[lib/file.rb test/file.rb bin/exec README.txt
  3421. - ext/extconf.rb].sort,
  3422. + assert_equal %w[README.txt bin/exec ext/extconf.rb lib/file.rb
  3423. + test/file.rb].sort,
  3424. spec.files
  3425. refute_same spec.files, new_spec.files, 'files'
  3426. @@ -1109,7 +1109,31 @@ dependencies: []
  3427. @a2.executable = 'app'
  3428. assert_equal nil, @a2.bindir
  3429. - assert_equal %w[lib/code.rb app].sort, @a2.files
  3430. + assert_equal %w[app lib/code.rb].sort, @a2.files
  3431. + end
  3432. +
  3433. + def test_extensions_equals_nil
  3434. + @a2.instance_variable_set(:@extensions, nil)
  3435. + assert_equal nil, @a2.instance_variable_get(:@extensions)
  3436. + assert_equal %w[lib/code.rb], @a2.files
  3437. + end
  3438. +
  3439. + def test_test_files_equals_nil
  3440. + @a2.instance_variable_set(:@test_files, nil)
  3441. + assert_equal nil, @a2.instance_variable_get(:@test_files)
  3442. + assert_equal %w[lib/code.rb], @a2.files
  3443. + end
  3444. +
  3445. + def test_executables_equals_nil
  3446. + @a2.instance_variable_set(:@executables, nil)
  3447. + assert_equal nil, @a2.instance_variable_get(:@executables)
  3448. + assert_equal %w[lib/code.rb], @a2.files
  3449. + end
  3450. +
  3451. + def test_extra_rdoc_files_equals_nil
  3452. + @a2.instance_variable_set(:@extra_rdoc_files, nil)
  3453. + assert_equal nil, @a2.instance_variable_get(:@extra_rdoc_files)
  3454. + assert_equal %w[lib/code.rb], @a2.files
  3455. end
  3456. def test_build_extensions
  3457. @@ -1437,7 +1461,7 @@ dependencies: []
  3458. def test_executable_equals
  3459. @a2.executable = 'app'
  3460. assert_equal 'app', @a2.executable
  3461. - assert_equal %w[lib/code.rb bin/app].sort, @a2.files
  3462. + assert_equal %w[bin/app lib/code.rb].sort, @a2.files
  3463. end
  3464. def test_extensions
  3465. @@ -1765,26 +1789,39 @@ dependencies: []
  3466. end
  3467. def test_require_paths
  3468. - enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
  3469. - RbConfig::CONFIG['ENABLE_SHARED'], 'no'
  3470. + enable_shared 'no' do
  3471. + ext_spec
  3472. - ext_spec
  3473. -
  3474. - @ext.require_path = 'lib'
  3475. + @ext.require_path = 'lib'
  3476. - ext_install_dir = Pathname(@ext.extension_dir)
  3477. - full_gem_path = Pathname(@ext.full_gem_path)
  3478. - relative_install_dir = ext_install_dir.relative_path_from full_gem_path
  3479. + ext_install_dir = Pathname(@ext.extension_dir)
  3480. + full_gem_path = Pathname(@ext.full_gem_path)
  3481. + relative_install_dir = ext_install_dir.relative_path_from full_gem_path
  3482. - assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths
  3483. - ensure
  3484. - RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
  3485. + assert_equal [relative_install_dir.to_s, 'lib'], @ext.require_paths
  3486. + end
  3487. end
  3488. def test_source
  3489. assert_kind_of Gem::Source::Installed, @a1.source
  3490. end
  3491. + def test_source_paths
  3492. + ext_spec
  3493. +
  3494. + @ext.require_paths = %w[lib ext foo]
  3495. + @ext.extensions << 'bar/baz'
  3496. +
  3497. + expected = %w[
  3498. + lib
  3499. + ext
  3500. + foo
  3501. + bar
  3502. + ]
  3503. +
  3504. + assert_equal expected, @ext.source_paths
  3505. + end
  3506. +
  3507. def test_full_require_paths
  3508. ext_spec
  3509. @@ -2435,7 +2472,7 @@ duplicate dependency on b (>= 1.2.3), (~> 1.2) use:
  3510. assert_equal '["lib2"] are not files', e.message
  3511. end
  3512. - assert_equal %w[lib/code.rb test/suite.rb bin/exec ext/a/extconf.rb lib2].sort,
  3513. + assert_equal %w[bin/exec ext/a/extconf.rb lib/code.rb lib2 test/suite.rb].sort,
  3514. @a1.files
  3515. end
  3516. @@ -2911,9 +2948,9 @@ end
  3517. def with_syck
  3518. begin
  3519. + verbose, $VERBOSE = $VERBOSE, nil
  3520. require "yaml"
  3521. old_engine = YAML::ENGINE.yamler
  3522. - verbose, $VERBOSE = $VERBOSE, nil
  3523. YAML::ENGINE.yamler = 'syck'
  3524. load 'rubygems/syck_hack.rb'
  3525. rescue NameError
  3526. diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb
  3527. index 1eea30f..11fdaf6 100644
  3528. --- a/test/rubygems/test_gem_uninstaller.rb
  3529. +++ b/test/rubygems/test_gem_uninstaller.rb
  3530. @@ -131,6 +131,23 @@ class TestGemUninstaller < Gem::InstallerTestCase
  3531. Gem::Installer.exec_format = nil
  3532. end
  3533. + def test_remove_not_in_home
  3534. + uninstaller = Gem::Uninstaller.new nil, :install_dir => "#{@gemhome}2"
  3535. +
  3536. + e = assert_raises Gem::GemNotInHomeException do
  3537. + use_ui ui do
  3538. + uninstaller.remove @spec
  3539. + end
  3540. + end
  3541. +
  3542. + expected =
  3543. + "Gem '#{@spec.full_name}' is not installed in directory #{@gemhome}2"
  3544. +
  3545. + assert_equal expected, e.message
  3546. +
  3547. + assert_path_exists @spec.gem_dir
  3548. + end
  3549. +
  3550. def test_path_ok_eh
  3551. uninstaller = Gem::Uninstaller.new nil
  3552. diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
  3553. index e0499fe..5a65b5c 100644
  3554. --- a/test/rubygems/test_gem_version.rb
  3555. +++ b/test/rubygems/test_gem_version.rb
  3556. @@ -3,6 +3,9 @@ require "rubygems/version"
  3557. class TestGemVersion < Gem::TestCase
  3558. + class V < ::Gem::Version
  3559. + end
  3560. +
  3561. def test_bump
  3562. assert_bumped_version_equal "5.3", "5.2.4"
  3563. end
  3564. @@ -37,6 +40,13 @@ class TestGemVersion < Gem::TestCase
  3565. assert_equal v('1.1'), Gem::Version.create(ver)
  3566. end
  3567. + def test_class_new_subclass
  3568. + v1 = Gem::Version.new '1'
  3569. + v2 = V.new '1'
  3570. +
  3571. + refute_same v1, v2
  3572. + end
  3573. +
  3574. def test_eql_eh
  3575. assert_version_eql "1.2", "1.2"
  3576. refute_version_eql "1.2", "1.2.0"
  3577. diff --git a/test/test_delegate.rb b/test/test_delegate.rb
  3578. index ca65ef3..6270cc6 100644
  3579. --- a/test/test_delegate.rb
  3580. +++ b/test/test_delegate.rb
  3581. @@ -180,4 +180,61 @@ class TestDelegateClass < Test::Unit::TestCase
  3582. x = assert_nothing_raised(ArgumentError, bug9155) {break Bug9155.new(1)}
  3583. assert_equal(1, x.to_i, bug9155)
  3584. end
  3585. +
  3586. + class Bug9403
  3587. + Name = '[ruby-core:59718] [Bug #9403]'
  3588. + SD = SimpleDelegator.new(new)
  3589. + class << SD
  3590. + def method_name
  3591. + __method__
  3592. + end
  3593. + def callee_name
  3594. + __callee__
  3595. + end
  3596. + alias aliased_name callee_name
  3597. + def dir_name
  3598. + __dir__
  3599. + end
  3600. + end
  3601. + dc = DelegateClass(self)
  3602. + dc.class_eval do
  3603. + def method_name
  3604. + __method__
  3605. + end
  3606. + def callee_name
  3607. + __callee__
  3608. + end
  3609. + alias aliased_name callee_name
  3610. + def dir_name
  3611. + __dir__
  3612. + end
  3613. + end
  3614. + DC = dc.new(new)
  3615. + end
  3616. +
  3617. + def test_method_in_simple_delegator
  3618. + assert_equal(:method_name, Bug9403::SD.method_name, Bug9403::Name)
  3619. + end
  3620. +
  3621. + def test_callee_in_simple_delegator
  3622. + assert_equal(:callee_name, Bug9403::SD.callee_name, Bug9403::Name)
  3623. + assert_equal(:aliased_name, Bug9403::SD.aliased_name, Bug9403::Name)
  3624. + end
  3625. +
  3626. + def test_dir_in_simple_delegator
  3627. + assert_equal(__dir__, Bug9403::SD.dir_name, Bug9403::Name)
  3628. + end
  3629. +
  3630. + def test_method_in_delegator_class
  3631. + assert_equal(:method_name, Bug9403::DC.method_name, Bug9403::Name)
  3632. + end
  3633. +
  3634. + def test_callee_in_delegator_class
  3635. + assert_equal(:callee_name, Bug9403::DC.callee_name, Bug9403::Name)
  3636. + assert_equal(:aliased_name, Bug9403::DC.aliased_name, Bug9403::Name)
  3637. + end
  3638. +
  3639. + def test_dir_in_delegator_class
  3640. + assert_equal(__dir__, Bug9403::DC.dir_name, Bug9403::Name)
  3641. + end
  3642. end
  3643. diff --git a/test/test_timeout.rb b/test/test_timeout.rb
  3644. index 9d51ca5..e849cc5 100644
  3645. --- a/test/test_timeout.rb
  3646. +++ b/test/test_timeout.rb
  3647. @@ -57,4 +57,33 @@ class TestTimeout < Test::Unit::TestCase
  3648. end
  3649. assert_raise_with_message(exc, /execution expired/) {raise e if e}
  3650. end
  3651. +
  3652. + def test_custom_exception
  3653. + bug9354 = '[ruby-core:59511] [Bug #9354]'
  3654. + err = Class.new(StandardError) do
  3655. + def initialize(msg) super end
  3656. + end
  3657. + assert_nothing_raised(ArgumentError, bug9354) do
  3658. + assert_equal(:ok, timeout(100, err) {:ok})
  3659. + end
  3660. + end
  3661. +
  3662. + def test_exit_exception
  3663. + assert_raise_with_message(Timeout::ExitException, "boon") do
  3664. + Timeout.timeout(10, Timeout::ExitException) do
  3665. + raise Timeout::ExitException, "boon"
  3666. + end
  3667. + end
  3668. + end
  3669. +
  3670. + def test_enumerator_next
  3671. + bug9380 = '[ruby-dev:47872] [Bug #9380]: timeout in Enumerator#next'
  3672. + e = (o=Object.new).to_enum
  3673. + def o.each
  3674. + sleep
  3675. + end
  3676. + assert_raise_with_message(Timeout::Error, 'execution expired', bug9380) do
  3677. + Timeout.timeout(0.01) {e.next}
  3678. + end
  3679. + end
  3680. end
  3681. diff --git a/test/test_weakref.rb b/test/test_weakref.rb
  3682. index 85820b1..f12e943 100644
  3683. --- a/test/test_weakref.rb
  3684. +++ b/test/test_weakref.rb
  3685. @@ -19,9 +19,14 @@ class TestWeakRef < Test::Unit::TestCase
  3686. end
  3687. def test_recycled
  3688. - weak = make_weakref
  3689. - ObjectSpace.garbage_collect
  3690. - ObjectSpace.garbage_collect
  3691. + weaks = []
  3692. + weak = nil
  3693. + 100.times do
  3694. + weaks << make_weakref
  3695. + ObjectSpace.garbage_collect
  3696. + ObjectSpace.garbage_collect
  3697. + break if weak = weaks.find {|w| !w.weakref_alive?}
  3698. + end
  3699. assert_raise(WeakRef::RefError) {weak.to_s}
  3700. assert_not_predicate(weak, :weakref_alive?)
  3701. end
  3702. diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
  3703. index 563b91e..2126500 100644
  3704. --- a/test/thread/test_queue.rb
  3705. +++ b/test/thread/test_queue.rb
  3706. @@ -55,6 +55,13 @@ class TestQueue < Test::Unit::TestCase
  3707. assert_equal(1, q.max)
  3708. assert_raise(ArgumentError) { q.max = -1 }
  3709. assert_equal(1, q.max)
  3710. +
  3711. + before = q.max
  3712. + q.max.times { q << 1 }
  3713. + t1 = Thread.new { q << 1 }
  3714. + sleep 0.01 until t1.stop?
  3715. + q.max = q.max + 1
  3716. + assert_equal before + 1, q.max
  3717. end
  3718. def test_queue_pop_interrupt
  3719. @@ -134,6 +141,29 @@ class TestQueue < Test::Unit::TestCase
  3720. assert_same q, retval
  3721. end
  3722. + def test_sized_queue_throttle
  3723. + q = SizedQueue.new(1)
  3724. + i = 0
  3725. + consumer = Thread.new do
  3726. + while q.pop
  3727. + i += 1
  3728. + Thread.pass
  3729. + end
  3730. + end
  3731. + nprod = 4
  3732. + npush = 100
  3733. +
  3734. + producer = nprod.times.map do
  3735. + Thread.new do
  3736. + npush.times { q.push(true) }
  3737. + end
  3738. + end
  3739. + producer.each(&:join)
  3740. + q.push(nil)
  3741. + consumer.join
  3742. + assert_equal(nprod * npush, i)
  3743. + end
  3744. +
  3745. def test_queue_thread_raise
  3746. q = Queue.new
  3747. th1 = Thread.new do
  3748. diff --git a/version.h b/version.h
  3749. index be88078..a3c4820 100644
  3750. --- a/version.h
  3751. +++ b/version.h
  3752. @@ -1,10 +1,10 @@
  3753. #define RUBY_VERSION "2.1.0"
  3754. -#define RUBY_RELEASE_DATE "2013-12-25"
  3755. -#define RUBY_PATCHLEVEL 0
  3756. +#define RUBY_RELEASE_DATE "2014-02-06"
  3757. +#define RUBY_PATCHLEVEL 27
  3758. -#define RUBY_RELEASE_YEAR 2013
  3759. -#define RUBY_RELEASE_MONTH 12
  3760. -#define RUBY_RELEASE_DAY 25
  3761. +#define RUBY_RELEASE_YEAR 2014
  3762. +#define RUBY_RELEASE_MONTH 2
  3763. +#define RUBY_RELEASE_DAY 6
  3764. #include "ruby/version.h"
  3765. diff --git a/vm_insnhelper.c b/vm_insnhelper.c
  3766. index 99b0c75..edf4e46 100644
  3767. --- a/vm_insnhelper.c
  3768. +++ b/vm_insnhelper.c
  3769. @@ -126,20 +126,22 @@ NORETURN(static void argument_error(const rb_iseq_t *iseq, int miss_argc, int mi
  3770. static void
  3771. argument_error(const rb_iseq_t *iseq, int miss_argc, int min_argc, int max_argc)
  3772. {
  3773. + rb_thread_t *th = GET_THREAD();
  3774. VALUE exc = rb_arg_error_new(miss_argc, min_argc, max_argc);
  3775. - VALUE bt = rb_make_backtrace();
  3776. - VALUE err_line = 0;
  3777. + VALUE at;
  3778. if (iseq) {
  3779. - int line_no = FIX2INT(rb_iseq_first_lineno(iseq->self));
  3780. -
  3781. - err_line = rb_sprintf("%s:%d:in `%s'",
  3782. - RSTRING_PTR(iseq->location.path),
  3783. - line_no, RSTRING_PTR(iseq->location.label));
  3784. - rb_funcall(bt, rb_intern("unshift"), 1, err_line);
  3785. + vm_push_frame(th, iseq, VM_FRAME_MAGIC_METHOD, Qnil /* self */, Qnil /* klass */, Qnil /* specval*/,
  3786. + iseq->iseq_encoded, th->cfp->sp, 0 /* local_size */, 0 /* me */, 0 /* stack_max */);
  3787. + at = rb_vm_backtrace_object();
  3788. + vm_pop_frame(th);
  3789. + }
  3790. + else {
  3791. + at = rb_vm_backtrace_object();
  3792. }
  3793. - rb_funcall(exc, rb_intern("set_backtrace"), 1, bt);
  3794. + rb_iv_set(exc, "bt_locations", at);
  3795. + rb_funcall(exc, rb_intern("set_backtrace"), 1, at);
  3796. rb_exc_raise(exc);
  3797. }
  3798. @@ -2002,7 +2004,8 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
  3799. current_defined_class = RCLASS_REFINED_CLASS(current_defined_class);
  3800. }
  3801. - if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
  3802. + if (BUILTIN_TYPE(current_defined_class) != T_MODULE &&
  3803. + !FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) &&
  3804. !rb_obj_is_kind_of(ci->recv, current_defined_class)) {
  3805. VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ?
  3806. RBASIC(current_defined_class)->klass : current_defined_class;
  3807. @@ -2022,6 +2025,12 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
  3808. " by define_method() is not supported."
  3809. " Specify all arguments explicitly.");
  3810. }
  3811. + if (!ci->klass) {
  3812. + /* bound instance method of module */
  3813. + ci->aux.missing_reason = NOEX_SUPER;
  3814. + CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
  3815. + return;
  3816. + }
  3817. /* TODO: use inline cache */
  3818. ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);
  3819. diff --git a/win32/Makefile.sub b/win32/Makefile.sub
  3820. index 305f37d..a04e802 100644
  3821. --- a/win32/Makefile.sub
  3822. +++ b/win32/Makefile.sub
  3823. @@ -1034,14 +1034,17 @@ $(RCFILES): $(RBCONFIG) $(srcdir)/revision.h $(srcdir)/win32/resource.rb
  3824. -so_name=$(RUBY_SO_NAME) \
  3825. . $(icondirs) $(win_srcdir)
  3826. -$(arch)-fake.rb: $(MKFILES)
  3827. +$(arch)-fake.rb: $(MKFILES) $(srcdir)/version.h
  3828. @echo Creating <<$@
  3829. class Object
  3830. + remove_const :CROSS_COMPILING if defined?(CROSS_COMPILING)
  3831. CROSS_COMPILING = RUBY_PLATFORM
  3832. remove_const :RUBY_PLATFORM
  3833. remove_const :RUBY_VERSION
  3834. + remove_const :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
  3835. RUBY_PLATFORM = "$(arch)"
  3836. - RUBY_VERSION = "$(MAJOR).$(MINOR).$(TEENY)"
  3837. + RUBY_VERSION = $(RUBY_PROGRAM_VERSION)
  3838. + RUBY_DESCRIPTION = "ruby #{RUBY_VERSION} (" + $(RUBY_PROGRAM_RELEASE_DATE) + ") [#{RUBY_PLATFORM}]"
  3839. end
  3840. class File
  3841. remove_const :ALT_SEPARATOR
  3842. diff --git a/win32/setup.mak b/win32/setup.mak
  3843. index 458212b..b6358e5 100644
  3844. --- a/win32/setup.mak
  3845. +++ b/win32/setup.mak
  3846. @@ -117,6 +117,8 @@ int main(void) {return (EnumProcesses(NULL,0,NULL) ? 0 : 1);}
  3847. MAJOR = RUBY_API_VERSION_MAJOR
  3848. MINOR = RUBY_API_VERSION_MINOR
  3849. TEENY = RUBY_API_VERSION_TEENY
  3850. +RUBY_PROGRAM_VERSION = RUBY_VERSION
  3851. +RUBY_PROGRAM_RELEASE_DATE = RUBY_RELEASE_DATE
  3852. MSC_VER = _MSC_VER
  3853. <<
  3854. diff --git a/win32/win32.c b/win32/win32.c
  3855. index 9cbd07f..2c888ae 100644
  3856. --- a/win32/win32.c
  3857. +++ b/win32/win32.c
  3858. @@ -6965,7 +6965,7 @@ rb_w32_fd_is_text(int fd)
  3859. return _osfile(fd) & FTEXT;
  3860. }
  3861. -#if RUBY_MSVCRT_VERSION < 80 && !defined(__MINGW64__)
  3862. +#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__GMTIME64_S)
  3863. /* License: Ruby's */
  3864. static int
  3865. unixtime_to_systemtime(const time_t t, SYSTEMTIME *st)
  3866. @@ -7027,7 +7027,11 @@ systemtime_to_localtime(TIME_ZONE_INFORMATION *tz, SYSTEMTIME *gst, SYSTEMTIME *
  3867. }
  3868. #endif
  3869. -#ifdef __MINGW64__
  3870. +#ifdef HAVE__GMTIME64_S
  3871. +# ifndef HAVE__LOCALTIME64_S
  3872. +/* assume same as _gmtime64_s() */
  3873. +# define HAVE__LOCALTIME64_S 1
  3874. +# endif
  3875. # ifndef MINGW_HAS_SECURE_API
  3876. _CRTIMP errno_t __cdecl _gmtime64_s(struct tm* tm, const __time64_t *time);
  3877. _CRTIMP errno_t __cdecl _localtime64_s(struct tm* tm, const __time64_t *time);
  3878. @@ -7046,7 +7050,7 @@ gmtime_r(const time_t *tp, struct tm *rp)
  3879. errno = e;
  3880. return NULL;
  3881. }
  3882. -#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__)
  3883. +#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__GMTIME64_S)
  3884. e = gmtime_s(rp, tp);
  3885. if (e != 0) goto error;
  3886. #else
  3887. @@ -7070,7 +7074,7 @@ localtime_r(const time_t *tp, struct tm *rp)
  3888. errno = e;
  3889. return NULL;
  3890. }
  3891. -#if RUBY_MSVCRT_VERSION >= 80 || defined(__MINGW64__)
  3892. +#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__LOCALTIME64_S)
  3893. e = localtime_s(rp, tp);
  3894. if (e) goto error;
  3895. #else