-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# cli-test: Tests for forever CLI | ||
# | ||
# (C) 2012 Nodejitsu Inc. | ||
# MIT LICENSE | ||
# | ||
|
||
# Yes, we have tests in bash. How mad science is that? | ||
|
||
alias forever=bin/forever | ||
script="examples/log-on-interval.js" | ||
|
||
function fail { | ||
echo "\033[31m ✘ $1\033[0m" | ||
exit 1 | ||
} | ||
|
||
function success { | ||
echo "\033[32m ✔ $1\033[0m" | ||
} | ||
|
||
function spec { | ||
[ $? -eq 0 ] || fail "$1" | ||
success "$1" | ||
} | ||
|
||
echo "\033[1mRunning tests:\033[0m" | ||
|
||
# First kill all processes and remove forever directory to ensure clean | ||
# environment | ||
forever stopall | ||
rm -rf ~/.forever | ||
|
||
# Spawn some process | ||
forever start "$script" | ||
|
||
# Assert that forever actually spawned a process and that it's in `forever list` | ||
sleep 1 # it takes some time until process appears in `forever list` | ||
forever list | grep "$script" | ||
spec "\`forever list\` should contain spawned process" | ||
|
||
# `forever stop` should output process it stopped... | ||
forever stop 0 | grep "$script" | ||
spec "\`forever stop 0\` should contain stopped process" | ||
|
||
# ... and actually stop it | ||
forever list | grep -v "$script" | ||
spec "\`forever stop 0\` should actually stop the process" | ||
|