зеркало из https://github.com/github/ruby.git
* test/ruby/test_system.rb (test_syntax): unified with test_syntax2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
16923c25a1
Коммит
c5de4d4cbd
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Jul 4 22:02:02 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* test/ruby/test_system.rb (test_syntax): unified with test_syntax2.
|
||||||
|
|
||||||
Sun Jul 4 21:00:39 2010 Tanaka Akira <akr@fsij.org>
|
Sun Jul 4 21:00:39 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* test/ruby/test_system.rb (test_syntax2): moved from sample/test.rb
|
* test/ruby/test_system.rb (test_syntax2): moved from sample/test.rb
|
||||||
|
|
|
@ -14,19 +14,6 @@ class TestSystem < Test::Unit::TestCase
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_syntax2?(code, fname)
|
|
||||||
p fname
|
|
||||||
code = code.dup.force_encoding("ascii-8bit")
|
|
||||||
code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
|
|
||||||
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
|
||||||
}
|
|
||||||
code.force_encoding("us-ascii")
|
|
||||||
catch {|tag| eval(code, binding, fname, 0)}
|
|
||||||
rescue Exception
|
|
||||||
STDERR.puts $!.message
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_system
|
def test_system
|
||||||
ruby = EnvUtil.rubybin
|
ruby = EnvUtil.rubybin
|
||||||
assert_equal("foobar\n", `echo foobar`)
|
assert_equal("foobar\n", `echo foobar`)
|
||||||
|
@ -114,22 +101,8 @@ class TestSystem < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_syntax
|
def test_syntax
|
||||||
assert_nothing_raised(Exception) do
|
assert_nothing_raised(Exception) do
|
||||||
for script in Dir[File.expand_path("../../../{lib,sample,ext}/**/*.rb", __FILE__)]
|
for script in Dir[File.expand_path("../../../{lib,sample,ext,test}/**/*.rb", __FILE__)].sort
|
||||||
valid_syntax? IO::read(script), script
|
assert(valid_syntax?(IO::read(script), script))
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_syntax2
|
|
||||||
if (dir = File.dirname(File.dirname(File.dirname(__FILE__)))) == '.'
|
|
||||||
dir = ""
|
|
||||||
else
|
|
||||||
dir << "/"
|
|
||||||
end
|
|
||||||
for script in Dir["#{dir}{lib,sample,ext,test}/**/*.rb"].sort
|
|
||||||
unless valid_syntax2? IO::read(script), script
|
|
||||||
STDERR.puts script
|
|
||||||
flunk("syntax error: #{script}")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче