UNPKG

1.13 kBPlain TextView Raw
1#!/usr/bin/env bash
2
3#
4# cli-test: Tests for forever CLI
5#
6# (C) 2012 Charlie Robbins & the Contributors
7# MIT LICENSE
8#
9
10# Yes, we have tests in bash. How mad science is that?
11
12alias forever=bin/forever
13script="test/fixtures/log-on-interval.js"
14
15function fail {
16 echo "\033[31m ✘ $1\033[0m"
17 exit 1
18}
19
20function success {
21 echo "\033[32m ✔ $1\033[0m"
22}
23
24function spec {
25 [ $? -eq 0 ] || fail "$1"
26 success "$1"
27}
28
29echo "\033[1mRunning tests:\033[0m"
30
31# First kill all processes and remove forever directory to ensure clean
32# environment
33forever stopall
34rm -rf ~/.forever
35
36# Spawn some process
37forever start "$script"
38
39# Assert that forever actually spawned a process and that it's in `forever list`
40sleep 1 # it takes some time until process appears in `forever list`
41forever list | grep "$script"
42spec "\`forever list\` should contain spawned process"
43
44# `forever stop` should output process it stopped...
45forever stop 0 | grep "$script"
46spec "\`forever stop 0\` should contain stopped process"
47
48# ... and actually stop it
49forever list | grep -v "$script"
50spec "\`forever stop 0\` should actually stop the process"
51