1c7358aaf8
Closes #49115. Signed-off-by: FX Coudert <fxcoudert@gmail.com>
61 lines
1.7 KiB
Ruby
61 lines
1.7 KiB
Ruby
class Byteman < Formula
|
|
desc "Java bytecode manipulation tool for testing, monitoring and tracing"
|
|
homepage "https://byteman.jboss.org/"
|
|
url "https://downloads.jboss.org/byteman/4.0.10/byteman-download-4.0.10-bin.zip"
|
|
sha256 "068cf4752688e0c154daa476c1a26d10cb8f90252e380862f44d3bb79781cc2e"
|
|
|
|
bottle :unneeded
|
|
depends_on :java => "1.6+"
|
|
|
|
def install
|
|
rm_rf Dir["bin/*.bat"]
|
|
doc.install Dir["docs/*"], "README"
|
|
libexec.install ["bin", "lib", "contrib"]
|
|
pkgshare.install ["sample"]
|
|
|
|
env = Language::Java.java_home_env("1.6+").merge(:BYTEMAN_HOME => libexec)
|
|
Pathname.glob("#{libexec}/bin/*") do |file|
|
|
target = bin/File.basename(file, File.extname(file))
|
|
# Drop the .sh from the scripts
|
|
target.write_env_script(libexec/"bin/#{File.basename(file)}", env)
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"src/main/java/BytemanHello.java").write <<~EOS
|
|
class BytemanHello {
|
|
public static void main(String... args) {
|
|
System.out.println("Hello, Brew!");
|
|
}
|
|
}
|
|
EOS
|
|
|
|
(testpath/"brew.btm").write <<~EOS
|
|
RULE trace main entry
|
|
CLASS BytemanHello
|
|
METHOD main
|
|
AT ENTRY
|
|
IF true
|
|
DO traceln("Entering main")
|
|
ENDRULE
|
|
|
|
RULE trace main exit
|
|
CLASS BytemanHello
|
|
METHOD main
|
|
AT EXIT
|
|
IF true
|
|
DO traceln("Exiting main")
|
|
ENDRULE
|
|
EOS
|
|
# Compile example
|
|
system "javac", "src/main/java/BytemanHello.java"
|
|
# Expected successful output when Byteman runs example
|
|
expected = <<~EOS
|
|
Entering main
|
|
Hello, Brew!
|
|
Exiting main
|
|
EOS
|
|
actual = shell_output("#{bin}/bmjava -l brew.btm -cp src/main/java BytemanHello")
|
|
assert_equal(expected, actual)
|
|
end
|
|
end
|