Add --noformat option for unit test
The run-unit-test-docker.sh and unit-test.py will run format-code.sh to
check the code format, and break when the code is not formatted
correctly.
For local-ci, this is unecessary because the code not "git add" or not
committed is treated as not-formatted and will break.
Adding NO_FORMAT_CODE option to make the unit test skip formatting the
code, so that one could write code in local repo, run the local-ci
without having to git add ro commit the changes.
Tested: Run run-unit-test-docker.sh as before, verify the format-code.sh
is invoked;
Run 'NO_FORMAT_CODE=1 run-unit-test-docker.sh', verify the
format-code.sh is not invoked.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ib3b6cf34390c91d551bc14613e925b8e51a3065f
diff --git a/run-unit-test-docker.sh b/run-unit-test-docker.sh
index 18e7e6a..b178fa4 100755
--- a/run-unit-test-docker.sh
+++ b/run-unit-test-docker.sh
@@ -24,6 +24,7 @@
# -$BRANCH replacing -master if $BRANCH provided
# dbus_sys_config_file: Optional, with the default being
# `/usr/share/dbus-1/system.conf`
+# NO_FORMAT_CODE: Optional, do not run format-code.sh
# Trace bash processing. Set -e so when a step fails, we fail the build
set -uo pipefail
@@ -41,6 +42,7 @@
DBUS_SYS_CONFIG_FILE=${dbus_sys_config_file:-"/usr/share/dbus-1/system.conf"}
MAKEFLAGS="${MAKEFLAGS:-""}"
DOCKER_WORKDIR="${DOCKER_WORKDIR:-$WORKSPACE}"
+NO_FORMAT_CODE="${NO_FORMAT_CODE:-}"
# Timestamp for job
echo "Unit test build started, $(date)"
@@ -90,7 +92,7 @@
# Unit test and parameters
UNIT_TEST="${DOCKER_WORKDIR}/${UNIT_TEST_PY},-w,${DOCKER_WORKDIR},\
--p,${UNIT_TEST_PKG},-b,$BRANCH,-v${TEST_ONLY:+,-t}"
+-p,${UNIT_TEST_PKG},-b,$BRANCH,-v${TEST_ONLY:+,-t}${NO_FORMAT_CODE:+,-n}"
# Run the docker unit test container with the unit test execution script
echo "Executing docker image"