forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlock.sh
executable file
·54 lines (42 loc) · 853 Bytes
/
lock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
source "./utils.sh"
cd ../testrepo
bold "Test: It should lock - when watching"
sleep 1
if rewatch clean &> /dev/null;
then
success "Repo Cleaned"
else
error "Error Cleaning Repo"
exit 1
fi
exit_watcher() {
# we need to kill the parent process (rewatch)
kill $(pgrep -P $!);
}
rewatch watch &>/dev/null &
success "Watcher Started"
sleep 1
if rewatch watch 2>&1 | grep 'Error while trying to get lock:' &> /dev/null;
then
success "Lock is correctly set"
exit_watcher
else
error "Not setting lock correctly"
exit_watcher
exit 1
fi
sleep 1
touch tmp.txt
rewatch watch &> tmp.txt &
success "Watcher Started"
sleep 1
if cat tmp.txt | grep 'Error while trying to get lock:' &> /dev/null;
then
error "Lock not removed correctly"
exit_watcher
exit 1
else
success "Lock removed correctly"
exit_watcher
fi
rm tmp.txt