Skip to content

Commit 5d0e318

Browse files
committed
fix lock tests
1 parent aced9b1 commit 5d0e318

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

rewatch/tests/lock.sh

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ else
1414
fi
1515

1616
exit_watcher() {
17-
# we need to kill the parent process (rewatch)
18-
kill $(pgrep -P $!);
17+
# Try to find child process, if not found just kill the process directly
18+
rm lib/rewatch.lock
1919
}
2020

21-
rewatch watch &>/dev/null &
22-
success "Watcher Started"
21+
rewatch_bg watch > /dev/null 2>&1 &
22+
echo "Started watcher in background"
2323

2424
sleep 1
2525

26-
if rewatch watch 2>&1 | grep 'Could not start Rewatch:' &> /dev/null;
26+
if rewatch watch | grep 'Could not start Rewatch:' &> /dev/null;
2727
then
28+
# rm output.txt
2829
success "Lock is correctly set"
2930
exit_watcher
3031
else
32+
# rm output.txt
3133
error "Not setting lock correctly"
3234
exit_watcher
3335
exit 1
@@ -36,7 +38,7 @@ fi
3638
sleep 1
3739

3840
touch tmp.txt
39-
rewatch watch &> tmp.txt &
41+
rewatch_bg watch > tmp.txt 2>&1 &
4042
success "Watcher Started"
4143

4244
sleep 1
@@ -51,4 +53,4 @@ else
5153
exit_watcher
5254
fi
5355

54-
rm tmp.txt
56+
rm tmp.txt

0 commit comments

Comments
 (0)