Practical Testing of Ruby Core

Hiroshi SHIBATA
Hiroshi SHIBATAOSS programmer at GMO Pepabo, Inc.
Details for language testing
Practical Testing
of Ruby Core
self.introduce
=>
{
name: “SHIBATA Hiroshi”,
nickname: “hsbt”,
title: “Chief engineer at GMO Pepabo, Inc.”,
commit_bits: [“ruby”, “rake”, “rubygems”, “rdoc”,
“psych”, “syck”, “ruby-build”, “tdiary”, “railsgirls”,
“railsgirls-jp”, …],
sites: [“hsbt.org”, “ruby-lang.org”, “rubyci.org”,
“railsgirls.com”, “railsgirls.jp”],
}
pepabo.com
もっと
おもしろくできる
Our challenges on GMO Pepabo, Inc.
Infrastructure as a Code
• https://github.com/yaocloud
• https://github.com/matsumoto-r/mod_mruby
• https://github.com/matsumoto-r/ngx_mruby
• https://github.com/matsumoto-r/rcon
Productive Development with OSS
• https://github.com/pepabo/capistrano-stretcher
• https://github.com/pepabo/mackerel-rb
• https://github.com/pyama86/malsh
• https://github.com/linyows/capistrano-github-
releases
self.introduce
=>
{
name: “SHIBATA Hiroshi”,
nickname: “hsbt”,
title: “Chief engineer at GMO Pepabo, Inc.”,
commit_bits: [“ruby”, “rake”, “rubygems”, “rdoc”,
“psych”, “syck”, “ruby-build”, “tdiary”, “railsgirls”,
“railsgirls-jp”, …],
sites: [“hsbt.org”, “ruby-lang.org”, “rubyci.org”,
“railsgirls.com”, “railsgirls.jp”],
}
Practical Testing of Ruby Core
How to contribute
to OSS
Contributing of OSS
People say:
“Contributing to OSS is easy! Please write
some documentation and submit a patch!”
You say:
“Okay! I will contribute new documentation
for Ruby!”
Documentation is hard
But documentation is hard, I think
• No-one knows the true behavior of the Ruby
language.
• Only Matz knows that.
• English is hard (for Japanese)
• Documentation is boring work :bow:
Because documentation is valuable work.
Testing and Running are easy
On the other hand, testing and running code is easy.
• Ruby has a lot of test ecosystem and libraries.
• Bundler and Docker provide an encapsulated
environment.
If you get test failures, you can submit issue ticket to our
tracker. It helps ruby committer.
If test coverage is missing for some ruby code, you can
also write new tests and submit a patch to upstream.
Code reading tips
I always start code reading with the following commands
I pick out `before_script` and `script` code from .travis.yml
and invoke it. For example:
$ git clone https://github.com/some/gems
$ cd gems
$ less .travis.yml
$ bundle install
$ rake spec
$ rake spec:plugins
In the case of ruby
You will get…
$ git clone https://github.com/ruby/ruby
$ cd ruby
$ less .travis.yml
before_script:
- "if [[ $TRAVIS_OS_NAME = 'osx' ]]; then rm -f ~/Library/Logs/DiagnosticReports/ruby_*.crash; fi"
- "uname -a"
- "uname -r"
- "rm -fr .ext autom4te.cache"
- "make -f common.mk BASERUBY=ruby MAKEDIRS='mkdir -p' srcdir=. update-config_files"
- "autoconf"
- "mkdir config_1st config_2nd"
- "./configure -C --disable-install-doc --with-gcc=$CC $CONFIG_FLAG"
- "cp -pr config.status .ext/include config_1st"
- "make reconfig"
- "cp -pr config.status .ext/include config_2nd"
- "diff -ru config_1st config_2nd"
- "make after-update BASERUBY=ruby"
- "make -s $JOBS encs"
- "make -s $JOBS exts"
- "make update-rubyspec"
- "if [[ $TRAVIS_OS_NAME = 'osx' ]]; then echo 'exclude :test_deadlock_by_signal_at_forking, "under
investigation"' >> test/excludes/TestProcess.rb; fi"
script:
- "make test"
- "make test-all TESTOPTS='-q -j2'"
- "make test-rubyspec"
.travis.yml in ruby/ruby
Dive into
testing of ruby language
Tips for testing ruby
You can invoke language tests with the following
instructions:
$ git clone https://github.com/ruby/ruby
$ cd ruby
$ autoconf
$ ./configure —disable-install-doc
$ make -j
$ make check
% make check
(snip)
test succeeded
PASS all 1010 tests
exec ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems "./bootstraptest/
runner.rb" --ruby="ruby --disable-gems" ./KNOWNBUGS.rb
2015-12-04 11:53:44 +0900
Driver is ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15]
Target is ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15]
KNOWNBUGS.rb PASS 0
No tests, no problem
Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems"
# Running tests:
Finished tests in 2.009208s, 109.4959 tests/s, 219.9872 assertions/s.
220 tests, 442 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15]
Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" --
excludes=./test/excludes -x /memory_leak/ -x /testunit/ -x /minitest/
# Running tests:
[ 365/15731] Fiddle::TestFunc#test_qsort1
common.mk
common.mk defines test tasks for the make command
• check/check-ruby
• btest/btest-ruby
• test-sample
• test-knownbug
• test-testframework
• test
• test-all
• test-almost
• test-ruby
• test-rubyspec
make test
make test depends on the following tests
• test-sample
• invoke `tool/rubytest.rb` with target ruby
• rubytest.rb run `sample/test.rb` !!1
• btest-ruby
• snip for next slides
• test-knownbug
• invoke `KNOWNBUGS.rb`
• It’s empty a lot of the time.
`cat sample/test.rb`
a, = nil; test_ok(a == nil)
a, = 1; test_ok(a == 1)
a, = []; test_ok(a == nil)
(snip)
def r; return *[]; end; a = r(); test_ok(a == [])
def r; return *[1]; end; a = r(); test_ok(a == [1])
def r; return *[nil]; end; a = r(); test_ok(a == [nil])
(snip)
f = lambda { |a, b=42, *c| [a,b,c] }
test_ok(f.call(1 ) == [1,42,[ ]] )
test_ok(f.call(1,43 ) == [1,43,[ ]] )
test_ok(f.call(1,43,44) == [1,43,[44]] )
(snip)
make btest-ruby
btest-ruby invokes test files with the ruby binary and
`bootstraptest/runner.rb` under the `bootstraptest`
directory.
What’s `bootstraptest/runner.rb` ?
• load test files and invoke them
• define assertion methods like `assert_equal` etc.
% ls bootstraptest
pending.rb runner.rb* test_attr.rb test_autoload.rb test_block.rb test_class.rb
test_eval.rb test_exception.rb test_finalizer.rb test_flip.rb test_flow.rb test_fork.rb
test_gc.rb test_io.rb test_jump.rb test_literal.rb test_literal_suffix.rb test_load.rb
test_marshal.rb test_massign.rb test_method.rb test_objectspace.rb test_proc.rb
test_string.rb test_struct.rb test_syntax.rb test_thread.rb
`cat bootstraptest/test_class.rb`
assert_equal 'true', %q( class C; end
Object.const_defined?(:C) )
assert_equal 'Class', %q( class C; end
C.class )
(snip)
assert_equal 'Class', %q( class A; end
class C < A; end
C.class )
(snip)
assert_equal 'M', %q( module M; end
M.name )
(snip)
assert_equal 'A::B', %q( class A; end
class A::B; end
A::B )
make test-all
test-all invokes test files under the `test` directory.
These test files contain core libraries like String and
Array and stdlib like Webrick and Logger. This task is a
good one for a typical contributor.
test-all has some options for testing:
• make test-all TESTS=logger
• test only files under `test/logger`
• make test-all TESTS=“-j4”
• it make parallel execution with 4 processes.
cat `test/ruby/test_array.rb`
% cat test/ruby/test_array.rb
# coding: US-ASCII
require 'test/unit'
class TestArray < Test::Unit::TestCase
(snip)
def test_percent_i
assert_equal([:foo, :bar], %i[foo bar])
assert_equal([:""foo"], %i["foo])
end
def test_0_literal
assert_equal([1, 2, 3, 4], [1, 2] + [3, 4])
assert_equal([1, 2, 1, 2], [1, 2] * 2)
assert_equal("1:2", [1, 2] * ":")
(snip)
cat `test/-ext-/array/test_resize.rb`
require 'test/unit'
require '-test-/array/resize'
class TestArray < Test::Unit::TestCase
class TestResize < Test::Unit::TestCase
def test_expand
feature = '[ruby-dev:42912]'
ary = [*1..10]
ary.__resize__(10)
assert_equal(10, ary.size, feature)
assert_equal([*1..10], ary, feature)
ary.__resize__(100)
assert_equal(100, ary.size, feature)
(snip)
% cat ext/-test-/array/resize/resize.c
#include "ruby/ruby.h"
static VALUE
ary_resize(VALUE ary, VALUE len)
{
rb_ary_resize(ary, NUM2LONG(len));
return ary;
}
void
Init_resize(void)
{
rb_define_method(rb_cArray, "__resize__", ary_resize, 1);
}
cat `test/logger/test_logger.rb`
% cat test/logger/test_logger.rb
# coding: US-ASCII
require 'test/unit'
require 'logger'
require 'tempfile'
class TestLogger < Test::Unit::TestCase
(snip)
def test_add
logger = Logger.new(nil)
logger.progname = "my_progname"
assert(logger.add(INFO))
log = log_add(logger, nil, "msg")
assert_equal("ANY", log.severity)
assert_equal("my_progname", log.progname)
(snip)
make check
make check depends on the following definitions:
• main
• build encodings and extensions.
• test
• (snip)
• test-testframework
• run tests for `testunit` and `minitest`
• test-almost
• run tests under `test` excluding `testunit` and
`minitest`
make check runs all test tasks in CRuby
make testframework-test/test-almost
I separated test files testunit and minitest from test-all.
Why does CRuby have test files for testunit and minitest?
• CRuby Forked test-unit and minitest
• CRuby added parallel execution function to test-unit
We need to invoke to test to test-framework before CAPI,
core library and standard library.
test-almost invokes tests under `test` without test-unit
and minitest.
test-unit/minitest
Why separated the test framework?
The following libraries uses minitest directly in Ruby 2.3:
• rubygems
• rdoc
• net-smtp (It seems unnecessary)
Other libraries uses test-unit. rubygems and rdoc are
developed at github.com/rubygems/rubygems and
github.com/rdoc/rdoc. We need to support these libraries
and their tests.
How to merge upstream from others
I merged upstream into ruby/ruby periodically using
following instructions.
ruby and rubygems guarantee to work to test and code
each other. it’s the same situation for ruby and rdoc
$ git clone https://github.com/ruby/ruby
$ git clone https://github.com/rubygems/rubygems
$ cd ruby
$ rm -rf lib/rubygems test/rubygtems lib/rubygems.rb
$ cp -rf ../../rubygems/rubygems/lib/rubygems ./lib
$ cp -rf ../../rubygems/rubygems/lib/rubygems.rb ./lib
$ cp -rf ../../rubygems/rubygems/test/rubygems ./test
$ git checkout lib/rubygems/LICENSE.txt
backporting is hard
rubygems and rdoc still support Ruby 1.8.
% g show a34fb569e41cd87866e644d92a9df4be89b3cad2 test/rubygems/test_gem_package.rb
commit a34fb569e41cd87866e644d92a9df4be89b3cad2
Author: Eric Hodel <drbrain@segment7.net>
Date: Tue Jul 8 16:53:50 2014 -0700
Fix tests on ruby 1.8
diff --git test/rubygems/test_gem_package.rb test/rubygems/test_gem_package.rb
index f07c083..128dcdb 100644
--- test/rubygems/test_gem_package.rb
+++ test/rubygems/test_gem_package.rb
@@ -638,7 +638,7 @@ class TestGemPackage < Gem::Package::TarTestCase
e.message
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
end
def test_verify_empty
Forked code for Test::Unit
• test/lib/envutil.rb
• some assertion and function for language
testing
• leakchecker.rb
• checker for memory and fd leak.
• test/lib/test/lib/parallel.rb
• helper library parallel execution for test-
case
rubyspec
RubySpec
Q. What’s rubyspec?
A. RubySpec is an executable specification for the Ruby
programming language.
“Matz's Ruby Developers Don't Use RubySpec and It's
Hurting Ruby”
http://rubini.us/2014/12/31/matz-s-ruby-developers-don-t-use-rubyspec/
rubyspec is not a “specification”. It’s actually a set of
“test”. The only real ruby specification is inside of Matz :)
make test-rubyspec
CRuby has `make update-rubyspec` and `make test-
rubyspec` tasks.
`make update-rubyspec` pulls ruby/rubyspec and ruby/
mspec into the spec directory.
`make test-rubyspec` invokes mspec with the ruby binary
and the latest rubyspecs.
cat spec/rubyspec/core/string/append_spec.rb
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/concat', __FILE__)
describe "String#<<" do
it_behaves_like :string_concat, :<<
it_behaves_like :string_concat_encoding, :<<
end
% cat spec/rubyspec/core/string/shared/concat.rb
describe :string_concat, shared: true do
it "concatenates the given argument to self and returns self" do
str = 'hello '
str.send(@method, 'world').should equal(str)
str.should == "hello world"
end
(snip)
rubyspec and mspec
We approved new or updated examples at github.com/
ruby/rubyspec.
@headius wrote: “So nice to see RubySpec getting a
steady stream of Ruby 2.3 specs.”
https://twitter.com/headius/status/667793518098673664
A lot of contributors submitted new specs for Ruby 2.3
features.
rubyci
rubyci and chkbuild
Ruby CI is a CI results collector for alternative
platforms:
https://github.com/nurse/rubyci
ruby ci uses chkbuild built by akr:
https://github.com/akr/chkbuild
Practical Testing of Ruby Core
How to add a new server
You can add your server to rubyci.org
Requirements:
• not yet supported platforms.
• ex. linux with ARM, *BSD, icc with OSX, Windows
• periodically running every day
• It must be possible to access to AWS S3
You should check the following commands on your server
$ git clone https://github.com/akr/chkbuild
$ cd chkbuild
$ ruby start-build
appendix
make run/bisect
`make run` invokes the `test.rb` file on ruby source
directory. ko1 said this task helped with YARV
development.
`make bisect` invokes `make run` with git-bisect. It helps
detect commits containing defects.
but it’s only useful for a single ruby file. we need to
invoke git-bisect under the bundler environment. that’s
very difficult.
test coverage
I added a coverage task using simplecov
You can get coverage results for `webrick` under the
coverage directory.
% make update-coverage
updating simplecov ...
remote: Counting objects: 90, done.
(snip)
updating simplecov-html ...
updating doclie …
% COVERAGE=1 make test-all TESTS=webrick
Practical Testing of Ruby Core
% COVERAGE=1 make test-all
CC = clang
(snip)
Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext
-- --disable-gems" --excludes=./test/excludes -x /memory_leak/
# Running tests:
[ 3491/15951] TestCoverage#test_big_code = 0.17 s
1) Failure:
TestCoverage#test_big_code [/path/to/ruby/test/lib/tracepointchecker.rb:18]:
The number of active trace events was changed.
<[[#<RubyVM:0x000001017c3588>, 1]]> expected but was
<[[#<RubyVM:0x000001017c3588>, 0]]>.
/path/to/ruby/test/lib/leakchecker.rb:116: [BUG] Segmentation fault at
0x00000000000000
ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15]
Limitation of test coverage
We have some defects related to the “Coverage” library.
Conclusion
Plan for Ruby 2.4/3.0
• Restructured test directories and files
• Separated test focus
• Removed duplicate tests
• Simplify test tasks
• stdlib tests more friendly with JRuby
• Increase coverage
• Integrate rubyspec and ruby tests
Please contribute tests to ruby
You can invoke CRuby tests:
You can invoke focused tests with coverage:
You can code new tests or update existing tests. and
submit patches to our tracker or github.com/ruby/ruby.
$ git clone https://github.com/ruby/ruby
$ cd ruby
$ autoconf
$ ./configure —disable-install-doc
$ make -j
$ make check
$ COVERAGE=1 make test-all TESTS=“logger”
$ open coverage/index.html
Ruby testing is so easy
1 of 51

Recommended

The worst Ruby codes I’ve seen in my life - RubyKaigi 2015 by
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015Fernando Hamasaki de Amorim
16.3K views141 slides
How to Begin Developing Ruby Core by
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
1.9K views27 slides
Practical ngx_mruby by
Practical ngx_mrubyPractical ngx_mruby
Practical ngx_mrubyHiroshi SHIBATA
5.9K views27 slides
Rhebok, High Performance Rack Handler / Rubykaigi 2015 by
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Masahiro Nagano
76.1K views67 slides
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015) by
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)ngotogenome
11.9K views42 slides

More Related Content

What's hot

PSGI and Plack from first principles by
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principlesPerl Careers
2K views42 slides
服务框架: Thrift & PasteScript by
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
4.8K views35 slides
Large-scaled Deploy Over 100 Servers in 3 Minutes by
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesHiroshi SHIBATA
3.8K views89 slides
How to Begin to Develop Ruby Core by
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHiroshi SHIBATA
2.9K views80 slides
Plack - LPW 2009 by
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009Tatsuhiko Miyagawa
2.4K views93 slides
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery by
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
39.1K views131 slides

What's hot(20)

PSGI and Plack from first principles by Perl Careers
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
Perl Careers2K views
服务框架: Thrift & PasteScript by Qiangning Hong
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
Qiangning Hong4.8K views
Large-scaled Deploy Over 100 Servers in 3 Minutes by Hiroshi SHIBATA
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA3.8K views
How to Begin to Develop Ruby Core by Hiroshi SHIBATA
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
Hiroshi SHIBATA2.9K views
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery by Tatsuhiko Miyagawa
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa39.1K views
Middleware as Code with mruby by Hiroshi SHIBATA
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
Hiroshi SHIBATA5.2K views
How to test code with mruby by Hiroshi SHIBATA
How to test code with mrubyHow to test code with mruby
How to test code with mruby
Hiroshi SHIBATA10.1K views
Gemification plan of Standard Library on Ruby by Hiroshi SHIBATA
Gemification plan of Standard Library on RubyGemification plan of Standard Library on Ruby
Gemification plan of Standard Library on Ruby
Hiroshi SHIBATA351 views
The secret of programming language development and future by Hiroshi SHIBATA
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
Hiroshi SHIBATA1.1K views
Practical PHP 5.3 by Nate Abele
Practical PHP 5.3Practical PHP 5.3
Practical PHP 5.3
Nate Abele7K views
Nodejs Explained with Examples by Gabriele Lana
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
Gabriele Lana112.3K views
Integrating icinga2 and the HashiCorp suite by Bram Vogelaar
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
Bram Vogelaar86 views

Viewers also liked

TRICK2015 results by
TRICK2015 resultsTRICK2015 results
TRICK2015 resultsmametter
17.9K views68 slides
Plugin-based software design with Ruby and RubyGems by
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsSadayuki Furuhashi
7.9K views78 slides
Techmix2014 温故知新 by
Techmix2014 温故知新Techmix2014 温故知新
Techmix2014 温故知新Kazuya Numata
7.2K views57 slides
Do you trust that certificate? by
Do you trust that certificate?Do you trust that certificate?
Do you trust that certificate?zunda
1.6K views69 slides
Metaprogramming in Haskell by
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in HaskellHiromi Ishii
4.2K views156 slides
High Performance tDiary by
High Performance tDiaryHigh Performance tDiary
High Performance tDiaryHiroshi SHIBATA
1K views25 slides

Viewers also liked(18)

TRICK2015 results by mametter
TRICK2015 resultsTRICK2015 results
TRICK2015 results
mametter17.9K views
Plugin-based software design with Ruby and RubyGems by Sadayuki Furuhashi
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
Sadayuki Furuhashi7.9K views
Techmix2014 温故知新 by Kazuya Numata
Techmix2014 温故知新Techmix2014 温故知新
Techmix2014 温故知新
Kazuya Numata7.2K views
Do you trust that certificate? by zunda
Do you trust that certificate?Do you trust that certificate?
Do you trust that certificate?
zunda1.6K views
Metaprogramming in Haskell by Hiromi Ishii
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
Hiromi Ishii4.2K views
GitHub Enterprise with GMO Pepabo by Hiroshi SHIBATA
GitHub Enterprise with GMO PepaboGitHub Enterprise with GMO Pepabo
GitHub Enterprise with GMO Pepabo
Hiroshi SHIBATA3.9K views
RubyKaigi2015 making robots-with-mruby by yamanekko
RubyKaigi2015 making robots-with-mrubyRubyKaigi2015 making robots-with-mruby
RubyKaigi2015 making robots-with-mruby
yamanekko13K views
The OMR GC talk - Ruby Kaigi 2015 by craig lehmann
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015
craig lehmann13.4K views
成長を加速する minne の技術基盤戦略 by Hiroshi SHIBATA
成長を加速する minne の技術基盤戦略成長を加速する minne の技術基盤戦略
成長を加速する minne の技術基盤戦略
Hiroshi SHIBATA9.4K views
Data Analytics Service Company and Its Ruby Usage by SATOSHI TAGOMORI
Data Analytics Service Company and Its Ruby UsageData Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby Usage
SATOSHI TAGOMORI21K views
Experiments in Sharing Java VM Technology with CRuby by Matthew Gaudet
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
Matthew Gaudet17.7K views
The story of language development by Hiroshi SHIBATA
The story of language developmentThe story of language development
The story of language development
Hiroshi SHIBATA11K views
Logging for Production Systems in The Container Era by Sadayuki Furuhashi
Logging for Production Systems in The Container EraLogging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
Sadayuki Furuhashi1.4K views
Advanced technic for OS upgrading in 3 minutes by Hiroshi SHIBATA
Advanced technic for OS upgrading in 3 minutesAdvanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutes
Hiroshi SHIBATA42K views

Similar to Practical Testing of Ruby Core

Hacking with ruby2ruby by
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
1.4K views60 slides
Toolbox of a Ruby Team by
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
422 views38 slides
Groovy by
GroovyGroovy
GroovyZen Urban
1.1K views35 slides
JRuby hacking guide by
JRuby hacking guideJRuby hacking guide
JRuby hacking guideDavid Calavera
779 views58 slides
The details of CI/CD environment for Ruby by
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for RubyHiroshi SHIBATA
1.1K views39 slides
Practical Chef and Capistrano for Your Rails App by
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
10.7K views40 slides

Similar to Practical Testing of Ruby Core(20)

Hacking with ruby2ruby by Marc Chung
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
Marc Chung1.4K views
Toolbox of a Ruby Team by Arto Artnik
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
Arto Artnik422 views
Groovy by Zen Urban
GroovyGroovy
Groovy
Zen Urban1.1K views
The details of CI/CD environment for Ruby by Hiroshi SHIBATA
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
Hiroshi SHIBATA1.1K views
Practical Chef and Capistrano for Your Rails App by SmartLogic
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
SmartLogic10.7K views
Crafting Beautiful CLI Applications in Ruby by Nikhil Mungel
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
Nikhil Mungel12.7K views
Ruby C extensions at the Ruby drink-up of Sophia, April 2012 by rivierarb
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
rivierarb2.4K views
JavaScript Growing Up by David Padbury
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury14.1K views
Using ngx_lua in UPYUN by Cong Zhang
Using ngx_lua in UPYUNUsing ngx_lua in UPYUN
Using ngx_lua in UPYUN
Cong Zhang13K views
A Recovering Java Developer Learns to Go by Matt Stine
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
Matt Stine13.8K views
JRuby @ Boulder Ruby by Nick Sieger
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder Ruby
Nick Sieger791 views
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DB by Raimonds Simanovskis
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DBWeb aplikāciju izstrāde ar Ruby on Rails un Oracle DB
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DB
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011 by Nick Sieger
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger3.6K views
Railsconf2011 deployment tips_for_slideshare by tomcopeland
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
tomcopeland1.4K views
Introduction to Resque by koshigoe
Introduction to ResqueIntroduction to Resque
Introduction to Resque
koshigoe1.7K views

More from Hiroshi SHIBATA

How resolve Gem dependencies in your code? by
How resolve Gem dependencies in your code?How resolve Gem dependencies in your code?
How resolve Gem dependencies in your code?Hiroshi SHIBATA
40 views50 slides
How resolve Gem dependencies in your code? by
How resolve Gem dependencies in your code?How resolve Gem dependencies in your code?
How resolve Gem dependencies in your code?Hiroshi SHIBATA
15 views54 slides
Ruby コミッターと歩む Ruby を用いたプロダクト開発 by
Ruby コミッターと歩む Ruby を用いたプロダクト開発Ruby コミッターと歩む Ruby を用いたプロダクト開発
Ruby コミッターと歩む Ruby を用いたプロダクト開発Hiroshi SHIBATA
49 views14 slides
Why ANDPAD commit Ruby and RubyKaigi? by
Why ANDPAD commit Ruby and RubyKaigi?Why ANDPAD commit Ruby and RubyKaigi?
Why ANDPAD commit Ruby and RubyKaigi?Hiroshi SHIBATA
220 views17 slides
RailsGirls から始める エンジニアリングはじめの一歩 by
RailsGirls から始める エンジニアリングはじめの一歩RailsGirls から始める エンジニアリングはじめの一歩
RailsGirls から始める エンジニアリングはじめの一歩Hiroshi SHIBATA
846 views16 slides
How to develop the Standard Libraries of Ruby? by
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?Hiroshi SHIBATA
3.6K views25 slides

More from Hiroshi SHIBATA(20)

How resolve Gem dependencies in your code? by Hiroshi SHIBATA
How resolve Gem dependencies in your code?How resolve Gem dependencies in your code?
How resolve Gem dependencies in your code?
Hiroshi SHIBATA40 views
How resolve Gem dependencies in your code? by Hiroshi SHIBATA
How resolve Gem dependencies in your code?How resolve Gem dependencies in your code?
How resolve Gem dependencies in your code?
Hiroshi SHIBATA15 views
Ruby コミッターと歩む Ruby を用いたプロダクト開発 by Hiroshi SHIBATA
Ruby コミッターと歩む Ruby を用いたプロダクト開発Ruby コミッターと歩む Ruby を用いたプロダクト開発
Ruby コミッターと歩む Ruby を用いたプロダクト開発
Hiroshi SHIBATA49 views
Why ANDPAD commit Ruby and RubyKaigi? by Hiroshi SHIBATA
Why ANDPAD commit Ruby and RubyKaigi?Why ANDPAD commit Ruby and RubyKaigi?
Why ANDPAD commit Ruby and RubyKaigi?
Hiroshi SHIBATA220 views
RailsGirls から始める エンジニアリングはじめの一歩 by Hiroshi SHIBATA
RailsGirls から始める エンジニアリングはじめの一歩RailsGirls から始める エンジニアリングはじめの一歩
RailsGirls から始める エンジニアリングはじめの一歩
Hiroshi SHIBATA846 views
How to develop the Standard Libraries of Ruby? by Hiroshi SHIBATA
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
Hiroshi SHIBATA3.6K views
Dependency Resolution with Standard Libraries by Hiroshi SHIBATA
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
Hiroshi SHIBATA803 views
Roadmap for RubyGems 4 and Bundler 3 by Hiroshi SHIBATA
Roadmap for RubyGems 4 and Bundler 3Roadmap for RubyGems 4 and Bundler 3
Roadmap for RubyGems 4 and Bundler 3
Hiroshi SHIBATA794 views
The Future of library dependency management of Ruby by Hiroshi SHIBATA
 The Future of library dependency management of Ruby The Future of library dependency management of Ruby
The Future of library dependency management of Ruby
Hiroshi SHIBATA644 views
The Future of library dependency manageement of Ruby by Hiroshi SHIBATA
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
Hiroshi SHIBATA988 views
The Future of Dependency Management for Ruby by Hiroshi SHIBATA
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
Hiroshi SHIBATA7.4K views
The Future of Bundled Bundler by Hiroshi SHIBATA
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled Bundler
Hiroshi SHIBATA4.7K views
Productive Organization with Ruby by Hiroshi SHIBATA
Productive Organization with RubyProductive Organization with Ruby
Productive Organization with Ruby
Hiroshi SHIBATA545 views

Recently uploaded

DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
110 views21 slides
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...ShapeBlue
128 views20 slides
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueShapeBlue
191 views23 slides
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...ShapeBlue
114 views12 slides
Microsoft Power Platform.pptx by
Microsoft Power Platform.pptxMicrosoft Power Platform.pptx
Microsoft Power Platform.pptxUni Systems S.M.S.A.
74 views38 slides
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...ShapeBlue
120 views62 slides

Recently uploaded(20)

DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue110 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue128 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue191 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue114 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue120 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue by ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue68 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE67 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue113 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue93 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue81 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue121 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue63 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue218 views
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool by ShapeBlue
Extending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPoolExtending KVM Host HA for Non-NFS Storage -  Alex Ivanov - StorPool
Extending KVM Host HA for Non-NFS Storage - Alex Ivanov - StorPool
ShapeBlue56 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10110 views

Practical Testing of Ruby Core

  • 1. Details for language testing Practical Testing of Ruby Core
  • 2. self.introduce => { name: “SHIBATA Hiroshi”, nickname: “hsbt”, title: “Chief engineer at GMO Pepabo, Inc.”, commit_bits: [“ruby”, “rake”, “rubygems”, “rdoc”, “psych”, “syck”, “ruby-build”, “tdiary”, “railsgirls”, “railsgirls-jp”, …], sites: [“hsbt.org”, “ruby-lang.org”, “rubyci.org”, “railsgirls.com”, “railsgirls.jp”], }
  • 5. Our challenges on GMO Pepabo, Inc. Infrastructure as a Code • https://github.com/yaocloud • https://github.com/matsumoto-r/mod_mruby • https://github.com/matsumoto-r/ngx_mruby • https://github.com/matsumoto-r/rcon Productive Development with OSS • https://github.com/pepabo/capistrano-stretcher • https://github.com/pepabo/mackerel-rb • https://github.com/pyama86/malsh • https://github.com/linyows/capistrano-github- releases
  • 6. self.introduce => { name: “SHIBATA Hiroshi”, nickname: “hsbt”, title: “Chief engineer at GMO Pepabo, Inc.”, commit_bits: [“ruby”, “rake”, “rubygems”, “rdoc”, “psych”, “syck”, “ruby-build”, “tdiary”, “railsgirls”, “railsgirls-jp”, …], sites: [“hsbt.org”, “ruby-lang.org”, “rubyci.org”, “railsgirls.com”, “railsgirls.jp”], }
  • 9. Contributing of OSS People say: “Contributing to OSS is easy! Please write some documentation and submit a patch!” You say: “Okay! I will contribute new documentation for Ruby!”
  • 10. Documentation is hard But documentation is hard, I think • No-one knows the true behavior of the Ruby language. • Only Matz knows that. • English is hard (for Japanese) • Documentation is boring work :bow: Because documentation is valuable work.
  • 11. Testing and Running are easy On the other hand, testing and running code is easy. • Ruby has a lot of test ecosystem and libraries. • Bundler and Docker provide an encapsulated environment. If you get test failures, you can submit issue ticket to our tracker. It helps ruby committer. If test coverage is missing for some ruby code, you can also write new tests and submit a patch to upstream.
  • 12. Code reading tips I always start code reading with the following commands I pick out `before_script` and `script` code from .travis.yml and invoke it. For example: $ git clone https://github.com/some/gems $ cd gems $ less .travis.yml $ bundle install $ rake spec $ rake spec:plugins
  • 13. In the case of ruby You will get… $ git clone https://github.com/ruby/ruby $ cd ruby $ less .travis.yml
  • 14. before_script: - "if [[ $TRAVIS_OS_NAME = 'osx' ]]; then rm -f ~/Library/Logs/DiagnosticReports/ruby_*.crash; fi" - "uname -a" - "uname -r" - "rm -fr .ext autom4te.cache" - "make -f common.mk BASERUBY=ruby MAKEDIRS='mkdir -p' srcdir=. update-config_files" - "autoconf" - "mkdir config_1st config_2nd" - "./configure -C --disable-install-doc --with-gcc=$CC $CONFIG_FLAG" - "cp -pr config.status .ext/include config_1st" - "make reconfig" - "cp -pr config.status .ext/include config_2nd" - "diff -ru config_1st config_2nd" - "make after-update BASERUBY=ruby" - "make -s $JOBS encs" - "make -s $JOBS exts" - "make update-rubyspec" - "if [[ $TRAVIS_OS_NAME = 'osx' ]]; then echo 'exclude :test_deadlock_by_signal_at_forking, "under investigation"' >> test/excludes/TestProcess.rb; fi" script: - "make test" - "make test-all TESTOPTS='-q -j2'" - "make test-rubyspec" .travis.yml in ruby/ruby
  • 15. Dive into testing of ruby language
  • 16. Tips for testing ruby You can invoke language tests with the following instructions: $ git clone https://github.com/ruby/ruby $ cd ruby $ autoconf $ ./configure —disable-install-doc $ make -j $ make check
  • 17. % make check (snip) test succeeded PASS all 1010 tests exec ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems "./bootstraptest/ runner.rb" --ruby="ruby --disable-gems" ./KNOWNBUGS.rb 2015-12-04 11:53:44 +0900 Driver is ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15] Target is ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15] KNOWNBUGS.rb PASS 0 No tests, no problem Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" # Running tests: Finished tests in 2.009208s, 109.4959 tests/s, 219.9872 assertions/s. 220 tests, 442 assertions, 0 failures, 0 errors, 0 skips ruby -v: ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15] Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" -- excludes=./test/excludes -x /memory_leak/ -x /testunit/ -x /minitest/ # Running tests: [ 365/15731] Fiddle::TestFunc#test_qsort1
  • 18. common.mk common.mk defines test tasks for the make command • check/check-ruby • btest/btest-ruby • test-sample • test-knownbug • test-testframework • test • test-all • test-almost • test-ruby • test-rubyspec
  • 19. make test make test depends on the following tests • test-sample • invoke `tool/rubytest.rb` with target ruby • rubytest.rb run `sample/test.rb` !!1 • btest-ruby • snip for next slides • test-knownbug • invoke `KNOWNBUGS.rb` • It’s empty a lot of the time.
  • 20. `cat sample/test.rb` a, = nil; test_ok(a == nil) a, = 1; test_ok(a == 1) a, = []; test_ok(a == nil) (snip) def r; return *[]; end; a = r(); test_ok(a == []) def r; return *[1]; end; a = r(); test_ok(a == [1]) def r; return *[nil]; end; a = r(); test_ok(a == [nil]) (snip) f = lambda { |a, b=42, *c| [a,b,c] } test_ok(f.call(1 ) == [1,42,[ ]] ) test_ok(f.call(1,43 ) == [1,43,[ ]] ) test_ok(f.call(1,43,44) == [1,43,[44]] ) (snip)
  • 21. make btest-ruby btest-ruby invokes test files with the ruby binary and `bootstraptest/runner.rb` under the `bootstraptest` directory. What’s `bootstraptest/runner.rb` ? • load test files and invoke them • define assertion methods like `assert_equal` etc. % ls bootstraptest pending.rb runner.rb* test_attr.rb test_autoload.rb test_block.rb test_class.rb test_eval.rb test_exception.rb test_finalizer.rb test_flip.rb test_flow.rb test_fork.rb test_gc.rb test_io.rb test_jump.rb test_literal.rb test_literal_suffix.rb test_load.rb test_marshal.rb test_massign.rb test_method.rb test_objectspace.rb test_proc.rb test_string.rb test_struct.rb test_syntax.rb test_thread.rb
  • 22. `cat bootstraptest/test_class.rb` assert_equal 'true', %q( class C; end Object.const_defined?(:C) ) assert_equal 'Class', %q( class C; end C.class ) (snip) assert_equal 'Class', %q( class A; end class C < A; end C.class ) (snip) assert_equal 'M', %q( module M; end M.name ) (snip) assert_equal 'A::B', %q( class A; end class A::B; end A::B )
  • 23. make test-all test-all invokes test files under the `test` directory. These test files contain core libraries like String and Array and stdlib like Webrick and Logger. This task is a good one for a typical contributor. test-all has some options for testing: • make test-all TESTS=logger • test only files under `test/logger` • make test-all TESTS=“-j4” • it make parallel execution with 4 processes.
  • 24. cat `test/ruby/test_array.rb` % cat test/ruby/test_array.rb # coding: US-ASCII require 'test/unit' class TestArray < Test::Unit::TestCase (snip) def test_percent_i assert_equal([:foo, :bar], %i[foo bar]) assert_equal([:""foo"], %i["foo]) end def test_0_literal assert_equal([1, 2, 3, 4], [1, 2] + [3, 4]) assert_equal([1, 2, 1, 2], [1, 2] * 2) assert_equal("1:2", [1, 2] * ":") (snip)
  • 25. cat `test/-ext-/array/test_resize.rb` require 'test/unit' require '-test-/array/resize' class TestArray < Test::Unit::TestCase class TestResize < Test::Unit::TestCase def test_expand feature = '[ruby-dev:42912]' ary = [*1..10] ary.__resize__(10) assert_equal(10, ary.size, feature) assert_equal([*1..10], ary, feature) ary.__resize__(100) assert_equal(100, ary.size, feature) (snip) % cat ext/-test-/array/resize/resize.c #include "ruby/ruby.h" static VALUE ary_resize(VALUE ary, VALUE len) { rb_ary_resize(ary, NUM2LONG(len)); return ary; } void Init_resize(void) { rb_define_method(rb_cArray, "__resize__", ary_resize, 1); }
  • 26. cat `test/logger/test_logger.rb` % cat test/logger/test_logger.rb # coding: US-ASCII require 'test/unit' require 'logger' require 'tempfile' class TestLogger < Test::Unit::TestCase (snip) def test_add logger = Logger.new(nil) logger.progname = "my_progname" assert(logger.add(INFO)) log = log_add(logger, nil, "msg") assert_equal("ANY", log.severity) assert_equal("my_progname", log.progname) (snip)
  • 27. make check make check depends on the following definitions: • main • build encodings and extensions. • test • (snip) • test-testframework • run tests for `testunit` and `minitest` • test-almost • run tests under `test` excluding `testunit` and `minitest` make check runs all test tasks in CRuby
  • 28. make testframework-test/test-almost I separated test files testunit and minitest from test-all. Why does CRuby have test files for testunit and minitest? • CRuby Forked test-unit and minitest • CRuby added parallel execution function to test-unit We need to invoke to test to test-framework before CAPI, core library and standard library. test-almost invokes tests under `test` without test-unit and minitest.
  • 30. Why separated the test framework? The following libraries uses minitest directly in Ruby 2.3: • rubygems • rdoc • net-smtp (It seems unnecessary) Other libraries uses test-unit. rubygems and rdoc are developed at github.com/rubygems/rubygems and github.com/rdoc/rdoc. We need to support these libraries and their tests.
  • 31. How to merge upstream from others I merged upstream into ruby/ruby periodically using following instructions. ruby and rubygems guarantee to work to test and code each other. it’s the same situation for ruby and rdoc $ git clone https://github.com/ruby/ruby $ git clone https://github.com/rubygems/rubygems $ cd ruby $ rm -rf lib/rubygems test/rubygtems lib/rubygems.rb $ cp -rf ../../rubygems/rubygems/lib/rubygems ./lib $ cp -rf ../../rubygems/rubygems/lib/rubygems.rb ./lib $ cp -rf ../../rubygems/rubygems/test/rubygems ./test $ git checkout lib/rubygems/LICENSE.txt
  • 32. backporting is hard rubygems and rdoc still support Ruby 1.8. % g show a34fb569e41cd87866e644d92a9df4be89b3cad2 test/rubygems/test_gem_package.rb commit a34fb569e41cd87866e644d92a9df4be89b3cad2 Author: Eric Hodel <drbrain@segment7.net> Date: Tue Jul 8 16:53:50 2014 -0700 Fix tests on ruby 1.8 diff --git test/rubygems/test_gem_package.rb test/rubygems/test_gem_package.rb index f07c083..128dcdb 100644 --- test/rubygems/test_gem_package.rb +++ test/rubygems/test_gem_package.rb @@ -638,7 +638,7 @@ class TestGemPackage < Gem::Package::TarTestCase e.message io end - tf.close! + tf.close! if tf.respond_to? :close! end def test_verify_empty
  • 33. Forked code for Test::Unit • test/lib/envutil.rb • some assertion and function for language testing • leakchecker.rb • checker for memory and fd leak. • test/lib/test/lib/parallel.rb • helper library parallel execution for test- case
  • 35. RubySpec Q. What’s rubyspec? A. RubySpec is an executable specification for the Ruby programming language. “Matz's Ruby Developers Don't Use RubySpec and It's Hurting Ruby” http://rubini.us/2014/12/31/matz-s-ruby-developers-don-t-use-rubyspec/ rubyspec is not a “specification”. It’s actually a set of “test”. The only real ruby specification is inside of Matz :)
  • 36. make test-rubyspec CRuby has `make update-rubyspec` and `make test- rubyspec` tasks. `make update-rubyspec` pulls ruby/rubyspec and ruby/ mspec into the spec directory. `make test-rubyspec` invokes mspec with the ruby binary and the latest rubyspecs.
  • 37. cat spec/rubyspec/core/string/append_spec.rb require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/concat', __FILE__) describe "String#<<" do it_behaves_like :string_concat, :<< it_behaves_like :string_concat_encoding, :<< end % cat spec/rubyspec/core/string/shared/concat.rb describe :string_concat, shared: true do it "concatenates the given argument to self and returns self" do str = 'hello ' str.send(@method, 'world').should equal(str) str.should == "hello world" end (snip)
  • 38. rubyspec and mspec We approved new or updated examples at github.com/ ruby/rubyspec. @headius wrote: “So nice to see RubySpec getting a steady stream of Ruby 2.3 specs.” https://twitter.com/headius/status/667793518098673664 A lot of contributors submitted new specs for Ruby 2.3 features.
  • 40. rubyci and chkbuild Ruby CI is a CI results collector for alternative platforms: https://github.com/nurse/rubyci ruby ci uses chkbuild built by akr: https://github.com/akr/chkbuild
  • 42. How to add a new server You can add your server to rubyci.org Requirements: • not yet supported platforms. • ex. linux with ARM, *BSD, icc with OSX, Windows • periodically running every day • It must be possible to access to AWS S3 You should check the following commands on your server $ git clone https://github.com/akr/chkbuild $ cd chkbuild $ ruby start-build
  • 44. make run/bisect `make run` invokes the `test.rb` file on ruby source directory. ko1 said this task helped with YARV development. `make bisect` invokes `make run` with git-bisect. It helps detect commits containing defects. but it’s only useful for a single ruby file. we need to invoke git-bisect under the bundler environment. that’s very difficult.
  • 45. test coverage I added a coverage task using simplecov You can get coverage results for `webrick` under the coverage directory. % make update-coverage updating simplecov ... remote: Counting objects: 90, done. (snip) updating simplecov-html ... updating doclie … % COVERAGE=1 make test-all TESTS=webrick
  • 47. % COVERAGE=1 make test-all CC = clang (snip) Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" --excludes=./test/excludes -x /memory_leak/ # Running tests: [ 3491/15951] TestCoverage#test_big_code = 0.17 s 1) Failure: TestCoverage#test_big_code [/path/to/ruby/test/lib/tracepointchecker.rb:18]: The number of active trace events was changed. <[[#<RubyVM:0x000001017c3588>, 1]]> expected but was <[[#<RubyVM:0x000001017c3588>, 0]]>. /path/to/ruby/test/lib/leakchecker.rb:116: [BUG] Segmentation fault at 0x00000000000000 ruby 2.3.0dev (2015-12-03 trunk 52872) [x86_64-darwin15] Limitation of test coverage We have some defects related to the “Coverage” library.
  • 49. Plan for Ruby 2.4/3.0 • Restructured test directories and files • Separated test focus • Removed duplicate tests • Simplify test tasks • stdlib tests more friendly with JRuby • Increase coverage • Integrate rubyspec and ruby tests
  • 50. Please contribute tests to ruby You can invoke CRuby tests: You can invoke focused tests with coverage: You can code new tests or update existing tests. and submit patches to our tracker or github.com/ruby/ruby. $ git clone https://github.com/ruby/ruby $ cd ruby $ autoconf $ ./configure —disable-install-doc $ make -j $ make check $ COVERAGE=1 make test-all TESTS=“logger” $ open coverage/index.html
  • 51. Ruby testing is so easy