mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 18:36:28 +00:00
Fix code coverage + less flakiness (#318)
Code coverage logic was missing coverage from rust tests. This is now fixed. Also, we weren't reaping spawned PgCat processes correctly which left zombie processes.
This commit is contained in:
committed by
GitHub
parent
f1265a5570
commit
bf6efde8cc
@@ -1,7 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# inspired by https://doc.rust-lang.org/rustc/instrument-coverage.html#tips-for-listing-the-binaries-automatically
|
||||||
|
TEST_OBJECTS=$( \
|
||||||
|
for file in $(cargo test --no-run 2>&1 | grep "target/debug/deps/pgcat-[[:alnum:]]\+" -o); \
|
||||||
|
do \
|
||||||
|
printf "%s %s " --object $file; \
|
||||||
|
done \
|
||||||
|
)
|
||||||
|
|
||||||
rust-profdata merge -sparse pgcat-*.profraw -o pgcat.profdata
|
rust-profdata merge -sparse pgcat-*.profraw -o pgcat.profdata
|
||||||
|
|
||||||
rust-cov export -ignore-filename-regex="rustc|registry" -Xdemangler=rustfilt -instr-profile=pgcat.profdata --object ./target/debug/pgcat --format lcov > ./lcov.info
|
bash -c "rust-cov export -ignore-filename-regex='rustc|registry' -Xdemangler=rustfilt -instr-profile=pgcat.profdata $TEST_OBJECTS --object ./target/debug/pgcat --format lcov > ./lcov.info"
|
||||||
|
|
||||||
genhtml lcov.info --output-directory /tmp/cov --prefix $(pwd)
|
genhtml lcov.info --output-directory /tmp/cov --prefix $(pwd)
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ class PgcatProcess
|
|||||||
attr_reader :pid
|
attr_reader :pid
|
||||||
|
|
||||||
def self.finalize(pid, log_filename, config_filename)
|
def self.finalize(pid, log_filename, config_filename)
|
||||||
`kill #{pid}` if pid
|
if pid
|
||||||
|
Process.kill("TERM", pid)
|
||||||
|
Process.wait(pid)
|
||||||
|
end
|
||||||
|
|
||||||
File.delete(config_filename) if File.exist?(config_filename)
|
File.delete(config_filename) if File.exist?(config_filename)
|
||||||
File.delete(log_filename) if File.exist?(log_filename)
|
File.delete(log_filename) if File.exist?(log_filename)
|
||||||
end
|
end
|
||||||
@@ -77,8 +81,8 @@ class PgcatProcess
|
|||||||
def stop
|
def stop
|
||||||
return unless @pid
|
return unless @pid
|
||||||
|
|
||||||
`kill #{@pid}`
|
Process.kill("TERM", @pid)
|
||||||
sleep 0.1
|
Process.wait(@pid)
|
||||||
@pid = nil
|
@pid = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user