testing_ruby - Documentation for Ruby 4.0 (original) (raw)
All the commands below assume that you’re running them from the build/ directory made during Building Ruby.
Most commands below should work with GNU make (the default on Linux and macOS), BSD make and NMAKE, except where indicated otherwise.
- bootstraptest/
This is a small test suite that runs on Miniruby. We can run it with:
make btest
To run individual bootstrap tests, we can either specify a list of filenames or use the--setsflag in the variableBTESTS:
make btest BTESTS="../bootstraptest/test_string.rb ../bootstraptest/test_class.rb"
make btest BTESTS="--sets=string,class"
To run these tests with verbose logging, we can add-vto theOPTS:
make btest OPTS="--sets=string,class -v"
If we want to run the bootstrap test suite on Ruby (not Miniruby), we can use:
make test
To run these tests with verbose logging, we can add-vto theOPTS:
make test OPTS=-v
(GNU make only) To run a specific file, we can use:
make ../test/ruby/test_string.rb
You can use the-ntest option to run a specific test with a regex:
make ../test/ruby/test_string.rb TESTOPTS="-n /test_.*_to_s/" - test/
This is a more comprehensive test suite that runs on Ruby. We can run it with:
make test-all
We can run a specific test file or directory in this suite using theTESTSoption, for example:
make test-all TESTS="../test/ruby/"
make test-all TESTS="../test/ruby/test_string.rb"
We can run a specific test in this suite using theTESTSoption, specifying first the file name, and then the test name, prefixed with--name. For example:
make test-all TESTS="../test/ruby/test_string.rb --name=TestString#test_to_s"
To run these tests with verbose logging, we can add-vtoTESTS:
make test-all TESTS=-v
We can display the help of theTESTSoption:
make test-all TESTS=--help
We can run all the tests intest/,bootstraptest/andspec/(thespec/is explained in a later section) all together with:
make check - spec/ruby
This is a test suite defined in the Ruby spec repository, and is periodically mirrored into thespec/rubydirectory of this repository. It tests the behavior of the Ruby programming language. We can run this using:
make test-spec
We can run a specific test file or directory in this suite using theSPECOPTSoption, for example:
make test-spec SPECOPTS="../spec/ruby/core/string/"
make test-spec SPECOPTS="../spec/ruby/core/string/to_s_spec.rb"
To run a specific test, we can use the--exampleflag to match against the test name:
make test-spec SPECOPTS="../spec/ruby/core/string/to_s_spec.rb --example='returns self when self.class == String'"
To run these specs with verbose logging, we can add-vto theSPECOPTS:
make test-spec SPECOPTS="../spec/ruby/core/string/to_s_spec.rb -Vfs"
(GNU make only) To run a ruby-spec file or directory, we can use
make ../spec/ruby/core/string/to_s_spec.rb - spec/bundler
The bundler test suite is defined in the RubyGems repository, and is periodically mirrored into thespec/rubydirectory of this repository. We can run this using:
make test-bundler
To run a specific bundler spec file, we can useBUNDLER_SPECSas follows:
make test-bundler BUNDLER_SPECS=commands/exec_spec.rb
If we see failing tests related to the zlib library on s390x CPU architecture, we can run the test suites with DFLTCC=0 to pass:
The failures can happen with the zlib library applying the patch madler/zlib#410 to enable the deflate algorithm producing a different compressed byte stream. We manage this issue at [ruby-core:114942][Bug #19909].