-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
81 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
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,80 @@ | ||
#!/bin/bash | ||
|
||
REL_SCRIPT_DIR="`dirname \"$0\"`" | ||
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`" | ||
|
||
test_cli_common() | ||
{ | ||
echo ---------------------------------------- | ||
echo Testing common cli behavior... | ||
CLI_SCRIPT_NAME=${1:?missing_param} | ||
CLI_SCRIPT=$SCRIPT_DIR/../../$CLI_SCRIPT_NAME | ||
echo Script: $CLI_SCRIPT | ||
|
||
# should find the minimal help output | ||
$CLI_SCRIPT 2>&1 | grep -q "Must define at least one file\." || { | ||
echo "[$CLI_SCRIPT_NAME] Output should be help message." | ||
exit 1 | ||
} | ||
|
||
# Not working yet for python | ||
# $CLI_SCRIPT 2> /dev/null && { | ||
# echo "[$CLI_SCRIPT_NAME (with no parameters)] Return code should be error." | ||
# exit 1 | ||
# } | ||
|
||
# Not working yet for python | ||
# $CLI_SCRIPT -invalidParameter 2> /dev/null && { | ||
# echo "[$CLI_SCRIPT_NAME -invalidParameter] Return code should be error." | ||
# exit 1 | ||
# } | ||
|
||
$CLI_SCRIPT -h > /dev/null || { | ||
echo "[$CLI_SCRIPT_NAME -h] Return code should be success." | ||
exit 1 | ||
} | ||
|
||
$CLI_SCRIPT -v > /dev/null || { | ||
echo "[$CLI_SCRIPT_NAME -v] Return code should be success." | ||
exit 1 | ||
} | ||
|
||
} | ||
|
||
test_cli_js_beautify() | ||
{ | ||
echo ---------------------------------------- | ||
echo Testing js-beautify cli behavior... | ||
CLI_SCRIPT=$SCRIPT_DIR/../../js-beautify | ||
|
||
$CLI_SCRIPT $SCRIPT_DIR/../../../js/bin/js-beautify.js > /dev/null || { | ||
echo "js-beautify output for $SCRIPT_DIR/../bin/js-beautify.js was expected succeed." | ||
exit 1 | ||
} | ||
|
||
$CLI_SCRIPT $SCRIPT_DIR/../../../js/bin/css-beautify.js > /dev/null || { | ||
echo "js-beautify output for $SCRIPT_DIR/../bin/css-beautify.js was expected succeed." | ||
exit 1 | ||
} | ||
|
||
$CLI_SCRIPT $SCRIPT_DIR/../../../js/bin/js-beautify.js | diff $SCRIPT_DIR/../../../js/bin/js-beautify.js - || { | ||
echo "js-beautify output for $SCRIPT_DIR/../bin/js-beautify.js was expected to be unchanged." | ||
exit 1 | ||
} | ||
|
||
$CLI_SCRIPT $SCRIPT_DIR/../../../js/bin/css-beautify.js | diff -q $SCRIPT_DIR/../../../js/bin/css-beautify.js - && { | ||
echo "js-beautify output for $SCRIPT_DIR/../bin/css-beautify.js was expected to be different." | ||
exit 1 | ||
} | ||
|
||
} | ||
|
||
#test_cli_common css-beautify | ||
#test_cli_common html-beautify | ||
test_cli_common js-beautify | ||
|
||
test_cli_js_beautify | ||
|
||
echo ---------------------------------------- | ||
echo $0 - PASSED. | ||
echo ---------------------------------------- |