Skip to content

Manually merging specs (old way)

Benoit Daloze edited this page Oct 31, 2024 · 2 revisions

Old

This is the old historic way, see https://github.com/ruby/spec/wiki/Merging-specs-from-JRuby-and-other-sources instead.

The procedure is the following. Specs from Opal are directly merged in this repo, so there is nothing special to do.

1. Merging new specs from JRuby, TruffleRuby and MRI

A tool is now available in MSpec that entirely automates this section: https://github.com/ruby/mspec/blob/master/tool/sync/sync-rubyspec.rb

Create a clone of jruby/jruby just for this purpose:

git clone https://github.com/jruby/jruby.git jruby-rubyspec 
cd jruby-rubyspec 

Extract the commits and push them on a branch of the local rubyspec repo:

git checkout master
git pull

SPECS_BRANCH=specs-`date +%F`
git checkout -b $SPECS_BRANCH

git filter-branch -f --subdirectory-filter spec/ruby f10ab6988d...

# Assuming the rubyspec repo is in the parent dir
git push -f ../rubyspec ${SPECS_BRANCH}:jruby

Integrate the new specs on top of master:

cd ../rubyspec
git checkout master
git pull

git branch -D jruby-rebased
git checkout -b jruby-rebased jruby

# LAST_MERGE is the parent of the first new spec commit
LAST_MERGE=`git log --grep='Merge.*commit' -n 1 --format=%H`
echo $LAST_MERGE

git rebase --onto master $LAST_MERGE

# Clean up the commit messages, in one terminal use:
git log -p master...
# and in the other
git rebase -i master
# You can check the diff of the commit you are rewording with
git diff HEAD^

Test if all specs pass on MRI latest release and 2.1:

chruby 2.4.0
../mspec/bin/mspec .

chruby 2.1.9
../mspec/bin/mspec .

# If you get failures, commit fixes on top until everything passes.

Merge to master and push:

git checkout master
git merge --ff-only jruby-rebased

git push

Wait for Travis-CI and AppVeyor, and fix if there is any error or failure.

2. Merging new specs from Rubinius

Look if there are new specs at https://github.com/rubinius/rubinius/commits/master/spec/ruby

Create a clone of rubinius/rubinius just for this purpose:

git clone https://github.com/rubinius/rubinius.git rubinius-rubyspec
cd rubinius-rubyspec

Extract the commits and push them on a branch of the local rubyspec repo:

git checkout master
git pull

SPECS_BRANCH=specs-`date +%F`
git checkout -b $SPECS_BRANCH

# This takes a while, be patient
git filter-branch -f --subdirectory-filter spec/ruby

# Assuming the rubyspec repo is in the parent dir
git push -f ../rubyspec ${SPECS_BRANCH}:rbx

Integrate the new specs on top of master:

cd ../rubyspec
git checkout master
git pull

git branch -D rbx-rebased
git checkout -b rbx-rebased rbx

# We need to find the last commit that was merged in ruby/spec
# For that,
cd ../rubinius-rubyspec
git log --oneline --decorate
# Copy the commit message corresponding to the last specs branch
cd ../rubyspec
LAST_MERGE=`git log --grep='<PASTED MESSAGE>' -n 1 --format=%H`
echo $LAST_MERGE

git rebase --onto master $LAST_MERGE

# Clean up the commit messages, in one terminal use:
git log -p master...
# and in the other
git rebase -i master
# You can check the diff of the commit you are rewording with
git diff HEAD^

Test if all specs pass on MRI latest release and 2.1:

chruby 2.3.0
../mspec/bin/mspec .

chruby 2.1.7
../mspec/bin/mspec .

# If you get failures, commit fixes on top until everything passes.

Create a Pull Request and when the CI passes, push directly to master (to avoid the Merge commit):

git checkout master
git merge --ff-only rbx-rebased

git push

Wait for Travis-CI and AppVeyor, and fix if there is any error or failure.

3. Merging back to JRuby and TruffleRuby

First update MSpec

cd ../jruby
git checkout master
git pull

# BUILD the project
./mvnw

spec/mspec/tool/pull-latest-mspec-spec

Add tags for new failing specs

# JRuby
bin/jruby spec/mspec/bin/mspec run -Gfails -Gcritical -Gslow :language
bin/jruby spec/mspec/bin/mspec tag -Gfails -Gcritical -Gslow --add fails spec/ruby/SOME/SPEC_spec.rb

# TruffleRuby
tool/jt.rb test fast
tool/jt.rb tag spec/ruby/SOME/SPEC_spec.rb

4. Update in MRI:

spec/mspec/tool/pull-latest-mspec-spec