pidof: add test
This commit is contained in:
parent
a79b8968a7
commit
325e5ee397
1 changed files with 25 additions and 0 deletions
|
@ -20,4 +20,29 @@ class Pidof < Formula
|
|||
man1.install gzip("pidof.1")
|
||||
bin.install "pidof"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"homebrew_testing.c").write <<-EOS.undent
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Testing Pidof\\n");
|
||||
sleep(10);
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
system ENV.cc, "homebrew_testing.c", "-o", "homebrew_testing"
|
||||
(testpath/"homebrew_testing").chmod 0555
|
||||
|
||||
pid = fork { exec "./homebrew_testing" }
|
||||
sleep 1
|
||||
begin
|
||||
assert_match(/\d+/, shell_output("#{bin}/pidof homebrew_testing"))
|
||||
ensure
|
||||
Process.kill("SIGINT", pid)
|
||||
Process.wait(pid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue