rails¶
DEP-8¶
The package ships DEP-8 limited testing, see autopkgtest.
In your test VM:
# buster/bullseye
# autodep8: also run the testsuite automatically
apt install autodep8
cd rails-5.2.2.1+dfsg/
debuild
autopkgtest ../rails_5.2.2.1+dfsg-1+deb10u6_amd64.changes -- null
Rails test suite¶
Run the full unit and functional testsuites (many tests are disabled when run from the build or from autopkgtest):
# buster/bullseye (WIP)
apt install mariadb-server postgresql memcached redis-server
apt install ruby-pg ruby-mysql2 ruby-hiredis
apt install ruby-nokogiri ruby-rack-cache ruby-bcrypt ruby-redcarpet
# buster:
gem install -i ~/.gem/ruby/2.5.0/ redis -v 4.0.1
#gem install mocha --version '~> 0.14'xs
#gem install redcarpet --version '~> 2.2.2'
#gem install minitest --version 5.1
#gem install w3c_validators kindlerb dalli benchmark-ips
# Setup MySQL / PostgreSQL
mysql -e "CREATE USER 'rails';"
mysql -e "GRANT ALL PRIVILEGES ON activerecord_unittest.* TO 'rails';"
mysql -e "GRANT ALL PRIVILEGES ON activerecord_unittest2.* TO 'rails';"
mysql -e "GRANT ALL PRIVILEGES ON inexistent_activerecord_unittest.* TO 'rails';"
su - postgres -c 'createuser --superuser '$USER
# Reset DB testing environment
(cd activerecord && rake db:drop; rake db:create)
rake test
time rake test > out.txt 2>&1 # ~12min
#time rake test TESTOPTS="--verbose" > out.txt 2>&1
grep 'failures,' out.txt
# "smoke" appears to run the same tests but "isolated"/individually
# some additional errors this way e.g. missing require-s
time rake smoke > smoke-out.txt 2>&1 # ~35min
grep 'failures,' smoke-out.txt
# rails-ujs
# cf. actionview/RUNNING_UJS_TESTS.rdoc
cd actionview/
apt install libxml2-dev libmariadb-dev libpq-dev libncurses-dev
bundle install --path vendor/bundle
# fiddle with ../Gemfile* until the above works...
make ujs:server
sensible-browser http://localhost:4567/
# activestorage
apt install imagemagick ffmpeg librsvg2-bin mupdf-tools
# 'bundle install' step from above
(cd activestorage/ && rake test)
# activesupport
gem install -i ~/.gem/ruby/2.5.0/ connection_pool -v 2.5.5
(cd activesupport/ && rake test)
# clean-up
(cd activerecord/ && rake db:drop)
rm -f activerecord/test/fixtures/fixture_database.sqlite3 activerecord/test/fixtures/fixture_database_2.sqlite3 Gemfile.lock activerecord/debug.log activerecord/test/config.yml railties/log/development.log
Selected tests:
(cd actionpack/ && rake test)
ruby -I actionpack/lib:actionpack/test \
actionpack/test/controller/parameters/accessors_test.rb
ruby -I activerecord/lib:activerecord/test activerecord/test/cases/serialized_attribute_test.rb
(cd activerecord/ && ruby -I lib:test test/cases/serialized_attribute_test.rb)
# with all DB backends:
cd activerecord/
rake test TEST=test/cases/serialized_attribute_test.rb
rake test TEST=test/cases/adapters/postgresql/quoting_test.rb
# Single test case
cd activesupport/
ruby -I lib:test test/cache/stores/mem_cache_store_test.rb \
-n test_raw_values_with_marshal
rake test TEST=test/cache/stores/mem_cache_store_test.rb TESTOPTS='--name=test_raw_values_with_marshal'
Before validating a patch, ensure that tests did fail before the patch (otherwise the vulnerability might need a different backport, or may not affect the version you’re working on, or maybe the new tests aren’t run at all):
# only keep the new tests
quilt diff | filterdiff -p1 -x '*/test/*' | patch -p1 -R
# should fail
<test>
# revert to full patch
quilt diff -z | patch -p1 -R
# should pass
<test>
- See also:
Note: on buster (at least), rails has a circular dependency on itself which installs its previous version, and the build-time testsuite runs against installed rails components, rather than the ones being built. This makes the testsuite particularly error-prone as it’s never clear what version is tested. +deb10u6 disables build-time tests. Build/install/autopkgtest is recommended instead.
Rebuild third-party rails packages¶
Updates in rails may cause third-party modules to break, try and rebuild a few of them:
apt source ruby-rails-assets-xxx
apt build-dep ruby-rails-assets-xxx
cd ruby-rails-assets-xxx-*/
debuild
apt source ruby-jquery-xxx-rails
apt build-dep ruby-jquery-xxx-rails
cd ruby-jquery-xxx-rails-*/
debuild
Redmine is a good reverse dependency too. Follow README.Debian.gz for the setup. Sadly Redmine got desync from rails and didn’t make it to buster and bullseye, but there were backports:
buster: https://snapshot.debian.org/package/redmine/4.0.7-1~bpo10%2B1/ (redmine 4, rails 5), plus https://snapshot.debian.org/package/ruby-rouge/3.21.0-1~bpo10%2B1/
bullseye: annoyingly there’s no redmine for rails 6.0 (4.x: 5.2; 5.x: 6.1); there’s a backport, but it pulls rails 6.1~bpo which defeats the point.