rtags: refine test

This commit is contained in:
Xu Cheng 2015-09-02 17:46:19 +08:00
parent cf706b5ec7
commit 580b1a72c2

View file

@ -30,41 +30,33 @@ class Rtags < Formula
test do test do
mkpath testpath/"src" mkpath testpath/"src"
(testpath/"src/foo.c").write(<<-END.undent) (testpath/"src/foo.c").write <<-EOS.undent
void zaphod() { void zaphod() {
} }
void beeblebrox() { void beeblebrox() {
zaphod(); zaphod();
} }
END EOS
(testpath/"src/README").write(<<-END.undent) (testpath/"src/README").write <<-EOS.undent
42 42
END EOS
rdm = fork do rdm = fork do
$stdout.reopen("/dev/null") $stdout.reopen("/dev/null")
$stderr.reopen("/dev/null") $stderr.reopen("/dev/null")
exec "#{bin}/rdm", "-L", "log" exec "#{bin}/rdm", "-L", "log"
end end
def pause
slept = 0 begin
while slept < 5 sleep 1
Kernel.system "#{bin}/rc --is-indexing >/dev/null 2>&1" pipe_output("#{bin}/rc -c", "clang -c src/foo.c", 0)
if $? == 0 sleep 1
break assert_match "foo.c:1:6", shell_output("#{bin}/rc -f src/foo.c:5:3")
end system "#{bin}/rc", "-q"
dt = 0.01 ensure
sleep dt Process.kill 9, rdm
slept += dt Process.wait rdm
end
end end
pause
system "sh", "-c", "echo clang -c src/foo.c | #{bin}/rc -c"
assert_equal $?, 0
pause
assert_match /foo\.c:1:6/, shell_output("#{bin}/rc -f src/foo.c:5:3")
system "#{bin}/rc", "-q"
assert_equal $?, 0
Process.wait(rdm)
end end
end end