Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (45 sloc) 1.988 kB
2b043ce @nicksieger JRUBY-1315 shell launching/arg processing fixed on trunk
nicksieger authored
1 require 'test/unit'
2
3 class TestJRubyInternals < Test::Unit::TestCase
4 def setup
5 @dir = File.join(Dir.pwd, "dir with spaces")
6 @file = File.join(@dir, "test_file")
7 Dir.mkdir(@dir)
8 File.open(@file, "w") {|f| f << "hello"}
9 end
10
11 def teardown
12 File.unlink @file
13 Dir.rmdir @dir
14 end
15
16 def test_smart_split_paths
17 require 'jruby/path_helper'
18 assert_equal %w(foo bar blah),
19 JRuby::PathHelper.smart_split_command("foo bar blah")
20 assert_equal [@file, *(%w{foo bar blah})],
21 JRuby::PathHelper.smart_split_command("#@file foo bar blah")
22 end
23
24 def test_split_command_around_quotes
25 assert_equal %w(foo bar baz quux),
26 JRuby::PathHelper.quote_sensitive_split(%{foo bar baz quux})
27 assert_equal ["foo", "bar baz", "quux"],
28 JRuby::PathHelper.quote_sensitive_split(%{foo "bar baz" quux})
29 assert_equal ["foo", "bar \" baz", "quux"],
30 JRuby::PathHelper.quote_sensitive_split(%{foo "bar \\\" baz" quux})
31 assert_equal ["foo", "bar baz", "quux"],
32 JRuby::PathHelper.quote_sensitive_split(%{"foo" "bar baz" quux})
33 assert_equal ["foo", "bar \" baz", "quux"],
34 JRuby::PathHelper.quote_sensitive_split(%{"foo" 'bar " baz' quux})
35 end
36
37 def test_split_typical_ruby_command_line
38 assert_equal ["ruby", "-e", "require 'java'; puts java.lang.System.getProperty('java.class.path')"],
39 JRuby::PathHelper.quote_sensitive_split(
40 "ruby -e \"require 'java'; puts java.lang.System.getProperty('java.class.path')\""
41 )
42 end
43
44 def test_unquoted_executable_with_quoted_args
45 cmd = "#@file -Ilib;test \"C:/Projects/space name/jruby-1_0/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb\" \"test/functional/hello_controller_test.rb\""
46 assert_equal [@file, "-Ilib;test",
47 "C:/Projects/space name/jruby-1_0/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb",
48 "test/functional/hello_controller_test.rb"],
49 JRuby::PathHelper.smart_split_command(cmd)
50 end
51 end
Something went wrong with that request. Please try again.