ruby-changes:26319
From: naruse <ko1@a...>
Date: Fri, 14 Dec 2012 10:39:56 +0900 (JST)
Subject: [ruby-changes:26319] naruse:r38369 (trunk): * test/ruby/envutil.rb (EnvUtil::Unit::Assertionsassert_separately):
naruse 2012-12-14 10:38:07 +0900 (Fri, 14 Dec 2012) New Revision: 38369 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38369 Log: * test/ruby/envutil.rb (EnvUtil::Unit::Assertionsassert_separately): added to execute given test source on separate process, catch its resulted exception and raise it on main process. Modified files: trunk/ChangeLog trunk/test/ruby/envutil.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38368) +++ ChangeLog (revision 38369) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Dec 14 04:08:05 2012 NARUSE, Yui <naruse@r...> + + * test/ruby/envutil.rb (EnvUtil::Unit::Assertionsassert_separately): + added to execute given test source on separate process, + catch its resulted exception and raise it on main process. + Fri Dec 14 07:43:44 2012 Aaron Patterson <aaron@t...> * ext/psych/lib/psych/visitors/yaml_tree.rb: quote strings that begin Index: test/ruby/envutil.rb =================================================================== --- test/ruby/envutil.rb (revision 38368) +++ test/ruby/envutil.rb (revision 38369) @@ -193,6 +193,23 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L193 assert(status.success?, m) end + def assert_separately(args, file, line, src) + opt = {} + src = <<eom + require 'test/unit';include Test::Unit::Assertions;begin;#{src} + ensure + print [Marshal.dump($!)].pack('m') + end +eom + stdout, _stderr, _status = EnvUtil.invoke_ruby(args, src, true, true, opt) + res = Marshal.load(stdout.unpack("m")[0]) + return unless res + res.backtrace.each do |l| + l.sub!(/\A-:(\d+)/){"#{file}:#{line + $1.to_i}"} + end + raise res + end + def assert_warning(pat, message = nil) stderr = EnvUtil.verbose_warning { yield } message = ' "' + message + '"' if message -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/