-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-watchman.sh
executable file
·52 lines (33 loc) · 1.26 KB
/
test-watchman.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
#!/bin/sh -eu
# Test if watchman works correctly
# Create a directory /tmp/watched-dir and watch it with watchman
mkdir -p /tmp/watched-dir
watchman watch /tmp/watched-dir
echo watchman FAILED >/tmp/result.txt
# create a script file_created.sh that will be executed whenever a file is created in /tmp/watched-dir
echo "echo watchman succeeded >/tmp/result.txt" > /tmp/file_created.sh
chmod +x /tmp/file_created.sh
# now execute the command file_created.sh whenever a file is created in /tmp/watched-dir
watchman -- trigger /tmp/watched-dir file_created '*' -- /tmp/file_created.sh
# now create a file in /tmp/watched-dir and see if the command is executed
touch /tmp/watched-dir/test.txt
# wait for 1 second
sleep 1
# now remove the watch
watchman watch-del /tmp/watched-dir
# now check if the command was executed
cat /tmp/result.txt
# testing watchman-make
echo watchman-make FAILED >/tmp/result.txt
watchman-make -r "echo watchman-make succeeded >/tmp/result.txt" -p '*' --root /tmp/watched-dir/ &
pid=$!
# wait for 1 second
sleep 1
# now create a file in /tmp/watched-dir and see if the command is executed
touch /tmp/watched-dir/test2.txt
# wait for 1 second
sleep 1
# now kill watchman-make
kill $pid
# now check if the command was executed
cat /tmp/result.txt