Created
May 2, 2011 18:21
-
-
Save mihaisucan/952081 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# $Author: Mihai Sucan <[email protected]>$ | |
# $Date: 2011-05-02 21:10:35 $ | |
# usage: | |
# moztests -hud | |
# runs the HUDService tests | |
# moztests -ws | |
# runs the Workspace tests | |
# moztests -dbg -hud | |
# runs the HUDService tests in the debug build | |
# moztests -hud *foo* | |
# runs the HUDService tests which match *foo*. you can also tell the exact file name you want. | |
# moztests path/to/folder *foo* | |
# runs the tests that match *foo* from path/to/folder. without *foo* you run all the tests from the given folder. | |
MY_PWD="$PWD" | |
MY_SELF="${0##*/}" | |
if [[ "$1" == "-dbg" ]] | |
then | |
OBJ_DIR="ff-dbg-obj" | |
TEST_DIR="$2" | |
TEST_FILE="$3" | |
else | |
OBJ_DIR="ff-obj" | |
TEST_DIR="$1" | |
TEST_FILE="$2" | |
fi | |
if [[ ! -d "$OBJ_DIR" ]] | |
then | |
echo "folder not found: $OBJ_DIR" | |
exit 1 | |
fi | |
# default make target | |
MAKE_TARGET="mochitest-browser-chrome" | |
# add anything you need ... | |
case "$TEST_DIR" in | |
( '-bbase' ) | |
TEST_DIR="browser/base/content/test" | |
MAKE_TARGET="mochitest-browser-chrome" | |
;; | |
( '-tabview' ) | |
TEST_DIR="browser/base/content/test/tabview" | |
MAKE_TARGET="mochitest-browser-chrome" | |
;; | |
( '-hud' ) | |
TEST_DIR="toolkit/components/console/hudservice/tests/browser" | |
MAKE_TARGET="mochitest-browser-chrome" | |
;; | |
( '-prompts' ) | |
TEST_DIR="toolkit/components/prompts/test" | |
MAKE_TARGET="mochitest-plain" | |
;; | |
( '-inspector' ) | |
TEST_DIR="browser/base/content/test" | |
MAKE_TARGET="mochitest-browser-chrome" | |
FILE_FILTER="browser_inspector_*.js" | |
;; | |
( '-ws' ) | |
TEST_DIR="browser/base/content/test" | |
MAKE_TARGET="mochitest-browser-chrome" | |
FILE_FILTER="browser_workspace_*.js" | |
;; | |
( '-dom-browser' ) | |
TEST_DIR="dom/tests/browser" | |
MAKE_TARGET="mochitest-browser-chrome" | |
;; | |
( '-dom-mochitest-general' ) | |
TEST_DIR="dom/tests/mochitest/general" | |
MAKE_TARGET="mochitest-plain" | |
;; | |
esac | |
if [[ ! -z "$TEST_FILE" ]] | |
then | |
if [[ -f "${TEST_DIR}/${TEST_FILE}" ]] | |
then | |
TEST_DIR="${TEST_DIR}/${TEST_FILE}" | |
else | |
FILE_FILTER="$TEST_FILE" | |
fi | |
fi | |
if [[ ! -d "$TEST_DIR" && ! -f "$TEST_DIR" ]] | |
then | |
echo "folder/file not found: $TEST_DIR" | |
exit 1 | |
fi | |
if [[ -d "$TEST_DIR" && ! -z "$FILE_FILTER" ]] | |
then | |
cd "$TEST_DIR" | |
FILES=($FILE_FILTER) | |
cd "$MY_PWD" | |
found=0 | |
for t in "${FILES[@]}" | |
do | |
if [[ ! -f "${TEST_DIR}/$t" || "$t" =~ ^\. || "$t" =~ ~$ || "$t" =~ \.bak$ ]] | |
then | |
continue | |
fi | |
found=1 | |
export TEST_PATH="${TEST_DIR}/$t" | |
make -C "$OBJ_DIR" "$MAKE_TARGET" | |
done | |
if [[ "$found" -eq 0 ]] | |
then | |
echo "no files match $FILE_FILTER in $TEST_DIR" | |
exit 1 | |
fi | |
exit 0 | |
else | |
export TEST_PATH="$TEST_DIR" | |
make -C "$OBJ_DIR" "$MAKE_TARGET" | |
exit $? | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment