From kou at cozmixng.org Sat Aug 1 06:49:40 2009 From: kou at cozmixng.org (Kouhei Sutou) Date: Sat, 01 Aug 2009 19:49:40 +0900 (JST) Subject: [test-unit-users-en:00005] Re: Rogue character with 1.9 and -v? In-Reply-To: <000601ca1165$b8869fc0$2993df40$@com> References: <000601ca1165$b8869fc0$2993df40$@com> Message-ID: <20090801.194940.1059810900265074718.kou@cozmixng.org> Hi, In <000601ca1165$b8869fc0$2993df40$@com> "[test-unit-users-en:00004] Rogue character with 1.9 and -v?" on Thu, 30 Jul 2009 16:33:09 -0600, "Daniel Berger" wrote: > Hi, > > I noticed the output is slightly different in verbose mode between 1.8 and > 1.9: 1.8 bundles test-unit but 1.9 bundles minitest and test-unit compatible layer above on minitest. > I see that 1.9 includes the class name - that's fine. But what are those 's' > characters at the end of each line? I can also find class name in 1.8. 's' may means 'seconds'. Thanks, -- kou From djberg96 at gmail.com Wed Aug 19 09:41:56 2009 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 19 Aug 2009 07:41:56 -0600 Subject: [test-unit-users-en:00006] Having a problem with startup, shutdown, rake, class variables Message-ID: <4A8C0124.9010108@gmail.com> Hi, test-unit 2.0.3 I have two test files that look like this: # test/test_foo_alpha.rb require 'rubygems' gem 'test-unit' require 'foo' require 'test/unit' class TC_Foo_Alpha < Test::Unit::TestCase def self.startup Dir.chdir(File.expand_path(File.dirname(__FILE__))) @@file = File.join(Dir.pwd, 'alpha.txt') File.open(@@file, 'w'){ |fh| fh.puts "alpha" } end def test_foo_alpha assert_nothing_raised{ Foo.new } end def self.shutdown File.delete(@@file) if File.exists?(@@file) @@file = nil end end # test/test_foo_beta.rb require 'rubygems' gem 'test-unit' require 'foo' require 'test/unit' class TC_Foo_Beta < Test::Unit::TestCase def self.startup Dir.chdir(File.expand_path(File.dirname(__FILE__))) @@file = File.join(Dir.pwd, 'beta.txt') File.open(@@file, 'w'){ |fh| fh.puts "beta" } end def test_foo_beta assert_nothing_raised{ Foo.new } end def self.shutdown File.delete(@@file) if File.exists?(@@file) @@file = nil end end And I have a simple Rakefile: # Rakefile require 'rake' require 'rake/testtask' Rake::TestTask.new do |t| t.warning = true t.verbose = true end Obviously this assumes the existence of lib/foo.rb, which can be just a basic class. Anyway, when I run the tests individually they work fine. But if I try to run them as part of the Rake task I get these errors: 1) Error: TC_Foo_Beta: Errno::ENOENT: No such file or directory - /Users/djberge/Documents/workspace/foo/test/test ./test/test_foo_beta.rb:9:in `chdir' ./test/test_foo_beta.rb:9:in `startup' 2) Error: TC_Foo_Beta: NameError: uninitialized class variable @@file in TC_Foo_Beta ./test/test_foo_beta.rb:19:in `shutdown' 2 tests, 2 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 notifications What's happening here? I'm very confused. Regards, Dan From djberg96 at gmail.com Thu Aug 20 00:29:58 2009 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 19 Aug 2009 22:29:58 -0600 Subject: [test-unit-users-en:00007] Re: Having a problem with startup, shutdown, rake, class variables Message-ID: <004401ca214e$e1d2e160$a578a420$@com> Disregard, it looks like it was a relative path mistake on my part with regards to __FILE__. My call to Dir.chdir should have been: Dir.chdir(File.dirname(File.expand_path(File.basename(__FILE__)))) Regards, Dan