aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorDominyk Tiller2015-03-10 13:36:52 +0000
committerBrett Koonce2015-03-14 19:27:32 -0700
commit8ac61457fa6c5d39ca3d1f7ece5366639405466e (patch)
tree64b730ff4e32f6ee01df8d4dd41703884107ea2f /Library/Formula
parent838eb29bcf4672cf7e6832d3e3cd9cd0ef1356ff (diff)
downloadhomebrew-8ac61457fa6c5d39ca3d1f7ece5366639405466e.tar.bz2
cflow: modernise & add test
Modernises the cflow formula with SSL/TLS links, SHA256, double quotes everywhere, etc. Also added a test, which I completely and utterly stole from the GNU manpage for cflow. Closes #37565. Signed-off-by: Brett Koonce <koonce@gmail.com>
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/cflow.rb55
1 files changed, 46 insertions, 9 deletions
diff --git a/Library/Formula/cflow.rb b/Library/Formula/cflow.rb
index 1a04530b3..d2642acde 100644
--- a/Library/Formula/cflow.rb
+++ b/Library/Formula/cflow.rb
@@ -1,15 +1,52 @@
-require 'formula'
-
class Cflow < Formula
- homepage 'http://www.gnu.org/software/cflow/'
- url 'http://ftpmirror.gnu.org/cflow/cflow-1.4.tar.bz2'
- mirror 'http://ftp.gnu.org/gnu/cflow/cflow-1.4.tar.bz2'
- sha1 'b8c3674e47112d5a81c34719fef343430be77f88'
+ homepage "https://www.gnu.org/software/cflow/"
+ url "http://ftpmirror.gnu.org/cflow/cflow-1.4.tar.bz2"
+ mirror "https://ftp.gnu.org/gnu/cflow/cflow-1.4.tar.bz2"
+ sha256 "037e39d6048ea91c68a5f3a561e10f22fd085d1f7641643e19c831a94ec26bca"
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
- "--prefix=#{prefix}",
- "--infodir=#{info}"
- system "make install"
+ "--prefix=#{prefix}", "--infodir=#{info}"
+ system "make", "install"
+ end
+
+ test do
+ (testpath/"whoami.c").write <<-EOS.undent
+ #include <pwd.h>
+ #include <sys/types.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ int
+ who_am_i (void)
+ {
+ struct passwd *pw;
+ char *user = NULL;
+
+ pw = getpwuid (geteuid ());
+ if (pw)
+ user = pw->pw_name;
+ else if ((user = getenv ("USER")) == NULL)
+ {
+ fprintf (stderr, "I don't know!\n");
+ return 1;
+ }
+ printf ("%s\n", user);
+ return 0;
+ }
+
+ int
+ main (int argc, char **argv)
+ {
+ if (argc > 1)
+ {
+ fprintf (stderr, "usage: whoami\n");
+ return 1;
+ }
+ return who_am_i ();
+ }
+ EOS
+
+ assert_match /getpwuid()/, shell_output("#{bin}/cflow --main who_am_i #{testpath}/whoami.c")
end
end