Hello community,
here is the log from the commit of package rubygem-thread_safe for
openSUSE:Factory checked in at 2014-10-15 16:20:15
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-thread_safe (Old)
and /work/SRC/openSUSE:Factory/.rubygem-thread_safe.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-thread_safe"
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-thread_safe/rubygem-thread_safe.changes
2014-10-14 07:13:16.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-thread_safe.new/rubygem-thread_safe.changes
2014-10-15 16:21:47.000000000 +0200
@@ -1,0 +2,5 @@
+Wed Oct 15 09:26:16 UTC 2014 - [email protected]
+
+- updated to version 0.3.4, no changelog
+
+-------------------------------------------------------------------
Old:
----
thread_safe-0.3.3.gem
New:
----
gem2rpm.yml
thread_safe-0.3.4.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-thread_safe.spec ++++++
--- /var/tmp/diff_new_pack.IxLn6B/_old 2014-10-15 16:21:49.000000000 +0200
+++ /var/tmp/diff_new_pack.IxLn6B/_new 2014-10-15 16:21:49.000000000 +0200
@@ -16,22 +16,31 @@
#
+#
+# This file was generated with a gem2rpm.yml and not just plain gem2rpm.
+# All sections marked as MANUAL, license headers, summaries and descriptions
+# can be maintained in that file. Please consult this file before editing any
+# of those fields
+#
+
Name: rubygem-thread_safe
-Version: 0.3.3
+Version: 0.3.4
Release: 0
%define mod_name thread_safe
%define mod_full_name %{mod_name}-%{version}
-
BuildRoot: %{_tmppath}/%{name}-%{version}-build
+BuildRequires: %{rubygem gem2rpm}
+BuildRequires: %{ruby}
BuildRequires: ruby-macros >= 5
Url: https://github.com/headius/thread_safe
Source: http://rubygems.org/gems/%{mod_full_name}.gem
+Source1: gem2rpm.yml
Summary: A collection of data structures and utilities to make
thread-safe
License: Apache-2.0
Group: Development/Languages/Ruby
%description
-Thread-safe collections and utilities for Ruby
+Thread-safe collections and utilities for Ruby.
%prep
@@ -39,7 +48,6 @@
%install
%gem_install \
- --symlink-binaries \
--doc-files="LICENSE README.md" \
-f
++++++ gem2rpm.yml ++++++
# ---
# ## used by gem2rpm
# :summary: this is a custom summary
# ## used by gem2rpm
# :description: |-
# this is a custom description
#
# it can be multiline
# ## used by gem2rpm
# :license: MIT or Ruby
# ## used by gem2rpm and gem_packages
# :version_suffix: -x_y
# ## used by gem2rpm and gem_packages
# :disable_docs: true
# ## used by gem2rpm
# :disable_automatic_rdoc_dep: true
# ## used by gem2rpm
# :preamble: |-
# BuildRequires: foobar
# Requires: foobar
# ## used by gem2rpm
# :patches:
# foo.patch: -p1
# bar.patch:
# ## used by gem2rpm
:sources:
# - foo.desktop
# - bar.desktop
# :gem_install_args: '....'
# ## used by gem2rpm
# :pre_install: |-
# %if 0%{?use_system_libev}
# export USE_VENDORED_LIBEV="no"
# %endif
# ## used by gem2rpm
# :post_install: |-
# # delete custom files here or do other fancy stuff
# install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse
# ## used by gem2rpm
# :testsuite_command: |-
# (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test)
# ## used by gem2rpm
# :filelist: |-
# /usr/bin/gem2rpm-opensuse
# ## used by gem2rpm
# :scripts:
# :post: |-
# /bin/echo foo
# ## used by gem_packages
# :main:
# :preamble: |-
# Requires: util-linux
# Recommends: pwgen
# :filelist: |-
# /usr/bin/gem2rpm-opensuse
# ## used by gem_packages
# :custom:
# apache:
# :preamble: |-
# Requires: .....
# :filelist: |-
# /etc/apache2/conf.d/passenger.conf
# :summary: Custom summary is optional
# :description: |-
# Custom description is optional
#
# bar
# :post: |-
# /bin/echo foo
#
++++++ thread_safe-0.3.3.gem -> thread_safe-0.3.4.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.gitignore new/.gitignore
--- old/.gitignore 1970-01-01 01:00:00.000000000 +0100
+++ new/.gitignore 1970-01-01 01:00:00.000000000 +0100
@@ -1,22 +0,0 @@
-*.gem
-*.rbc
-.rbx/*
-.bundle
-.config
-.yardoc
-Gemfile.lock
-InstalledFiles
-_yardoc
-coverage
-doc/
-lib/bundler/man
-lib/thread_safe/jruby_cache_backend.jar
-pkg
-rdoc
-spec/reports
-test/tmp
-test/version_tmp
-tmp
-.DS_Store
-*.swp
-test/package.jar
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/thread_safe/cache.rb new/lib/thread_safe/cache.rb
--- old/lib/thread_safe/cache.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/thread_safe/cache.rb 1970-01-01 01:00:00.000000000 +0100
@@ -35,9 +35,13 @@
end
def [](key)
- if value = super
+ if value = super # non-falsy value is an existing mapping, return it
right away
value
- elsif @default_proc && !key?(key)
+ # re-check is done with get_or_default(key, NULL) instead of a simple
!key?(key) in order to avoid a race condition, whereby by the time the current
thread gets to the key?(key) call
+ # a key => value mapping might have already been created by a different
thread (key?(key) would then return true, this elsif branch wouldn't be taken
and an incorrent +nil+ value
+ # would be returned)
+ # note: nil == value check is not technically necessary
+ elsif @default_proc && nil == value && NULL == (value =
get_or_default(key, NULL))
@default_proc.call(self, key)
else
value
@@ -55,7 +59,13 @@
elsif NULL != default_value
default_value
else
- raise KEY_ERROR, 'key not found'
+ raise_fetch_no_key
+ end
+ end
+
+ def fetch_or_store(key, default_value = NULL)
+ fetch(key) do
+ put(key, block_given? ? yield(key) : (NULL == default_value ?
raise_fetch_no_key : default_value))
end
end
@@ -127,6 +137,10 @@
undef :freeze
private
+ def raise_fetch_no_key
+ raise KEY_ERROR, 'key not found'
+ end
+
def initialize_copy(other)
super
populate_from(other)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/thread_safe/version.rb
new/lib/thread_safe/version.rb
--- old/lib/thread_safe/version.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/thread_safe/version.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +1,5 @@
module ThreadSafe
- VERSION = "0.3.3"
+ VERSION = "0.3.4"
end
# NOTE: <= 0.2.0 used Threadsafe::VERSION
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 1970-01-01 01:00:00.000000000 +0100
+++ new/metadata 1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: thread_safe
version: !ruby/object:Gem::Version
- version: 0.3.3
+ version: 0.3.4
platform: ruby
authors:
- Charles Oliver Nutter
@@ -9,7 +9,7 @@
autorequire:
bindir: bin
cert_chain: []
-date: 2014-04-07 00:00:00.000000000 Z
+date: 2014-05-27 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: atomic
@@ -45,6 +45,20 @@
- - '>='
- !ruby/object:Gem::Version
version: '0'
+- !ruby/object:Gem::Dependency
+ name: minitest
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '4'
+ type: :development
+ prerelease: false
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '4'
description: Thread-safe collections and utilities for Ruby
email:
- [email protected]
@@ -53,7 +67,6 @@
extensions: []
extra_rdoc_files: []
files:
-- .gitignore
- .travis.yml
- Gemfile
- LICENSE
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_array.rb new/test/test_array.rb
--- old/test/test_array.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_array.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +1,18 @@
-require 'test/unit'
require 'thread_safe'
+require File.join(File.dirname(__FILE__), "test_helper")
-class TestArray < Test::Unit::TestCase
+class TestArray < Minitest::Test
def test_concurrency
ary = ThreadSafe::Array.new
- assert_nothing_raised do
- (1..100).map do |i|
- Thread.new do
- 1000.times do
- ary << i
- ary.each {|x| x * 2}
- ary.shift
- ary.last
- end
+ (1..100).map do |i|
+ Thread.new do
+ 1000.times do
+ ary << i
+ ary.each {|x| x * 2}
+ ary.shift
+ ary.last
end
- end.map(&:join)
- end
+ end
+ end.map(&:join)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_cache.rb new/test/test_cache.rb
--- old/test/test_cache.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_cache.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,29 +1,26 @@
-require 'test/unit'
require 'thread_safe'
require 'thread'
require File.join(File.dirname(__FILE__), "test_helper")
Thread.abort_on_exception = true
-class TestCache < Test::Unit::TestCase
+class TestCache < Minitest::Test
def setup
@cache = ThreadSafe::Cache.new
end
def test_concurrency
cache = @cache
- assert_nothing_raised do
- (1..100).map do |i|
- Thread.new do
- 1000.times do |j|
- key = i*1000+j
- cache[key] = i
- cache[key]
- cache.delete(key)
- end
+ (1..100).map do |i|
+ Thread.new do
+ 1000.times do |j|
+ key = i*1000+j
+ cache[key] = i
+ cache[key]
+ cache.delete(key)
end
- end.map(&:join)
- end
+ end
+ end.map(&:join)
end
def test_retrieval
@@ -470,9 +467,14 @@
assert_equal(1, (@cache.fetch(:a) {flunk}))
end
- assert_raise(ThreadSafe::Cache::KEY_ERROR) do
+ assert_raises(ThreadSafe::Cache::KEY_ERROR) do
@cache.fetch(:b)
end
+
+ assert_no_size_change do
+ assert_equal 1, (@cache.fetch(:b, :c) {1}) # assert block
supersedes default value argument
+ assert_equal false, @cache.key?(:b)
+ end
end
end
@@ -508,6 +510,86 @@
end
end
+ def test_fetch_or_store
+ with_or_without_default_proc do |default_proc_set|
+ assert_size_change 1 do
+ assert_equal 1, @cache.fetch_or_store(:a, 1)
+ assert_equal 1, @cache[:a]
+ end
+
+ @cache.delete(:a)
+
+ assert_size_change 1 do
+ assert_equal 1, (@cache.fetch_or_store(:a) {1})
+ assert_equal 1, @cache[:a]
+ end
+
+ assert_no_size_change do
+ assert_equal(1, (@cache.fetch_or_store(:a) {flunk}))
+ end
+
+ assert_raises(ThreadSafe::Cache::KEY_ERROR) do
+ @cache.fetch_or_store(:b)
+ end
+
+ assert_size_change 1 do
+ assert_equal 1, (@cache.fetch_or_store(:b, :c) {1}) # assert block
supersedes default value argument
+ assert_equal 1, @cache[:b]
+ end
+ end
+ end
+
+ def test_falsy_fetch_or_store
+ with_or_without_default_proc do
+ assert_equal false, @cache.key?(:a)
+
+ assert_size_change 1 do
+ assert_equal(nil, @cache.fetch_or_store(:a, nil))
+ assert_equal nil, @cache[:a]
+ assert_equal true, @cache.key?(:a)
+ end
+ @cache.delete(:a)
+
+ assert_size_change 1 do
+ assert_equal(false, @cache.fetch_or_store(:a, false))
+ assert_equal false, @cache[:a]
+ assert_equal true, @cache.key?(:a)
+ end
+ @cache.delete(:a)
+
+ assert_size_change 1 do
+ assert_equal(nil, (@cache.fetch_or_store(:a) {}))
+ assert_equal nil, @cache[:a]
+ assert_equal true, @cache.key?(:a)
+ end
+ @cache.delete(:a)
+
+ assert_size_change 1 do
+ assert_equal(false, (@cache.fetch_or_store(:a) {false}))
+ assert_equal false, @cache[:a]
+ assert_equal true, @cache.key?(:a)
+ end
+
+ @cache[:a] = nil
+ assert_no_size_change do
+ assert_equal(nil, (@cache.fetch_or_store(:a) {flunk}))
+ end
+ end
+ end
+
+ def test_fetch_or_store_with_return
+ with_or_without_default_proc do
+ r = lambda do
+ @cache.fetch_or_store(:a) { return 10 }
+ end.call
+
+ assert_no_size_change do
+ assert_equal 10, r
+ assert_equal false, @cache.key?(:a)
+ end
+ end
+ end
+
def test_clear
@cache[:a] = 1
assert_size_change -1 do
@@ -554,11 +636,9 @@
@cache[:b] = 1
@cache[:c] = 1
- assert_nothing_raised do
- assert_size_change 1 do
- @cache.each_pair do |k, v|
- @cache[:z] = 1
- end
+ assert_size_change 1 do
+ @cache.each_pair do |k, v|
+ @cache[:z] = 1
end
end
end
@@ -704,14 +784,13 @@
end
def test_is_unfreezable
- assert_raise(NoMethodError) { @cache.freeze }
+ assert_raises(NoMethodError) { @cache.freeze }
end
def test_marshal_dump_load
- assert_nothing_raised do
- new_cache = Marshal.load(Marshal.dump(@cache))
- assert_equal 0, new_cache.size
- end
+ new_cache = Marshal.load(Marshal.dump(@cache))
+ assert_instance_of ThreadSafe::Cache, new_cache
+ assert_equal 0, new_cache.size
@cache[:a] = 1
new_cache = Marshal.load(Marshal.dump(@cache))
assert_equal 1, @cache[:a]
@@ -719,7 +798,7 @@
end
def test_marshal_dump_doesnt_work_with_default_proc
- assert_raise(TypeError) do
+ assert_raises(TypeError) do
Marshal.dump(ThreadSafe::Cache.new {})
end
end
@@ -740,7 +819,8 @@
end
def assert_valid_options(options)
- assert_nothing_raised { ThreadSafe::Cache.new(options) }
+ c = ThreadSafe::Cache.new(options)
+ assert_instance_of ThreadSafe::Cache, c
end
def assert_invalid_option(option_name, value)
@@ -748,7 +828,7 @@
end
def assert_invalid_options(options)
- assert_raise(ArgumentError) { ThreadSafe::Cache.new(options) }
+ assert_raises(ArgumentError) { ThreadSafe::Cache.new(options) }
end
def assert_size_change(change, cache = @cache)
@@ -782,7 +862,7 @@
before_had_value = before_had_key ? @cache[key] : nil
assert_no_size_change do
- assert_raise(TestException) do
+ assert_raises(TestException) do
@cache.send(method, key, *args) { raise TestException, '' }
end
assert_equal before_had_key, @cache.key?(key)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_cache_loops.rb new/test/test_cache_loops.rb
--- old/test/test_cache_loops.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_cache_loops.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +1,10 @@
require 'thread'
-require 'test/unit'
require 'thread_safe'
require File.join(File.dirname(__FILE__), "test_helper")
Thread.abort_on_exception = true
-class TestCacheTorture < Test::Unit::TestCase # this is not run unless
RUBY_VERSION =~ /1\.8/ || ENV['TRAVIS'] (see the end of the file)
+class TestCacheTorture < Minitest::Test # this is not run unless RUBY_VERSION
=~ /1\.8/ || ENV['TRAVIS'] (see the end of the file)
THREAD_COUNT = 40
KEY_COUNT = (((2**13) - 2) * 0.75).to_i # get close to the doubling cliff
LOW_KEY_COUNT = (((2**8 ) - 2) * 0.75).to_i # get close to the doubling cliff
@@ -310,15 +309,13 @@
def do_thread_loop(name, code, options = {}, &block)
options = DEFAULTS.merge(options)
meth = define_loop name, code, options[:prelude]
- assert_nothing_raised do
- keys = to_keys_array(options[:key_count])
- run_thread_loop(meth, keys, options, &block)
-
- if options[:key_count] > 1
- options[:key_count] = (options[:key_count] / 40).to_i
- keys = to_hash_collision_keys_array(options[:key_count])
- run_thread_loop(meth, keys, options.merge(:loop_count =>
(options[:loop_count] * 5)), &block)
- end
+ keys = to_keys_array(options[:key_count])
+ run_thread_loop(meth, keys, options, &block)
+
+ if options[:key_count] > 1
+ options[:key_count] = (options[:key_count] / 40).to_i
+ keys = to_hash_collision_keys_array(options[:key_count])
+ run_thread_loop(meth, keys, options.merge(:loop_count =>
(options[:loop_count] * 5)), &block)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_hash.rb new/test/test_hash.rb
--- old/test/test_hash.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_hash.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +1,17 @@
-require 'test/unit'
require 'thread_safe'
+require File.join(File.dirname(__FILE__), "test_helper")
-class TestHash < Test::Unit::TestCase
+class TestHash < Minitest::Test
def test_concurrency
hsh = ThreadSafe::Hash.new
- assert_nothing_raised do
- (1..100).map do |i|
- Thread.new do
- 1000.times do |j|
- hsh[i*1000+j] = i
- hsh[i*1000+j]
- hsh.delete(i*1000+j)
- end
+ (1..100).map do |i|
+ Thread.new do
+ 1000.times do |j|
+ hsh[i*1000+j] = i
+ hsh[i*1000+j]
+ hsh.delete(i*1000+j)
end
- end.map(&:join)
- end
+ end
+ end.map(&:join)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_helper.rb new/test/test_helper.rb
--- old/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +1,14 @@
require 'thread'
+require 'rubygems'
+gem 'minitest', '>= 4'
+require 'minitest/autorun'
+
+if Minitest.const_defined?('Test')
+ # We're on Minitest 5+. Nothing to do here.
+else
+ # Minitest 4 doesn't have Minitest::Test yet.
+ Minitest::Test = MiniTest::Unit::TestCase
+end
if defined?(JRUBY_VERSION) && ENV['TEST_NO_UNSAFE']
# to be used like this: rake test TEST_NO_UNSAFE=true
@@ -10,7 +20,7 @@
manager.deny java.lang.RuntimePermission.new("accessClassInPackage.sun.misc")
java.lang.System.setSecurityManager manager
- class TestNoUnsafe < Test::Unit::TestCase
+ class TestNoUnsafe < Minitest::Test
def test_security_manager_is_used
begin
java_import 'sun.misc.Unsafe'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_synchronized_delegator.rb
new/test/test_synchronized_delegator.rb
--- old/test/test_synchronized_delegator.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/test/test_synchronized_delegator.rb 1970-01-01 01:00:00.000000000
+0100
@@ -1,7 +1,7 @@
-require 'test/unit'
require 'thread_safe/synchronized_delegator.rb'
+require File.join(File.dirname(__FILE__), "test_helper")
-class TestSynchronizedDelegator < Test::Unit::TestCase
+class TestSynchronizedDelegator < Minitest::Test
def test_wraps_array
sync_array = SynchronizedDelegator.new(array = [])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/thread_safe.gemspec new/thread_safe.gemspec
--- old/thread_safe.gemspec 1970-01-01 01:00:00.000000000 +0100
+++ new/thread_safe.gemspec 1970-01-01 01:00:00.000000000 +0100
@@ -11,6 +11,7 @@
gem.files = `git ls-files`.split($\)
gem.files += ['lib/thread_safe/jruby_cache_backend.jar'] if
defined?(JRUBY_VERSION)
+ gem.files -= ['.gitignore'] # see
https://github.com/headius/thread_safe/issues/40#issuecomment-42315441
gem.platform = 'java' if defined?(JRUBY_VERSION)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -21,4 +22,5 @@
gem.add_development_dependency 'atomic', ['>= 1.1.7', '< 2']
gem.add_development_dependency 'rake'
+ gem.add_development_dependency 'minitest', '>= 4'
end
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]