diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 1c0120252fdf21..38c23b41107a28 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -60,23 +60,16 @@ jobs: - name: Check if to generate documents id: rdoc run: | - ref=$(sed 's/#.*//;/^rdoc /!d' gems/bundled_gems | awk '{print $4}') - echo ref=$ref >> $GITHUB_OUTPUT - # Generate only when document commit/PR - if: >- - ${{false - || contains(github.event.head_commit.message, '[ruby/rdoc]') - || contains(github.event.head_commit.message, '[DOC]') - || contains(github.event.pull_request.title, '[DOC]') - || contains(github.event.pull_request.labels.*.name, 'Documentation') - }} + set -- $(sed 's/#.*//;/^rdoc /!d' gems/bundled_gems) + { echo version=$2; echo ref=$4; } >> $GITHUB_OUTPUT + echo RDOC='ruby -W0 --disable-gems tool/rdoc-srcdir -q' >> $GITHUB_ENV - name: Checkout rdoc uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: repository: ruby/rdoc ref: ${{ steps.rdoc.outputs.ref }} - path: .bundle/gems/rdoc-0 + path: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }} if: ${{ steps.rdoc.outputs.ref != '' }} - name: Generate rdoc @@ -88,18 +81,26 @@ jobs: bundle config --local path vendor/bundle bundle install --jobs 4 bundle exec rake generate - working-directory: .bundle/gems/rdoc-0 + working-directory: .bundle/gems/rdoc-${{ steps.rdoc.outputs.version }} if: ${{ steps.rdoc.outputs.ref != '' }} + - name: Core docs coverage + run: | + $RDOC -C -x ^ext -x ^lib . + - name: Generate docs id: docs run: | - $RDOC -C -x ^ext -x ^lib . $RDOC --op html . echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT - env: - RDOC: ruby -W0 --disable-gems tool/rdoc-srcdir -q - if: ${{ steps.rdoc.outcome == 'success' }} + # Generate only when document commit/PR + if: >- + ${{false + || contains(github.event.head_commit.message, '[ruby/rdoc]') + || contains(github.event.head_commit.message, '[DOC]') + || contains(github.event.pull_request.title, '[DOC]') + || contains(github.event.pull_request.labels.*.name, 'Documentation') + }} - name: Upload docs uses: actions/upload-artifact@v4 diff --git a/doc/globals.md b/doc/globals.md index 419dcb3acdfa0e..b9315f5ff975e4 100644 --- a/doc/globals.md +++ b/doc/globals.md @@ -34,10 +34,10 @@ require 'English' ### Separators -| Variable | English | Contains | -|-------------|----------------------------|--------------------------------------------| -| `$/` | `$INPUT_RECORD_SEPARATOR` | Input record separator; initially newline. | -| `$\\\\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator; initially `nil`. | +| Variable | English | Contains | +|----------|----------------------------|--------------------------------------------| +| `$/` | `$INPUT_RECORD_SEPARATOR` | Input record separator; initially newline. | +| `$\` | `$OUTPUT_RECORD_SEPARATOR` | Output record separator; initially `nil`. | ### Streams @@ -179,7 +179,7 @@ English - `$INPUT_RECORD_SEPARATOR`, `$RS`. Aliased as `$-0`. -### `$\\` (Output Record Separator) +### `$\` (Output Record Separator) An output record separator, initially `nil`. diff --git a/gems/bundled_gems b/gems/bundled_gems index 20f4379dbbb6d7..d8fa9642ce1eb8 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -6,14 +6,14 @@ # - revision: revision in repository-url to test # if `revision` is not given, "v"+`version` or `version` will be used. -minitest 5.25.5 https://github.com/minitest/minitest +minitest 5.26.0 https://github.com/minitest/minitest power_assert 2.0.5 https://github.com/ruby/power_assert f88e406e7c9e0810cc149869582afbae1fb84c4a rake 13.3.0 https://github.com/ruby/rake test-unit 3.7.0 https://github.com/test-unit/test-unit rexml 3.4.4 https://github.com/ruby/rexml rss 0.3.1 https://github.com/ruby/rss net-ftp 0.3.8 https://github.com/ruby/net-ftp -net-imap 0.5.10 https://github.com/ruby/net-imap 71c0288b9a8f78a7125a4ce2980ab421acdf5836 +net-imap 0.5.12 https://github.com/ruby/net-imap net-pop 0.1.2 https://github.com/ruby/net-pop net-smtp 0.5.1 https://github.com/ruby/net-smtp matrix 0.4.3 https://github.com/ruby/matrix diff --git a/namespace.c b/namespace.c index 059642dd94c451..6a8f4abc9d87bf 100644 --- a/namespace.c +++ b/namespace.c @@ -986,6 +986,7 @@ rb_f_dump_classext(VALUE recv, VALUE klass) return res; } +/* :nodoc: */ static VALUE rb_namespace_root_p(VALUE namespace) { @@ -993,6 +994,7 @@ rb_namespace_root_p(VALUE namespace) return RBOOL(NAMESPACE_ROOT_P(ns)); } +/* :nodoc: */ static VALUE rb_namespace_main_p(VALUE namespace) { @@ -1000,6 +1002,7 @@ rb_namespace_main_p(VALUE namespace) return RBOOL(NAMESPACE_MAIN_P(ns)); } +/* :nodoc: */ static VALUE rb_namespace_user_p(VALUE namespace) { diff --git a/tool/commit-email.rb b/tool/commit-email.rb index d9f79f41c9982a..f738261dcca6cd 100755 --- a/tool/commit-email.rb +++ b/tool/commit-email.rb @@ -317,20 +317,14 @@ def diff_info(info, uri) end def make_header(to, from, info) - headers = [] - headers << x_author(info) - headers << x_repository(info) - headers << x_revision(info) - headers << x_id(info) - headers << 'Mime-Version: 1.0' - headers << 'Content-Type: text/plain; charset=utf-8' - headers << 'Content-Transfer-Encoding: quoted-printable' - headers << "From: #{from}" - headers << "To: #{to}" - headers << "Subject: #{make_subject(info)}" - headers.find_all do |header| - /\A\s*\z/ !~ header - end.join("\n") + <<~EOS + Mime-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: quoted-printable + From: #{from} + To: #{to} + Subject: #{make_subject(info)} + EOS end def make_subject(info) @@ -356,24 +350,8 @@ def make_from(name:, email:) end end - def x_author(info) - "X-SVN-Author: #{b_encode(info.author)}" - end - - def x_repository(info) - 'X-SVN-Repository: XXX' - end - - def x_id(info) - "X-SVN-Commit-Id: #{info.entire_sha256}" - end - - def x_revision(info) - "X-SVN-Revision: #{info.revision}" - end - def make_mail(to, from, info, viewer_uri:) - "#{make_header(to, from, info)}\n#{make_body(info, viewer_uri: viewer_uri)}" + make_header(to, from, info) + make_body(info, viewer_uri: viewer_uri) end end diff --git a/tool/test/init.rb b/tool/test/init.rb index 3a1143d01db281..3fd1419a9c85ff 100644 --- a/tool/test/init.rb +++ b/tool/test/init.rb @@ -1,7 +1,15 @@ -# This file includes the settings for "make test-all". +# This file includes the settings for "make test-all" and "make test-tool". # Note that this file is loaded not only by test/runner.rb but also by tool/lib/test/unit/parallel.rb. -ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze +# Prevent test-all from using bundled gems +["GEM_HOME", "GEM_PATH"].each do |gem_env| + # Preserve the gem environment prepared by tool/runruby.rb for test-tool, which uses bundled gems. + ENV["BUNDLED_#{gem_env}"] = ENV[gem_env] + + ENV[gem_env] = "".freeze +end +ENV["GEM_SKIP"] = "".freeze + ENV.delete("RUBY_CODESIGN") Warning[:experimental] = false diff --git a/tool/test/test_commit_email.rb b/tool/test/test_commit_email.rb index 539b0b071cd42c..efd45022be0bab 100644 --- a/tool/test/test_commit_email.rb +++ b/tool/test/test_commit_email.rb @@ -5,21 +5,24 @@ require 'open3' class TestCommitEmail < Test::Unit::TestCase + STDIN_DELIMITER = "---\n" + def setup @ruby = Dir.mktmpdir Dir.chdir(@ruby) do - git('init') + git('init', '--initial-branch=master') git('config', 'user.name', 'Jóhän Grübél') git('config', 'user.email', 'johan@example.com') - git('commit', '--allow-empty', '-m', 'New repository initialized by cvs2svn.') - git('commit', '--allow-empty', '-m', 'Initial revision') - git('commit', '--allow-empty', '-m', 'version 1.0.0') + env = { 'GIT_AUTHOR_DATE' => '2025-10-08T12:00:00Z', 'TZ' => 'UTC' } + git('commit', '--allow-empty', '-m', 'New repository initialized by cvs2svn.', env:) + git('commit', '--allow-empty', '-m', 'Initial revision', env:) + git('commit', '--allow-empty', '-m', 'version 1.0.0', env:) end @sendmail = File.join(Dir.mktmpdir, 'sendmail') File.write(@sendmail, <<~SENDMAIL) #!/usr/bin/env ruby - p ARGV + print #{STDIN_DELIMITER.dump} puts STDIN.read SENDMAIL FileUtils.chmod(0755, @sendmail) @@ -27,35 +30,54 @@ def setup @commit_email = File.expand_path('../../tool/commit-email.rb', __dir__) end - # Just testing an exit status :p - # TODO: prepare something in test/fixtures/xxx and test output - def test_successful_run - _, err, status = EnvUtil.invoke_ruby([gem_env, '-e', 'require "nkf"'], '', false, true) - unless status.success? - omit "bundled gems are not available: #{err}" - end + def test_sendmail_encoding + omit 'the sendmail script does not work on windows' if windows? Dir.chdir(@ruby) do + before_rev = git('rev-parse', 'HEAD^').chomp + after_rev = git('rev-parse', 'HEAD').chomp + short_rev = after_rev[0...10] + out, _, status = EnvUtil.invoke_ruby([ - { 'SENDMAIL' => @sendmail }.merge!(gem_env), + { 'SENDMAIL' => @sendmail, 'TZ' => 'UTC' }.merge!(gem_env), @commit_email, './', 'cvs-admin@ruby-lang.org', - git('rev-parse', 'HEAD^').chomp, git('rev-parse', 'HEAD').chomp, 'refs/heads/master', + before_rev, after_rev, 'refs/heads/master', '--viewer-uri', 'https://github.com/ruby/ruby/commit/', '--error-to', 'cvs-admin@ruby-lang.org', ], '', true) - assert_true(status.success?, out) + stdin = out.b.split(STDIN_DELIMITER.b, 2).last.force_encoding('UTF-8') + + assert_true(status.success?) + assert_equal(stdin, <<~EOS) + Mime-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: quoted-printable + From: =?UTF-8?B?SsOzaMOkbiBHcsO8YsOpbA==?= + To: cvs-admin@ruby-lang.org + Subject: #{short_rev} (master): =?UTF-8?B?dmVyc2lvbuOAgDEuMC4w?= + J=C3=B3h=C3=A4n Gr=C3=BCb=C3=A9l\t2025-10-08 12:00:00 +0000 (Wed, 08 Oct 2= + 025) + + New Revision: #{short_rev} + + https://github.com/ruby/ruby/commit/#{short_rev} + + Log: + version=E3=80=801.0.0= + EOS end end private - # Cancel the gem environments set by tool/test/init.rb + # Resurrect the gem environment preserved by tool/test/init.rb. + # This should work as long as you have run `make up` or `make install`. def gem_env - { 'GEM_PATH' => nil, 'GEM_HOME' => nil } + { 'GEM_PATH' => ENV['BUNDLED_GEM_PATH'], 'GEM_HOME' => ENV['BUNDLED_GEM_HOME'] } end - def git(*cmd) - out, status = Open3.capture2('git', *cmd) + def git(*cmd, env: {}) + out, status = Open3.capture2(env, 'git', *cmd) unless status.success? raise "git #{cmd.shelljoin}\n#{out}" end