Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/ruby | ||
require 'test/unit' | ||
require 'javac.rb' | ||
|
||
class | ||
Javac < Test::Unit::TestCase | ||
def test_windows_javac_cmd_one_input | ||
expected = "c:\\\\test.java" | ||
actual = windows_javac_args("/cygdrive/c/test.java".split) | ||
assert_equal(expected.split, actual) | ||
end | ||
|
||
def test_windows_javac_cmd_two_inputs | ||
expected = "c:\\\\test.java c:\\\\test2.java" | ||
actual = windows_javac_args("/cygdrive/c/test.java /cygdrive/c/test2.java".split) | ||
assert_equal(expected.split, actual) | ||
end | ||
|
||
def test_windows_javac_cmd_options | ||
expected = "-classpath c:\\\\classpath" | ||
actual = windows_javac_args("-classpath /cygdrive/c/classpath".split) | ||
assert_equal(expected.split, actual) | ||
end | ||
|
||
def test_windows_javac_cmd_slash | ||
expected = "wrappers\\\\hello.java" | ||
actual = windows_javac_args("./wrappers/hello.java") | ||
assert_equal(expected.split, actual) | ||
end | ||
|
||
def test_find_javac | ||
expected = "/cygdrive/c/Program Files/Java/jdk1.6.0_13/bin/javac.exe" | ||
actual = javac_path() | ||
assert_equal(expected, actual) | ||
end | ||
|
||
def test_javac_command | ||
expected = '"/cygdrive/c/Program Files/Java/jdk1.6.0_13/bin/javac.exe" 1.java 2.java' | ||
actual = windows_javac_command(["1.java", "2.java"]) | ||
assert_equal(expected, actual) | ||
end | ||
|
||
def test_to_winPathList | ||
expected="c:\\home;c:\\java" | ||
actual = to_winPathList("/cygdrive/c/home:/cygdrive/c/java") | ||
assert_equal(expected, actual) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/ruby | ||
require 'paths.rb' | ||
|
||
|
||
def windows_javac_args(unixARGV) | ||
unixARGV.map do | arg | | ||
if arg[0] != '-'[0] | ||
#need to escape slashes or javac swallows them | ||
to_winPath(arg).sub(/\\/,"\\\\\\") | ||
else | ||
#options like '-d' aren't paths, so don't convert them | ||
arg | ||
end | ||
end | ||
end | ||
|
||
def javac_path | ||
javacName = "javac.exe" | ||
javaPath = ENV["JAVA_HOME"] | ||
IO.popen("find \"#{javaPath}\" -name #{javacName}").readlines[0].chomp | ||
end | ||
|
||
def windows_javac_command(unixARGV) | ||
'"' << javac_path << '" ' << windows_javac_args(unixARGV).join(" ") | ||
end | ||
|
||
if __FILE__ == $0 | ||
ENV["CLASSPATH"] = to_winPathList(ENV["CLASSPATH"]) | ||
|
||
javac = IO.popen(windows_javac_command(ARGV)) | ||
|
||
#wait for javac to finish before exitting | ||
#and echo the input | ||
puts javac.readlines | ||
end |