Skip to content

Commit bf6efde

Browse files
authored
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.
1 parent f1265a5 commit bf6efde

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.circleci/generate_coverage.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#!/bin/bash
22

3+
# inspired by https://doc.rust-lang.org/rustc/instrument-coverage.html#tips-for-listing-the-binaries-automatically
4+
TEST_OBJECTS=$( \
5+
for file in $(cargo test --no-run 2>&1 | grep "target/debug/deps/pgcat-[[:alnum:]]\+" -o); \
6+
do \
7+
printf "%s %s " --object $file; \
8+
done \
9+
)
10+
311
rust-profdata merge -sparse pgcat-*.profraw -o pgcat.profdata
412

5-
rust-cov export -ignore-filename-regex="rustc|registry" -Xdemangler=rustfilt -instr-profile=pgcat.profdata --object ./target/debug/pgcat --format lcov > ./lcov.info
13+
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"
614

715
genhtml lcov.info --output-directory /tmp/cov --prefix $(pwd)

tests/ruby/helpers/pgcat_process.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ class PgcatProcess
88
attr_reader :pid
99

1010
def self.finalize(pid, log_filename, config_filename)
11-
`kill #{pid}` if pid
11+
if pid
12+
Process.kill("TERM", pid)
13+
Process.wait(pid)
14+
end
15+
1216
File.delete(config_filename) if File.exist?(config_filename)
1317
File.delete(log_filename) if File.exist?(log_filename)
1418
end
@@ -77,8 +81,8 @@ def wait_until_ready
7781
def stop
7882
return unless @pid
7983

80-
`kill #{@pid}`
81-
sleep 0.1
84+
Process.kill("TERM", @pid)
85+
Process.wait(@pid)
8286
@pid = nil
8387
end
8488

0 commit comments

Comments
 (0)