diff --git a/.gitignore b/.gitignore index 9055ac4..418faa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /rouge-*gem +/rouge-*-test-missing-files.tar.gz diff --git a/bundler.rb b/bundler.rb new file mode 100644 index 0000000..6ad8460 --- /dev/null +++ b/bundler.rb @@ -0,0 +1,6 @@ +module Bundler + class << self + def require + end + end +end diff --git a/rouge-create-missing-test-files.sh b/rouge-create-missing-test-files.sh new file mode 100644 index 0000000..eb18660 --- /dev/null +++ b/rouge-create-missing-test-files.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +usage() { + echo "$0 " +} + +set -e +set -x + +if [ $# -lt 1 ] ; then + usage + exit 1 +fi + +VERSION=$1 +REPONAME=rouge + +TMPDIR=$(mktemp -d /tmp/rouge-XXXXXX) +CURDIR=$(pwd) + +pushd $TMPDIR + +git clone https://github.com/rouge-ruby/${REPONAME}.git +cd rouge/ + +git reset --hard v$VERSION +cd .. +ln -sf ${REPONAME} ${REPONAME}-${VERSION} +tar czf $CURDIR/rouge-${VERSION}-test-missing-files.tar.gz ${REPONAME}-${VERSION}/spec/ + +popd +rm -rf $TMPDIR + diff --git a/rubygem-rouge-pr1912-espace-hash-in-regex-ruby32.patch b/rubygem-rouge-pr1912-espace-hash-in-regex-ruby32.patch new file mode 100644 index 0000000..a2a7055 --- /dev/null +++ b/rubygem-rouge-pr1912-espace-hash-in-regex-ruby32.patch @@ -0,0 +1,24 @@ +From 97deb402cf670d6f0708ab583f1b7d769d477c0b Mon Sep 17 00:00:00 2001 +From: Tan Le +Date: Fri, 13 Jan 2023 17:31:18 +1100 +Subject: [PATCH 3/3] Escape character that causes parsing issue + +This ensures we escape `#` character to avoid parsing issue in Ruby 3.2. +This change is backward compatible with earlier versions. +--- + lib/rouge/lexers/ghc_cmm.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/rouge/lexers/ghc_cmm.rb b/lib/rouge/lexers/ghc_cmm.rb +index 481bf20f9..1bbfb6be0 100644 +--- a/lib/rouge/lexers/ghc_cmm.rb ++++ b/lib/rouge/lexers/ghc_cmm.rb +@@ -22,7 +22,7 @@ class GHCCmm < RegexLexer + ws = %r(\s|//.*?\n|/[*](?:[^*]|(?:[*][^/]))*[*]+/)mx + + # Make sure that this is not a preprocessor macro, e.g. `#if` or `#define`. +- id = %r((?!#[a-zA-Z])[\w#\$%_']+) ++ id = %r((?!\#[a-zA-Z])[\w#\$%_']+) + + complex_id = %r( + (?:[\w#$%_']|\(\)|\(,\)|\[\]|[0-9])* diff --git a/rubygem-rouge.spec b/rubygem-rouge.spec index 9e603f9..df9d1c9 100644 --- a/rubygem-rouge.spec +++ b/rubygem-rouge.spec @@ -2,16 +2,25 @@ Name: rubygem-%{gem_name} Version: 4.0.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Pure-ruby colorizer based on pygments License: MIT and BSD URL: http://rouge.jneen.net/ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem - +Source1: %{gem_name}-%{version}-test-missing-files.tar.gz +# SOURCE1 is created by $ bash %%SOURCE2 %%version +Source2: rouge-create-missing-test-files.sh +Source10: spec_helper_assert.rb +Source11: bundler.rb +# https://github.com/rouge-ruby/rouge/pull/1912 +# Escape hash character in regex to avoid parsing issue in Ruby 3.2 +Patch0: %{name}-pr1912-espace-hash-in-regex-ruby32.patch BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: help2man +BuildRequires: rubygem(minitest) +BuildRequires: rubygem(rake) BuildArch: noarch @@ -29,14 +38,20 @@ Documentation for %{name}. %prep -%setup -q -n %{gem_name}-%{version} +%setup -q -n %{gem_name}-%{version} -a 1 mv ../%{gem_name}-%{version}.gemspec . +cp -a %{gem_name}-%{version}/spec . +mkdir FAKE +cp -a %{SOURCE11} FAKE/ +cp -pa %{SOURCE10} spec/ + +%patch0 -p1 + %build gem build %{gem_name}-%{version}.gemspec %gem_install - %install mkdir -p %{buildroot}%{gem_dir} cp -a .%{gem_dir}/* %{buildroot}%{gem_dir}/ @@ -61,6 +76,15 @@ rm -rf \ %{nil} popd +%check +find spec -name \*_spec.rb -print0 | \ + sort --zero-terminated | \ + xargs --null ruby -Ilib:FAKE \ + -r./spec/spec_helper \ + -r./spec/spec_helper_assert \ + -r rake/rake_test_loader \ + %{nil} + %files %dir %{gem_instdir} @@ -80,6 +104,10 @@ popd %{gem_libdir}/%{gem_name}/demos %changelog +* Sun Feb 12 2023 Mamoru TASAKA - 4.0.1-3 +- Execute spec test provided by the upstream +- Backport upstream patch for ruby32 regex issue with hash character + * Fri Jan 20 2023 Fedora Release Engineering - 4.0.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild diff --git a/sources b/sources index 5b819cd..70c048f 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (rouge-4.0.1.gem) = 49dc512e38b7109368ab827c5423174f5911b1c5a47257170b62c093041412abbefcf998b1e03bb2d994a2fb724eb8fb7868875bad440203b4203a31336b7108 +SHA512 (rouge-4.0.1-test-missing-files.tar.gz) = c906f60c3427b2d70cb621e9aa083713e1d242c3c221f932505d4307af1555775763b1795fb50563c44a7038651d6e20f27ec35c4d4a69202e583cbdb955efaf diff --git a/spec_helper_assert.rb b/spec_helper_assert.rb new file mode 100644 index 0000000..a063576 --- /dev/null +++ b/spec_helper_assert.rb @@ -0,0 +1,24 @@ +module Minitest + module Assertions + + alias_method :assert_orig, :assert + alias_method :refute_orig, :refute + + def assert(test = nil, msg = nil, &block) + if block_given? + assert_orig yield + else + assert_orig test, msg + end + end + + def refute(test = nil, msg = nil, &block) + if block_given? + refute_orig yield + else + refute_orig test, msg + end + end + + end +end