diff options
author | Jemma Issroff <[email protected]> | 2022-05-09 11:45:50 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-05-11 10:59:24 -0400 |
commit | c00feffb46ac646605adc277b5454e6b067e2d8a (patch) | |
tree | 5dc1cd26ca18b1bc0f6a48a71b91a67a6c778d43 /doc/contributing/testing_ruby.md | |
parent | becafe1efb7bf8bf5a324a6005b24e133c0f69a8 (diff) |
Improve documentation on contributing to Ruby
co-authored-by: Peter Zhu <[email protected]>
co-authored-by: Stan Lo <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5899
Diffstat (limited to 'doc/contributing/testing_ruby.md')
-rw-r--r-- | doc/contributing/testing_ruby.md | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/doc/contributing/testing_ruby.md b/doc/contributing/testing_ruby.md new file mode 100644 index 0000000000..c54b14c710 --- /dev/null +++ b/doc/contributing/testing_ruby.md @@ -0,0 +1,100 @@ +# Testing Ruby + +## Test suites + +There are several test suites in the Ruby codebase: + +We can run any of the make scripts [in parallel](building_ruby.md#label-Running+make+scripts+in+parallel) to speed them up. + +1. [bootstraptest/](https://github.com/ruby/ruby/tree/master/bootstraptest) + + This is a small test suite that runs on Miniruby (see [building Ruby](building_ruby.md#label-Miniruby+vs+Ruby)). We can run it with: + + ``` + make btest + ``` + + To run it with logs, we can use: + + ``` + make btest OPTS=-v + ``` + + If we want to run the bootstrap test suite on Ruby (not Miniruby), we can use: + + ``` + make test + ``` + + To run it with logs, we can use: + + ``` + make test OPTS=-v + ``` + +2. [test/](https://github.com/ruby/ruby/tree/master/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 in this suite using the `TESTS` environment variable, for example: + + ``` + make test-all TESTS=test/ruby/test_array.rb + ``` + + We can run a specific test in this suite using the `TESTS` environment variable, specifying + first the file name, and then the test name, prefixed with `--name`. For example: + + ``` + make test-all TESTS="../test/ruby/test_alias.rb --name=/test_aias_with_zsuper_method/" + ``` + + To run these specs with logs, we can use: + + ``` + make test-all TESTS=-v + ``` + + If we would like to run both the `test/` and `bootstraptest/` test suites, we can run + + ``` + make check + ``` + +3. [spec/ruby](https://github.com/ruby/ruby/tree/master/spec/ruby) + + This is a test suite that exists in [the Ruby spec repository](https://github.com/ruby/spec) and is mirrored into the `spec/ruby` directory in the Ruby repository. It tests the behavior of the Ruby programming language. We can run this using: + + ``` + make test-spec + ``` + + To run a specific file, we can use `MSPECOPT` to specify the file: + + ``` + make test-spec MSPECOPT=spec/ruby/core/array/any_spec.rb + ``` + + To run a specific test, we can use the `--example` flag to match against the test name: + + ``` + make test-spec MSPECOPT="../spec/ruby/core/array/any_spec.rb --example='is false if the array is empty'" + ``` + + To run these specs with logs, we can use: + + ``` + make test-spec MSPECOPT=-Vfs + ``` + +4. [spec/bundler](https://github.com/ruby/ruby/tree/master/spec/bundler) + + The bundler test suite exists in [the RubyGems repository](https://github.com/rubygems/rubygems/tree/master/bundler/spec) and is mirrored into the `spec/bundler` directory in the Ruby repository. We can run this using: + + ``` + make test-bundler + ``` |