<commit_before>#!/bin/bash
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

case "$(uname -s)" in
   CYGWIN*) IS_CYGWIN=1 ;;
esac

function makePath {
	local __assignTo=$1
	local __path=$2
	if [ ! -z $IS_CYGWIN ]; then
		__path="`cygpath -aw \"$__path\"`"
	fi
	eval $__assignTo="'$__path'"
}

DEBUG=false
if [ -z "$FX_EXECUTABLE" ]; then
	if [ "`uname`" == "Darwin" ]; then
		FX_EXECUTABLE="/Applications/Firefox.app/Contents/MacOS/firefox"
	else
		FX_EXECUTABLE="firefox"
	fi
fi

FX_ARGS=""

function usage {
	cat >&2 <<DONE
Usage: $0 [option] [TESTS...]
Options
 -b                  skip bundled translator/style installation
 -c                  open JavaScript console and don't quit on completion
 -d LEVEL            enable debug logging
 -f                  stop after first test failure
 -g                  only run tests matching the given pattern (grep)
 -t                  generate test data and quit
 -x FX_EXECUTABLE    path to Firefox executable (default: $FX_EXECUTABLE)
 -b                  skip bundled translator/style installation
 TESTS               set of tests to run (default: all)
DONE
	exit 1
}

DEBUG_LEVEL=0
while getopts "bcd:fg:tx:" opt; do
	case $opt in
        b)
        	FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
        	;;
		c)
			FX_ARGS="$FX_ARGS -jsconsole -noquit"
			;;
		d)
			DEBUG=true
			DEBUG_LEVEL="$OPTARG"
			;;
		f)
			FX_ARGS="$FX_ARGS -bail"
			;;
		g)
			GREP="$OPTARG"
			;;
		t)
			FX_ARGS="$FX_ARGS -makeTestData"
			;;
		x)
			FX_EXECUTABLE="$OPTARG"
			;;
		*)
			usage
			;;
	esac
	shift $((OPTIND-1)); OPTIND=1
done

if [ -z $1 ]; then
	TESTS="all"
else
	ARGS=("${@:1}")
	function join { local IFS="$1"; shift; echo "$*"; }
	TESTS="$(join , "${ARGS[@]}")"
fi

# Increase open files limit
#
# Mozilla file functions (OS.File.move()/copy(), NetUtil.asyncFetch/asyncCopy()) can leave file
# descriptors open for a few seconds (even with an explicit inputStream.close() in the case of
# the latter), so a source installation that copies ~500 translators and styles (with fds for<commit_msg>Add -h flag to test runner to display help cleanly<commit_after>#!/bin/bash
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

case "$(uname -s)" in
   CYGWIN*) IS_CYGWIN=1 ;;
esac

function makePath {
	local __assignTo=$1
	local __path=$2
	if [ ! -z $IS_CYGWIN ]; then
		__path="`cygpath -aw \"$__path\"`"
	fi
	eval $__assignTo="'$__path'"
}

DEBUG=false
if [ -z "$FX_EXECUTABLE" ]; then
	if [ "`uname`" == "Darwin" ]; then
		FX_EXECUTABLE="/Applications/Firefox.app/Contents/MacOS/firefox"
	else
		FX_EXECUTABLE="firefox"
	fi
fi

FX_ARGS=""

function usage {
	cat >&2 <<DONE
Usage: $0 [option] [TESTS...]
Options
 -b                  skip bundled translator/style installation
 -c                  open JavaScript console and don't quit on completion
 -d LEVEL            enable debug logging
 -f                  stop after first test failure
 -g                  only run tests matching the given pattern (grep)
 -h                  display this help
 -t                  generate test data and quit
 -x FX_EXECUTABLE    path to Firefox executable (default: $FX_EXECUTABLE)
 TESTS               set of tests to run (default: all)
DONE
	exit 1
}

DEBUG_LEVEL=0
while getopts "bcd:fg:htx:" opt; do
	case $opt in
        b)
        	FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
        	;;
		c)
			FX_ARGS="$FX_ARGS -jsconsole -noquit"
			;;
		d)
			DEBUG=true
			DEBUG_LEVEL="$OPTARG"
			;;
		f)
			FX_ARGS="$FX_ARGS -bail"
			;;
		g)
			GREP="$OPTARG"
			;;
		h)
			usage
			;;
		t)
			FX_ARGS="$FX_ARGS -makeTestData"
			;;
		x)
			FX_EXECUTABLE="$OPTARG"
			;;
		*)
			usage
			;;
	esac
	shift $((OPTIND-1)); OPTIND=1
done

if [ -z $1 ]; then
	TESTS="all"
else
	ARGS=("${@:1}")
	function join { local IFS="$1"; shift; echo "$*"; }
	TESTS="$(join , "${ARGS[@]}")"
fi

# Increase open files limit
#
# Mozilla file functions (OS.File.move()/copy(), NetUtil.asyncFetch/asyncCopy()) can leave file
# descriptors open for a few seconds (even with an explicit inputStream.close() in the case of
# the latter), so a source installation that copies ~500 translators and styles (with fds for
{'fraction_non_alphanumeric': 0.13817217265493129, 'fraction_numerical': 0.007716421509524958, 'mean_word_length': 2.736936936936937, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '717692', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1443, 'n_words': 431}