Pino Toscano
2016-Feb-23 10:51 UTC
[Libguestfs] [PATCH 1/2] Revert "ruby: Run tests one at a time, instead of in parallel."
It seems the default behaviour of rake is to run tests sequentially, and not in parallel (there are separate gems to achieve that behaviour). Hence just invoke "rake test" to run all the available tests at once. This reverts commit 8f30c3c3f8c063f7c5ff8c6154d881e07a820251. --- ruby/run-ruby-tests | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ruby/run-ruby-tests b/ruby/run-ruby-tests index ac18ea3..d69e9ea 100755 --- a/ruby/run-ruby-tests +++ b/ruby/run-ruby-tests @@ -18,10 +18,4 @@ set -e -# Run them one at a time, otherwise rake runs them in parallel (which -# is bound to fail because they all use a single test image file). - -for f in t/tc_*.rb; do - echo $RAKE test "$@" TEST="$f" - $RAKE test "$@" TEST="$f" -done +$RAKE test "$@" -- 2.5.0
Pino Toscano
2016-Feb-23 10:51 UTC
[Libguestfs] [PATCH 2/2] ruby: tests: use more asserts instead of manual checks
Make more use of assert_equal/refute_equal instead of manually checking values and raising errors. --- ruby/t/tc_100_launch.rb | 4 +--- ruby/t/tc_410_close_event.rb | 8 ++------ ruby/t/tc_420_log_messages.rb | 4 +--- ruby/t/tc_810_rhbz664558c6.rb | 4 +--- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/ruby/t/tc_100_launch.rb b/ruby/t/tc_100_launch.rb index 9c31aa5..b79b984 100644 --- a/ruby/t/tc_100_launch.rb +++ b/ruby/t/tc_100_launch.rb @@ -30,9 +30,7 @@ class TestLoad < MiniTest::Unit::TestCase g.lvcreate("LV2", "VG", 200); lvs = g.lvs() - if lvs != ["/dev/VG/LV1", "/dev/VG/LV2"] - raise "incorrect lvs returned" - end + assert_equal ["/dev/VG/LV1", "/dev/VG/LV2"], lvs g.sync() end diff --git a/ruby/t/tc_410_close_event.rb b/ruby/t/tc_410_close_event.rb index c547613..be62b91 100644 --- a/ruby/t/tc_410_close_event.rb +++ b/ruby/t/tc_410_close_event.rb @@ -29,12 +29,8 @@ class TestLoad < MiniTest::Unit::TestCase # Check that the close event is called. g.set_event_callback(close, Guestfs::EVENT_CLOSE) - if close_invoked != 0 - raise "close_invoked should be 0" - end + assert_equal 0, close_invoked g.close() - if close_invoked != 1 - raise "close_invoked should be 1" - end + assert_equal 1, close_invoked end end diff --git a/ruby/t/tc_420_log_messages.rb b/ruby/t/tc_420_log_messages.rb index 90a1360..e64ea74 100644 --- a/ruby/t/tc_420_log_messages.rb +++ b/ruby/t/tc_420_log_messages.rb @@ -45,8 +45,6 @@ class TestLoad < MiniTest::Unit::TestCase g.set_autosync(1) g.close() - if log_invoked == 0 - raise "log_invoked should be > 0" - end + refute_equal 0, log_invoked end end diff --git a/ruby/t/tc_810_rhbz664558c6.rb b/ruby/t/tc_810_rhbz664558c6.rb index 7e27db2..347e403 100644 --- a/ruby/t/tc_810_rhbz664558c6.rb +++ b/ruby/t/tc_810_rhbz664558c6.rb @@ -38,8 +38,6 @@ class TestLoad < MiniTest::Unit::TestCase # This should call the close callback. g.close() - if close_invoked != 1 - raise "close_invoked should be 1" - end + assert_equal 1, close_invoked end end -- 2.5.0
Richard W.M. Jones
2016-Feb-23 10:54 UTC
Re: [Libguestfs] [PATCH 2/2] ruby: tests: use more asserts instead of manual checks
On Tue, Feb 23, 2016 at 11:51:51AM +0100, Pino Toscano wrote:> Make more use of assert_equal/refute_equal instead of manually checking > values and raising errors. > --- > ruby/t/tc_100_launch.rb | 4 +--- > ruby/t/tc_410_close_event.rb | 8 ++------ > ruby/t/tc_420_log_messages.rb | 4 +--- > ruby/t/tc_810_rhbz664558c6.rb | 4 +--- > 4 files changed, 5 insertions(+), 15 deletions(-) > > diff --git a/ruby/t/tc_100_launch.rb b/ruby/t/tc_100_launch.rb > index 9c31aa5..b79b984 100644 > --- a/ruby/t/tc_100_launch.rb > +++ b/ruby/t/tc_100_launch.rb > @@ -30,9 +30,7 @@ class TestLoad < MiniTest::Unit::TestCase > g.lvcreate("LV2", "VG", 200); > > lvs = g.lvs() > - if lvs != ["/dev/VG/LV1", "/dev/VG/LV2"] > - raise "incorrect lvs returned" > - end > + assert_equal ["/dev/VG/LV1", "/dev/VG/LV2"], lvs > > g.sync() > end > diff --git a/ruby/t/tc_410_close_event.rb b/ruby/t/tc_410_close_event.rb > index c547613..be62b91 100644 > --- a/ruby/t/tc_410_close_event.rb > +++ b/ruby/t/tc_410_close_event.rb > @@ -29,12 +29,8 @@ class TestLoad < MiniTest::Unit::TestCase > # Check that the close event is called. > g.set_event_callback(close, Guestfs::EVENT_CLOSE) > > - if close_invoked != 0 > - raise "close_invoked should be 0" > - end > + assert_equal 0, close_invoked > g.close() > - if close_invoked != 1 > - raise "close_invoked should be 1" > - end > + assert_equal 1, close_invoked > end > end > diff --git a/ruby/t/tc_420_log_messages.rb b/ruby/t/tc_420_log_messages.rb > index 90a1360..e64ea74 100644 > --- a/ruby/t/tc_420_log_messages.rb > +++ b/ruby/t/tc_420_log_messages.rb > @@ -45,8 +45,6 @@ class TestLoad < MiniTest::Unit::TestCase > g.set_autosync(1) > > g.close() > - if log_invoked == 0 > - raise "log_invoked should be > 0" > - end > + refute_equal 0, log_invoked > end > end > diff --git a/ruby/t/tc_810_rhbz664558c6.rb b/ruby/t/tc_810_rhbz664558c6.rb > index 7e27db2..347e403 100644 > --- a/ruby/t/tc_810_rhbz664558c6.rb > +++ b/ruby/t/tc_810_rhbz664558c6.rb > @@ -38,8 +38,6 @@ class TestLoad < MiniTest::Unit::TestCase > # This should call the close callback. > g.close() > > - if close_invoked != 1 > - raise "close_invoked should be 1" > - end > + assert_equal 1, close_invoked > end > end > -- > 2.5.0ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Maybe Matching Threads
- [PATCH 1/2] ruby: Print exceptions thrown by event callbacks.
- [PATCH 2/2] ruby: tests: use more asserts instead of manual checks
- [PATCH 2/2] ruby: tests: Give each test class and method a unique name.
- Re: [PATCH 2/2] ruby: tests: Give each test class and method a unique name.
- [PATCH] ruby: Fix .new method (RHBZ#1046509).