Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make jrubyc test clean up after itself.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5943 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 4494fdbd6eda41bb691b7825ee2eed5e5bb2dcef 1 parent d2e6700
@headius headius authored
Showing with 27 additions and 35 deletions.
  1. +27 −35 test/compiler/test_jrubyc.rb
View
62 test/compiler/test_jrubyc.rb
@@ -1,6 +1,7 @@
require 'test/unit'
require 'stringio'
require 'tempfile'
+require 'fileutils'
require 'java'
require 'jruby/jrubyc'
@@ -13,6 +14,7 @@ def setup
end
def teardown
+ FileUtils.rm_rf(["foo", "ruby"])
$stdout.reopen(@old_stdout)
end
@@ -32,18 +34,16 @@ def test_basic
end
def test_target
- begin
- JRubyCompiler::compile_argv(["-t", File.dirname(@tempfile.path), __FILE__])
- output = File.read(@tempfile.path)
+ tempdir = File.dirname(@tempfile.path)
+ JRubyCompiler::compile_argv(["-t", tempdir, __FILE__])
+ output = File.read(@tempfile.path)
- assert_equal(
- "Compiling #{__FILE__} to class ruby/test/compiler/test_jrubyc\n",
- output)
+ assert_equal(
+ "Compiling #{__FILE__} to class ruby/test/compiler/test_jrubyc\n",
+ output)
- assert(File.exist?("ruby/test/compiler/test_jrubyc.class"))
- ensure
- File.delete("ruby") rescue nil
- end
+ assert(File.exist?(tempdir + "/ruby/test/compiler/test_jrubyc.class"))
+ FileUtils.rm_rf(tempdir + "/ruby")
end
def test_bad_target
@@ -59,38 +59,30 @@ def test_bad_target
end
def test_prefix
- begin
- JRubyCompiler::compile_argv(["-p", "foo", __FILE__])
- output = File.read(@tempfile.path)
+ JRubyCompiler::compile_argv(["-p", "foo", __FILE__])
+ output = File.read(@tempfile.path)
- assert_equal(
- "Compiling #{__FILE__} to class foo/test/compiler/test_jrubyc\n",
- output)
+ assert_equal(
+ "Compiling #{__FILE__} to class foo/test/compiler/test_jrubyc\n",
+ output)
- assert(File.exist?("foo/test/compiler/test_jrubyc.class"))
- ensure
- File.delete("ruby") rescue nil
- end
+ assert(File.exist?("foo/test/compiler/test_jrubyc.class"))
end
def test_require
$compile_test = false
File.open("test_file1.rb", "w") {|file| file.write("$compile_test = true")}
- begin
- JRubyCompiler::compile_argv(["test_file1.rb"])
- output = File.read(@tempfile.path)
-
- assert_equal(
- "Compiling test_file1.rb to class ruby/test_file1\n",
- output)
-
- File.delete("test_file1.rb")
-
- assert_nothing_raised { require 'ruby/test_file1' }
- assert($compile_test)
- ensure
- File.delete("ruby") rescue nil
- end
+ JRubyCompiler::compile_argv(["test_file1.rb"])
+ output = File.read(@tempfile.path)
+
+ assert_equal(
+ "Compiling test_file1.rb to class ruby/test_file1\n",
+ output)
+
+ File.delete("test_file1.rb")
+
+ assert_nothing_raised { require 'ruby/test_file1' }
+ assert($compile_test)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.