Fix Ruby minitest support (RHBZ#2229653)

This commit is contained in:
Richard W.M. Jones 2023-08-07 10:51:55 +01:00
parent 22a5e52508
commit 355dd7fcfc
4 changed files with 353 additions and 1 deletions

View File

@ -0,0 +1,102 @@
From fbcff7fbd8f96214c7f13f36bd7669a9142824ab Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 7 Aug 2023 10:21:54 +0100
Subject: [PATCH 1/3] ruby: Replace MiniTest with Minitest
Apparently the old MiniTest module is somewhat ancient. Use "new"
Minitest module instead. This was broken by the following change in
minitest 5.19:
https://github.com/minitest/minitest/commit/a2c6c18570f6f0a1bf6af70fe3b6d9599a13fdd6
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2229653
---
ruby/tests/tc_010_load.rb | 2 +-
ruby/tests/tc_021_close.rb | 2 +-
ruby/tests/tc_120_rlenvalue.rb | 2 +-
ruby/tests/tc_130_special.rb | 2 +-
ruby/tests/tc_200_write.rb | 2 +-
ruby/tests/tc_210_setvalue.rb | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ruby/tests/tc_010_load.rb b/ruby/tests/tc_010_load.rb
index 76fef60..58fac33 100644
--- a/ruby/tests/tc_010_load.rb
+++ b/ruby/tests/tc_010_load.rb
@@ -17,7 +17,7 @@
require File::join(File::dirname(__FILE__), 'test_helper')
-class TestLoad < MiniTest::Unit::TestCase
+class TestLoad < Minitest::Test
def test_load
h = Hivex::open("../images/minimal", {})
refute_nil (h)
diff --git a/ruby/tests/tc_021_close.rb b/ruby/tests/tc_021_close.rb
index 38b88a9..bc8f79d 100644
--- a/ruby/tests/tc_021_close.rb
+++ b/ruby/tests/tc_021_close.rb
@@ -17,7 +17,7 @@
require File::join(File::dirname(__FILE__), 'test_helper')
-class TestClose < MiniTest::Unit::TestCase
+class TestClose < Minitest::Test
def test_close
h = Hivex::open("../images/minimal", {})
refute_nil (h)
diff --git a/ruby/tests/tc_120_rlenvalue.rb b/ruby/tests/tc_120_rlenvalue.rb
index 6a2fb72..ee881bb 100644
--- a/ruby/tests/tc_120_rlenvalue.rb
+++ b/ruby/tests/tc_120_rlenvalue.rb
@@ -23,7 +23,7 @@
require File::join(File::dirname(__FILE__), 'test_helper')
-class TestRLenValue < MiniTest::Unit::TestCase
+class TestRLenValue < Minitest::Test
def test_RLenValue
h = Hivex::open(File::join(ENV['abs_srcdir'], '..', 'images', 'rlenvalue_test_hive'), {})
refute_nil(h)
diff --git a/ruby/tests/tc_130_special.rb b/ruby/tests/tc_130_special.rb
index 7570824..6179f51 100644
--- a/ruby/tests/tc_130_special.rb
+++ b/ruby/tests/tc_130_special.rb
@@ -3,7 +3,7 @@
require File::join(File::dirname(__FILE__), 'test_helper')
-class TestRLenValue < MiniTest::Unit::TestCase
+class TestRLenValue < Minitest::Test
def test_RLenValue
h = Hivex::open(File::join(ENV['abs_srcdir'], '..', 'images', 'special'), {})
refute_nil(h)
diff --git a/ruby/tests/tc_200_write.rb b/ruby/tests/tc_200_write.rb
index 463283e..a713d77 100644
--- a/ruby/tests/tc_200_write.rb
+++ b/ruby/tests/tc_200_write.rb
@@ -17,7 +17,7 @@
require File::join(File::dirname(__FILE__), 'test_helper')
-class TestWrite < MiniTest::Unit::TestCase
+class TestWrite < Minitest::Test
def test_write
h = Hivex::open("../images/minimal", {:write => 1})
refute_nil (h)
diff --git a/ruby/tests/tc_210_setvalue.rb b/ruby/tests/tc_210_setvalue.rb
index 736b073..2ffd07b 100644
--- a/ruby/tests/tc_210_setvalue.rb
+++ b/ruby/tests/tc_210_setvalue.rb
@@ -17,7 +17,7 @@
require File::join(File::dirname(__FILE__), 'test_helper')
-class TestSetValue < MiniTest::Unit::TestCase
+class TestSetValue < Minitest::Test
def test_set_value
h = Hivex::open("../images/minimal", {:write => 1})
refute_nil (h)
--
2.41.0

View File

@ -0,0 +1,160 @@
From 6dbbc474d3df5cdfd21ed5e692b3a58136fffc42 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 7 Aug 2023 10:41:26 +0100
Subject: [PATCH 2/3] ruby: Get rid of old Test::Unit compatibility
Minitest is now required to run the Ruby unit tests.
This compatibility was added back in commit 3f3bc6af07 ("ruby: tests:
convert from Test::Unit to MiniTest (RHBZ#1090407)", 2014), but is
broken by the change from MiniTest to Minitest.
---
ruby/Makefile.am | 3 +--
ruby/tests/tc_010_load.rb | 3 ++-
ruby/tests/tc_021_close.rb | 3 ++-
ruby/tests/tc_120_rlenvalue.rb | 3 ++-
ruby/tests/tc_130_special.rb | 3 ++-
ruby/tests/tc_200_write.rb | 3 ++-
ruby/tests/tc_210_setvalue.rb | 3 ++-
ruby/tests/test_helper.rb | 31 -------------------------------
8 files changed, 13 insertions(+), 39 deletions(-)
delete mode 100644 ruby/tests/test_helper.rb
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 0e9a868..7a5fe42 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -23,8 +23,7 @@ EXTRA_DIST = \
ext/hivex/_hivex.c \
lib/hivex.rb \
run-ruby-tests \
- tests/tc_*.rb \
- tests/test_helper.rb
+ tests/tc_*.rb
CLEANFILES = \
lib/*~ \
diff --git a/ruby/tests/tc_010_load.rb b/ruby/tests/tc_010_load.rb
index 58fac33..8efac36 100644
--- a/ruby/tests/tc_010_load.rb
+++ b/ruby/tests/tc_010_load.rb
@@ -15,7 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require File::join(File::dirname(__FILE__), 'test_helper')
+require 'minitest/autorun'
+require 'hivex'
class TestLoad < Minitest::Test
def test_load
diff --git a/ruby/tests/tc_021_close.rb b/ruby/tests/tc_021_close.rb
index bc8f79d..b3aaa10 100644
--- a/ruby/tests/tc_021_close.rb
+++ b/ruby/tests/tc_021_close.rb
@@ -15,7 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require File::join(File::dirname(__FILE__), 'test_helper')
+require 'minitest/autorun'
+require 'hivex'
class TestClose < Minitest::Test
def test_close
diff --git a/ruby/tests/tc_120_rlenvalue.rb b/ruby/tests/tc_120_rlenvalue.rb
index ee881bb..f40735d 100644
--- a/ruby/tests/tc_120_rlenvalue.rb
+++ b/ruby/tests/tc_120_rlenvalue.rb
@@ -21,7 +21,8 @@
# length and offset for this value cell should be 37 bytes, position
# 8712.
-require File::join(File::dirname(__FILE__), 'test_helper')
+require 'minitest/autorun'
+require 'hivex'
class TestRLenValue < Minitest::Test
def test_RLenValue
diff --git a/ruby/tests/tc_130_special.rb b/ruby/tests/tc_130_special.rb
index 6179f51..49a635b 100644
--- a/ruby/tests/tc_130_special.rb
+++ b/ruby/tests/tc_130_special.rb
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# -*- ruby -*-
-require File::join(File::dirname(__FILE__), 'test_helper')
+require 'minitest/autorun'
+require 'hivex'
class TestRLenValue < Minitest::Test
def test_RLenValue
diff --git a/ruby/tests/tc_200_write.rb b/ruby/tests/tc_200_write.rb
index a713d77..4ce0586 100644
--- a/ruby/tests/tc_200_write.rb
+++ b/ruby/tests/tc_200_write.rb
@@ -15,7 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require File::join(File::dirname(__FILE__), 'test_helper')
+require 'minitest/autorun'
+require 'hivex'
class TestWrite < Minitest::Test
def test_write
diff --git a/ruby/tests/tc_210_setvalue.rb b/ruby/tests/tc_210_setvalue.rb
index 2ffd07b..c3624ef 100644
--- a/ruby/tests/tc_210_setvalue.rb
+++ b/ruby/tests/tc_210_setvalue.rb
@@ -15,7 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-require File::join(File::dirname(__FILE__), 'test_helper')
+require 'minitest/autorun'
+require 'hivex'
class TestSetValue < Minitest::Test
def test_set_value
diff --git a/ruby/tests/test_helper.rb b/ruby/tests/test_helper.rb
deleted file mode 100644
index f939b94..0000000
--- a/ruby/tests/test_helper.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# hivex Ruby bindings -*- ruby -*-
-# Copyright (C) 2009-2014 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-begin
- require 'minitest/autorun'
-rescue LoadError
- require 'test/unit'
- MiniTest = Test
- module Test
- Assertions = Unit::Assertions
- module Assertions
- alias refute_nil assert_not_nil
- end
- end
-end
-
-require 'hivex'
--
2.41.0

View File

@ -0,0 +1,80 @@
From 326399ceef0c904f78cdd5da17f7ca724292b4f8 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 7 Aug 2023 10:36:46 +0100
Subject: [PATCH 3/3] build: Go back to gettext 0.19
Commit 850feece ("build: Remove gnulib") unintentionally(?) moved to
GNU gettext 0.21. However this is not available in RHEL 8, and
doesn't contain any new features we need. Go back to 0.19 from RHEL 8.
Update: commit 850feece47b052e568392e83bff2bcdb2886f14d
---
configure.ac | 2 +-
po/Makevars.template | 29 -----------------------------
2 files changed, 1 insertion(+), 30 deletions(-)
diff --git a/configure.ac b/configure.ac
index 946c261..7a8b664 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,7 +136,7 @@ AS_IF([test "x$with_readline" != xno],
dnl For i18n.
AM_GNU_GETTEXT([external])
-AM_GNU_GETTEXT_VERSION([0.21])
+AM_GNU_GETTEXT_VERSION([0.19])
AM_ICONV
dnl libxml2 (optional).
diff --git a/po/Makevars.template b/po/Makevars.template
index 86a11f1..4a9ff7d 100644
--- a/po/Makevars.template
+++ b/po/Makevars.template
@@ -1,8 +1,4 @@
# Makefile variables for PO directory in any package using GNU gettext.
-#
-# Copyright (C) 2003-2019 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation gives
-# unlimited permission to use, copy, distribute, and modify it.
# Usually the message domain is the same as the package name.
DOMAIN = $(PACKAGE)
@@ -24,13 +20,6 @@ XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
# their copyright.
COPYRIGHT_HOLDER = Free Software Foundation, Inc.
-# This tells whether or not to prepend "GNU " prefix to the package
-# name that gets inserted into the header of the $(DOMAIN).pot file.
-# Possible values are "yes", "no", or empty. If it is empty, try to
-# detect it automatically by scanning the files in $(top_srcdir) for
-# "GNU packagename" string.
-PACKAGE_GNU =
-
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
# - Strings which are not entire sentences, see the maintainer guidelines
@@ -62,21 +51,3 @@ USE_MSGCTXT = no
# --previous to keep previous msgids of translated messages,
# --quiet to reduce the verbosity.
MSGMERGE_OPTIONS =
-
-# These options get passed to msginit.
-# If you want to disable line wrapping when writing PO files, add
-# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
-# MSGINIT_OPTIONS.
-MSGINIT_OPTIONS =
-
-# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
-# has changed. Possible values are "yes" and "no". Set this to no if
-# the POT file is checked in the repository and the version control
-# program ignores timestamps.
-PO_DEPENDS_ON_POT = yes
-
-# This tells whether or not to forcibly update $(DOMAIN).pot and
-# regenerate PO files on "make dist". Possible values are "yes" and
-# "no". Set this to no if the POT file and PO files are maintained
-# externally.
-DIST_DEPENDS_ON_UPDATE_PO = yes
--
2.41.0

View File

@ -10,7 +10,7 @@
Name: hivex
Version: 1.3.23
Release: 11%{?dist}
Release: 12%{?dist}
Summary: Read and write Windows Registry binary hive files
License: LGPL-2.1 AND LGPL-2.0-or-later AND GPL-2.0-or-later
@ -26,6 +26,13 @@ Source1: http://libguestfs.org/download/hivex/%{name}-%{version}.tar.gz.s
Source2: libguestfs.keyring
%endif
# Upstream patches to fix Ruby minitest support.
# https://bugzilla.redhat.com/show_bug.cgi?id=2229653
Patch: 0001-ruby-Replace-MiniTest-with-Minitest.patch
Patch: 0002-ruby-Get-rid-of-old-Test-Unit-compatibility.patch
# Another upstream patch, not required.
Patch: 0003-build-Go-back-to-gettext-0.19.patch
BuildRequires: make
BuildRequires: autoconf, automake, libtool, gettext-devel
BuildRequires: perl-interpreter
@ -319,6 +326,9 @@ fi
%changelog
* Mon Aug 07 2023 Richard W.M. Jones <rjones@redhat.com> - 1.3.23-12
- Fix Ruby minitest support (RHBZ#2229653)
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.23-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild