File: watch-tests.sh

package info (click to toggle)
lua-cliargs 3.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: sh: 118; javascript: 14; makefile: 5
file content (36 lines) | stat: -rwxr-xr-x 779 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env bash
#
# Watches spec files and re-runs the busted suite when a spec or source file
# changes.
#
# Usage:
#
#     $0 [--focus]
#
# If --focus is passed, only the last spec file that has changed will be run
# when a _source_ file changes. Otherwise, all specs will run on source changes.
#
# Requires inotify-tools[1].
#
# [1] http://linux.die.net/man/1/inotifywait

if [ ! -d spec ]; then
  echo "Must be run from lua_cliargs root."
  exit 1
fi

LAST_FILE="spec/"

inotifywait -rm --format '%w %f' -e close_write -e create src/ spec/ | while read dir file; do
  FILEPATH="${dir}${file}"

  if [[ $FILEPATH =~ src\/ ]]; then
    busted $@ "${LAST_FILE}"
  else
    if [[ $1 =~ "focus" ]]; then
      LAST_FILE=$FILEPATH
    fi

    busted $@ "${FILEPATH}"
  fi
done