Skip to content

Instantly share code, notes, and snippets.

@dambrisco
Last active Aug 29, 2015
Embed
What would you like to do?
infer.rb
class Infer < Formula
desc "Infer is a static analysis tool that can analyze Java, Obj-C, and C"
homepage "https://fbinfer.com/"
url "https://github.com/facebook/infer/archive/v0.1.0.tar.gz"
sha256 "3652145b0e6d83cfce4377ae6591f87b027d601e22426bd789ec533e99cec0aa"
head "https://github.com/facebook/infer.git"
depends_on "opam" => :build
def install
ENV["OPAMROOT"] = buildpath/"opam"
ENV.append "PATH", buildpath/"opam/system/bin", File::PATH_SEPARATOR
system "opam", "init", "--keep-build-dir", "--no-setup"
system "opam", "install", "--yes", "sawja.1.5", "atdgen.1.5.0", "javalib.2.3", "extlib.1.5.4"
system "./update-fcp.sh"
system "../facebook-clang-plugin/clang/setup.sh"
system "./compile-fcp.sh"
system "make", "-C", "infer"
bin.install_symlink prefix/"infer"
libexec.install Dir["*"]
bin.install_symlink Dir["#{libexec}/infer/infer/bin/infer"]
stable do
inreplace "#{libexec}/infer/infer/bin/infer", "os.path.dirname(__file__)", "os.path.dirname(os.path.realpath(__file__))"
end
end
test do
# Java test
expected = <<-EOS.undent
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
#{libexec}/infer/examples/Hello.java:4: error: NULL_DEREFERENCE
object s last assigned on line 3 could be null and is dereferenced at line 4
EOS
actual = shell_output("#{bin}/infer -- javac #{libexec}/infer/examples/Hello.java").chomp
assert_equal expected, actual
# end Java test
# Obj-C test
expected = <<-EOS.undent
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
#{libexec}/infer/examples/Hello.m:10: error: NULL_DEREFERENCE
pointer hello last assigned on line 9 could be null and is dereferenced at line 10, column 12
EOS
actual = shell_output("#{bin}/infer -- clang -c #{libexec}/infer/examples/Hello.m").chomp
assert_equal expected, actual
# end Obj-C test
# C test
expected = <<-EOS.undent
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
#{libexec}/infer/examples/hello.c:5: error: NULL_DEREFERENCE
pointer s last assigned on line 4 could be null and is dereferenced at line 5, column 3
EOS
actual = shell_output("#{bin}/infer -- gcc -c #{libexec}/infer/examples/hello.c").chomp
assert_equal expected, actual
# end C test
end
end
class Infer < Formula
desc "Infer is a static analysis tool that can analyze Java, Obj-C, and C"
homepage "https://fbinfer.com/"
url "https://github.com/facebook/infer/archive/v0.1.0.tar.gz"
sha256 "3652145b0e6d83cfce4377ae6591f87b027d601e22426bd789ec533e99cec0aa"
head "https://github.com/facebook/infer.git"
depends_on "opam" => :build
def install
ENV["OPAMROOT"] = buildpath/"opam"
ENV.append "PATH", buildpath/"opam/4.01.0/bin", File::PATH_SEPARATOR
system "opam", "init", "--keep-build-dir", "--no-setup", "--comp=4.01.0"
system "opam", "install", "--yes", "sawja.1.5", "atdgen.1.5.0", "javalib.2.3", "extlib.1.5.4"
system "./update-fcp.sh"
system "../facebook-clang-plugin/clang/setup.sh"
system "./compile-fcp.sh"
system "make", "-C", "infer"
bin.install_symlink prefix/"infer"
libexec.install Dir["*"]
bin.install_symlink Dir["#{libexec}/infer/infer/bin/infer"]
stable do
inreplace "#{libexec}/infer/infer/bin/infer", "os.path.dirname(__file__)", "os.path.dirname(os.path.realpath(__file__))"
end
end
test do
# Java test
expected = <<-EOS.undent
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
#{libexec}/infer/examples/Hello.java:4: error: NULL_DEREFERENCE
object s last assigned on line 3 could be null and is dereferenced at line 4
EOS
actual = shell_output("#{bin}/infer -- javac #{libexec}/infer/examples/Hello.java").chomp
assert_equal expected, actual
# end Java test
# Obj-C test
expected = <<-EOS.undent
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
#{libexec}/infer/examples/Hello.m:10: error: NULL_DEREFERENCE
pointer hello last assigned on line 9 could be null and is dereferenced at line 10, column 12
EOS
actual = shell_output("#{bin}/infer -- clang -c #{libexec}/infer/examples/Hello.m").chomp
assert_equal expected, actual
# end Obj-C test
# C test
expected = <<-EOS.undent
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
#{libexec}/infer/examples/hello.c:5: error: NULL_DEREFERENCE
pointer s last assigned on line 4 could be null and is dereferenced at line 5, column 3
EOS
actual = shell_output("#{bin}/infer -- gcc -c #{libexec}/infer/examples/hello.c").chomp
assert_equal expected, actual
# end C test
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment