forked from haskellari/lukko
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-process.sh
executable file
·67 lines (51 loc) · 856 Bytes
/
test-process.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
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
set -ex
# Configuration
MODE=default
case "$1" in
default|flock|ofd|noop)
MODE=$1
;;
esac
echo "MODE $MODE"
# Build
# cabal v2-build test-process
TEST=$(cabal-plan list-bin test-process)
# Cleanup stuff, which shouldn't be there
rm -rf test-lock
rm -rf test-actual
rm -rf test-expected
# Tests assume there is test-actual file
touch test-actual
# Spawn workers
$TEST $MODE &
PID1=$!
$TEST $MODE &
PID2=$!
$TEST $MODE &
PID3=$!
$TEST $MODE &
PID4=$!
$TEST $MODE &
PID5=$!
# Wait for processes
wait $PID1
wait $PID2
wait $PID3
wait $PID4
wait $PID5
# Expected
cat <<EOF > test-expected
another line
another line
another line
another line
another line
EOF
# Output
cat test-actual
diff -u test-actual test-expected || exit 1
# Cleanup stuff after the test
rm -rf test-lock
rm -rf test-actual
rm -rf test-expected