aboutsummaryrefslogtreecommitdiffstats
path: root/tests/00-db-exclusive/run
blob: 1528b3bae91fd9e81146d4a1b06961311bf21abe (plain)
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
# verify that database isn't created in --watch mode
! interimap --watch=60
xgrep -E "^DBI connect\(.*\) failed: unable to open database file at " <"$STDERR"

# now create database
interimap

# start a background process
interimap --watch=60 & pid=$!
cleanup() {
    # kill interimap process and its children
    pkill -P "$pid" -TERM || true
    kill -TERM "$pid" || true
    wait
}
trap cleanup EXIT INT TERM

sleep .05 # wait a short while so we have time to lock the database (ugly and racy...)
# verify that subsequent runs fail as we can't acquire the exclusive lock
! interimap

# line 177 is `$DBH->do("PRAGMA locking_mode = EXCLUSIVE");`
xgrep -Fx "DBD::SQLite::db do failed: database is locked at ./interimap line 177." <"$STDERR"

# vim: set filetype=sh :