Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/dx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ copy_current() {
[ -f "$state/dx$exe" ] && [ -f "$bin" ] && [ "$(wc -c <"$state/dx$exe")" = "$(wc -c <"$bin")" ] &&
! [ "$state/dx$exe" -nt "$bin" ] && ! [ "$state/dx$exe" -ot "$bin" ]
}
# A run killed before its trap ran leaves its pid's temp files behind. A pid that still answers kill -0 belongs to a live run.
sweep_temps() {
for t in "$state/dx$exe".[0-9]* "$state/built".[0-9]* "$state/inputs".[0-9]*; do
[ -e "$t" ] || continue
kill -0 "${t##*.}" 2>/dev/null || rm -f "$t"
done
}
sync_copy() {
sweep_temps
rm -f "$state/dx$exe".old.* 2>/dev/null || true
if ! copy_current; then
[ -f "$bin" ] || return 1
Expand Down
13 changes: 13 additions & 0 deletions tools/dx_launcher_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ case $* in
esac
EOF
chmod +x "$work/bin/bazel"
# A dead pid's temp files are swept; a live pid's (this shell's) are kept.
mkdir -p "$ws/.dx/launcher"
touch "$ws/.dx/launcher/dx.999999" "$ws/.dx/launcher/built.999999" "$ws/.dx/launcher/dx.$$"
cd "$work"
CALLS="$work/calls" PATH="$work/bin:$PATH" HOME="$work/home" XDG_CACHE_HOME="$work/cache" "$ws/tools/dx" >/dev/null 2>&1 || true
calls=$(cat "$work/calls" 2>/dev/null || true)
Expand All @@ -46,3 +49,13 @@ if [ "$inputs" != '//cli/cli:a.rs' ]; then
echo "a retried query kept the failed attempt's partial stdout: inputs=$inputs" >&2
exit 1
fi
for f in dx.999999 built.999999; do
if [ -e "$ws/.dx/launcher/$f" ]; then
echo "the launcher kept $f from a dead pid" >&2
exit 1
fi
done
if [ ! -e "$ws/.dx/launcher/dx.$$" ]; then
echo "the launcher removed dx.$$ from a live pid" >&2
exit 1
fi