+export LANG=C.UTF-8
+
+# Explore candidates for LC_ALL
+#
+# If C.UTF-8, the most agnostic UTF-8 locale is supported, we
+# use it, otherwise we default to the UTF-8 system locale, and
+# if unavailable, we default on C.
+#
+# Note that C however is not guaranteed to be UTF-8, and
+# some tests may fail when relying on Unicode semantics.
+locale_candidate=C.UTF-8
+if ! locale -a 2>/dev/null | grep -q C.UTF-8; then
+ locale_candidate="$(locale -a | grep -i utf8 | head -n1)"
+ if [ -z "$locale_candidate" ]; then
+ locale_candidate=C
+ fi
+fi
+export LC_ALL="$locale_candidate"
+
+# Darwin / macOS
+if uname | grep Darwin 1>/dev/null 2>&1; then
+ export LANG=en_US.UTF-8
+ export LC_ALL=en_US.UTF-8
+
+ # Fix for errors on some libevent/nitcorn clients
+ export EVENT_NOKQUEUE=1
+fi
+
+export NIT_TESTING=true
+# Use the pid as a collision prevention
+export NIT_TESTING_ID=$$
+export NIT_SRAND=0
+
+# Identify this as a tests.sh test to differentiate from a nitunit test
+export NIT_TESTING_TESTS_SH=true
+
+unset NIT_DIR
+
+# Get the first Java lib available
+if which_java=$(which javac 2>/dev/null); then
+
+ if sh -c "readlink -f ." 1>/dev/null 2>&1; then
+ READLINK="readlink -f"
+ else
+ # Darwin?
+ READLINK="readlink"
+ fi
+ JAVA_HOME=$(dirname $(dirname $($READLINK "$which_java")))
+
+ shopt -s nullglob
+ paths=`echo $JAVA_HOME/jre/lib/*/{client,server}/libjvm.so`
+ if [ -n "$paths" ]; then
+ paths=($paths)
+ JNI_LIB_PATH=`dirname ${paths[0]}`
+ fi
+ shopt -u nullglob
+fi
+
+outdir="out"
+compdir="nit_compile"
+
+# User CPU time limit (in seconds)
+# Is used to avoid to CPU intensive test (infinite loops). See ulimit -t
+usertimelimit=600 # 1 CPU minute
+
+# Real-time limit (in seconds)
+# Is used to avoid waiting or sleeping tests.
+# Require timeout or timelimit, or else is not used.
+realtimelimit=300 # 5 min
+
+# User limit for write files (in kilo-bytes)
+# Is used to avoid execution that loop and fill the hard drive. See ulimit -f
+# Note that a test might require a lot of temporary disk space (eg. nitc+gcc)
+filelimit=100000 # ~100MB
+
+# Limit (in bytes) for generated .res file.
+# Larger ones are truncated and will fail tests
+# Is used to avoid processing huge crappy res file (diff, xml, etc)
+reslimit=100000 # ~100KB