Control: tags 1019638 + patch
Control: tags 1019638 + pending

Dear maintainer,

I've prepared an NMU for ruby-memory-profiler (versioned as 0.9.14-4.1) 
and uploaded it to DELAYED/15. Please feel free to tell me if I should 
cancel it.

cu
Adrian
diff -Nru ruby-memory-profiler-0.9.14/debian/changelog ruby-memory-profiler-0.9.14/debian/changelog
--- ruby-memory-profiler-0.9.14/debian/changelog	2021-11-08 01:42:01.000000000 +0200
+++ ruby-memory-profiler-0.9.14/debian/changelog	2022-11-20 02:14:54.000000000 +0200
@@ -1,3 +1,10 @@
+ruby-memory-profiler (0.9.14-4.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Add upstream fixes for Ruby 3.1. (Closes: #1019638)
+
+ -- Adrian Bunk <b...@debian.org>  Sun, 20 Nov 2022 02:14:54 +0200
+
 ruby-memory-profiler (0.9.14-4) unstable; urgency=low
 
   * Team upload.
diff -Nru ruby-memory-profiler-0.9.14/debian/patches/0001-Fix-normalize_path-and-guess_gem-to-support-Ruby-3.patch ruby-memory-profiler-0.9.14/debian/patches/0001-Fix-normalize_path-and-guess_gem-to-support-Ruby-3.patch
--- ruby-memory-profiler-0.9.14/debian/patches/0001-Fix-normalize_path-and-guess_gem-to-support-Ruby-3.patch	1970-01-01 02:00:00.000000000 +0200
+++ ruby-memory-profiler-0.9.14/debian/patches/0001-Fix-normalize_path-and-guess_gem-to-support-Ruby-3.patch	2022-11-20 02:14:02.000000000 +0200
@@ -0,0 +1,39 @@
+From dcc4464d1766046712a406b32651a00a64d7e592 Mon Sep 17 00:00:00 2001
+From: Benoit Daloze <erego...@gmail.com>
+Date: Tue, 25 Oct 2022 15:06:10 +0200
+Subject: Fix normalize_path and guess_gem to support Ruby 3+
+
+---
+ lib/memory_profiler/helpers.rb | 2 +-
+ lib/memory_profiler/results.rb | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/memory_profiler/helpers.rb b/lib/memory_profiler/helpers.rb
+index d894ffa..c008cd1 100644
+--- a/lib/memory_profiler/helpers.rb
++++ b/lib/memory_profiler/helpers.rb
+@@ -16,7 +16,7 @@ module MemoryProfiler
+           gemname
+         elsif /\/rubygems[\.\/]/ =~ path
+           "rubygems"
+-        elsif /ruby\/2\.[^\/]+\/(?<stdlib>[^\/\.]+)/ =~ path
++        elsif /ruby\/\d\.[^\/]+\/(?<stdlib>[^\/\.]+)/ =~ path
+           stdlib
+         elsif /(?<app>[^\/]+\/(bin|app|lib))/ =~ path
+           app
+diff --git a/lib/memory_profiler/results.rb b/lib/memory_profiler/results.rb
+index 5630977..d6fad8d 100644
+--- a/lib/memory_profiler/results.rb
++++ b/lib/memory_profiler/results.rb
+@@ -172,7 +172,7 @@ module MemoryProfiler
+       @normalize_path[path] ||= begin
+         if %r!(/gems/.*)*/gems/(?<gemname>[^/]+)(?<rest>.*)! =~ path
+           "#{gemname}#{rest}"
+-        elsif %r!ruby/2\.[^/]+/(?<stdlib>[^/.]+)(?<rest>.*)! =~ path
++        elsif %r!ruby/\d\.[^/]+/(?<stdlib>[^/.]+)(?<rest>.*)! =~ path
+           "ruby/lib/#{stdlib}#{rest}"
+         elsif %r!(?<app>[^/]+/(bin|app|lib))(?<rest>.*)! =~ path
+           "#{app}#{rest}"
+-- 
+2.30.2
+
diff -Nru ruby-memory-profiler-0.9.14/debian/patches/0002-Adapt-tests-for-Ruby-3.0.patch ruby-memory-profiler-0.9.14/debian/patches/0002-Adapt-tests-for-Ruby-3.0.patch
--- ruby-memory-profiler-0.9.14/debian/patches/0002-Adapt-tests-for-Ruby-3.0.patch	1970-01-01 02:00:00.000000000 +0200
+++ ruby-memory-profiler-0.9.14/debian/patches/0002-Adapt-tests-for-Ruby-3.0.patch	2022-11-20 02:14:02.000000000 +0200
@@ -0,0 +1,51 @@
+From 499480ce9820f7df21a4e7ca30c1bbd78564be2e Mon Sep 17 00:00:00 2001
+From: Benoit Daloze <erego...@gmail.com>
+Date: Tue, 25 Oct 2022 15:18:49 +0200
+Subject: Adapt tests for Ruby 3.0
+
+---
+ test/test_reporter.rb | 19 +++++++++++++++----
+ 1 file changed, 15 insertions(+), 4 deletions(-)
+
+diff --git a/test/test_reporter.rb b/test/test_reporter.rb
+index 55c440f..c10efd6 100644
+--- a/test/test_reporter.rb
++++ b/test/test_reporter.rb
+@@ -232,7 +232,15 @@ class TestReporter < Minitest::Test
+       end
+     end
+ 
+-    assert_equal(45, results.total_allocated, "45 strings should be allocated")
++    if RUBY_VERSION < '3'
++      # 3 times "0", 2 times for interpolated strings
++      total_allocated = 5 * (3 + 2 + 2 + 2)
++    else
++      # 3 times "0", 2 times for short interpolated strings, 3 times for long interpolated strings
++      total_allocated = 5 * (3 + 2 + 3 + 3)
++    end
++
++    assert_equal(total_allocated, results.total_allocated, "#{total_allocated} strings should be allocated")
+     assert_equal(20, results.strings_allocated.size, "20 unique strings should be observed")
+     assert_equal(0, results.strings_retained.size, "0 unique strings should be retained")
+   end
+@@ -244,11 +252,14 @@ class TestReporter < Minitest::Test
+       string.to_sym
+     end
+ 
+-    assert_equal(3, results.total_allocated)
+-    assert_equal(0, results.total_retained)
++    strings_allocated = RUBY_VERSION < '3' ? 2 : 1
++    assert_equal(strings_allocated + 1, results.total_allocated)
++    assert_includes(0..1, results.total_retained)
+     assert_equal(1, results.strings_allocated.size)
++
+     assert_equal('String', results.allocated_objects_by_class[0][:data])
+-    assert_equal(2, results.allocated_objects_by_class[0][:count])
++    assert_equal(strings_allocated, results.allocated_objects_by_class[0][:count])
++
+     assert_equal('Symbol', results.allocated_objects_by_class[1][:data])
+     assert_equal(1, results.allocated_objects_by_class[1][:count])
+   end
+-- 
+2.30.2
+
diff -Nru ruby-memory-profiler-0.9.14/debian/patches/0003-Adapt-tests-for-Ruby-3.1.patch ruby-memory-profiler-0.9.14/debian/patches/0003-Adapt-tests-for-Ruby-3.1.patch
--- ruby-memory-profiler-0.9.14/debian/patches/0003-Adapt-tests-for-Ruby-3.1.patch	1970-01-01 02:00:00.000000000 +0200
+++ ruby-memory-profiler-0.9.14/debian/patches/0003-Adapt-tests-for-Ruby-3.1.patch	2022-11-20 02:14:02.000000000 +0200
@@ -0,0 +1,38 @@
+From 8aa50fba9b6f3d01fe8ce4cd98bc307bc2214ef3 Mon Sep 17 00:00:00 2001
+From: Benoit Daloze <erego...@gmail.com>
+Date: Tue, 25 Oct 2022 16:20:58 +0200
+Subject: Adapt tests for Ruby 3.1
+
+---
+ test/test_reporter.rb | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/test/test_reporter.rb b/test/test_reporter.rb
+index c10efd6..e33c24a 100644
+--- a/test/test_reporter.rb
++++ b/test/test_reporter.rb
+@@ -235,13 +235,19 @@ class TestReporter < Minitest::Test
+     if RUBY_VERSION < '3'
+       # 3 times "0", 2 times for interpolated strings
+       total_allocated = 5 * (3 + 2 + 2 + 2)
+-    else
++      unique = 20
++    elsif RUBY_VERSION < '3.1'
+       # 3 times "0", 2 times for short interpolated strings, 3 times for long interpolated strings
+       total_allocated = 5 * (3 + 2 + 3 + 3)
++      unique = 20
++    else
++      # 2 times for short interpolated strings, 3 times for long interpolated strings
++      total_allocated = 5 * (2 + 3 + 3)
++      unique = 15
+     end
+ 
+     assert_equal(total_allocated, results.total_allocated, "#{total_allocated} strings should be allocated")
+-    assert_equal(20, results.strings_allocated.size, "20 unique strings should be observed")
++    assert_equal(unique, results.strings_allocated.size, "#{unique} unique strings should be observed")
+     assert_equal(0, results.strings_retained.size, "0 unique strings should be retained")
+   end
+ 
+-- 
+2.30.2
+
diff -Nru ruby-memory-profiler-0.9.14/debian/patches/996317-skip-ruby2-tests-on-ruby3.patch ruby-memory-profiler-0.9.14/debian/patches/996317-skip-ruby2-tests-on-ruby3.patch
--- ruby-memory-profiler-0.9.14/debian/patches/996317-skip-ruby2-tests-on-ruby3.patch	2021-11-08 01:42:01.000000000 +0200
+++ ruby-memory-profiler-0.9.14/debian/patches/996317-skip-ruby2-tests-on-ruby3.patch	1970-01-01 02:00:00.000000000 +0200
@@ -1,35 +0,0 @@
-From: Daniel Leidert <dleid...@debian.org>
-Date: Sun, 7 Nov 2021 23:17:47 +0100
-Subject: Skip Ruby 2 tests in Ruby 3
-
-Bug-Debian: https://bugs.debian.org/996317
----
- test/test_reporter.rb | 2 +-
- test/test_results.rb  | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/test/test_reporter.rb b/test/test_reporter.rb
-index f2a150c..01eec92 100644
---- a/test/test_reporter.rb
-+++ b/test/test_reporter.rb
-@@ -232,7 +232,7 @@ class TestReporter < Minitest::Test
-       end
-     end
- 
--    assert_equal(45, results.total_allocated, "45 strings should be allocated")
-+    assert_includes([45, 55], results.total_allocated, "45 strings should be allocated")
-     assert_equal(20, results.strings_allocated.size, "20 unique strings should be observed")
-     assert_equal(0, results.strings_retained.size, "0 unique strings should be retained")
-   end
-diff --git a/test/test_results.rb b/test/test_results.rb
-index 0174b7f..e22a10b 100644
---- a/test/test_results.rb
-+++ b/test/test_results.rb
-@@ -80,6 +80,6 @@ class TestResults < Minitest::Test
-     io = StringIO.new
-     report.pretty_print(io, normalize_paths: true)
-     assert_match(%r!\d+\s{2}longhorn-0.1.0/lib/longhorn.rb:\d+!, io.string)
--    assert_match(%r!ruby/lib/set.rb!, io.string)
-+    assert_match(%r!ruby/lib/set.rb!, io.string) if RUBY_VERSION < '3'
-   end
- end
diff -Nru ruby-memory-profiler-0.9.14/debian/patches/series ruby-memory-profiler-0.9.14/debian/patches/series
--- ruby-memory-profiler-0.9.14/debian/patches/series	2021-11-08 01:42:01.000000000 +0200
+++ ruby-memory-profiler-0.9.14/debian/patches/series	2022-11-20 02:14:52.000000000 +0200
@@ -1,2 +1,4 @@
 skip-failures-for-arm64.patch
-996317-skip-ruby2-tests-on-ruby3.patch
+0001-Fix-normalize_path-and-guess_gem-to-support-Ruby-3.patch
+0002-Adapt-tests-for-Ruby-3.0.patch
+0003-Adapt-tests-for-Ruby-3.1.patch

Reply via email to