diff options
author | Aseda Aboagye <aaboagye@google.com> | 2015-12-17 14:06:03 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-01-04 16:26:22 -0800 |
commit | c6773e676536d82ee0649865138713123a7c8445 (patch) | |
tree | a1071ce2fc9ff3ec4fb2169ba1ca48ee9e7d0940 | |
parent | ec7927a20d4fd1db35e482a69da1e9915552322f (diff) | |
download | chrome-ec-c6773e676536d82ee0649865138713123a7c8445.tar.gz |
util: ec3po: Add presubmit check for ec3po.stabilize-smaug-7800.B
Added presubmit check to make sure that when any ec3po files are
modified, the unit tests should be run as well.
BUG=None
BRANCH=None
TEST=Touched a unit test file, tried repo upload and received an error
about running unit tests. Ran run_tests.sh and all tests passed. Tried
to repo upload again and this time it succeeded.
TEST=Created a failure in one unit test, ran run_tests.sh and verified
that the failure was caught and the CL wouldn't pass the presubmit
check.
Change-Id: I4df4a0fd1107292f693749188491f6286360f557
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/319211
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rwxr-xr-x | util/ec3po/run_tests.sh | 9 | ||||
-rwxr-xr-x | util/presubmit_check.sh | 17 |
2 files changed, 26 insertions, 0 deletions
diff --git a/util/ec3po/run_tests.sh b/util/ec3po/run_tests.sh new file mode 100755 index 0000000000..f0ef348273 --- /dev/null +++ b/util/ec3po/run_tests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Copyright 2015 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Discover all the unit tests in the ec3po directory and run them. +python2 -m unittest discover -b -s util/ec3po/ -p *_unittest.py \ + && touch util/ec3po/.tests-passed diff --git a/util/presubmit_check.sh b/util/presubmit_check.sh index 220522083e..41045042f1 100755 --- a/util/presubmit_check.sh +++ b/util/presubmit_check.sh @@ -8,10 +8,27 @@ if [[ ! -e .tests-passed ]]; then echo 'Unit tests have not passed. Please run "make buildall -j".' exit 1 fi + changed=$(find ${PRESUBMIT_FILES} -newer .tests-passed) +ec3po_files=$(echo "${PRESUBMIT_FILES}" | grep util/ec3po/) +# Filter out ec3po files from changed files. +changed=$(echo "${changed}" | grep -v util/ec3po/) if [[ -n "${changed}" ]]; then echo "Files have changed since last time unit tests passed:" echo "${changed}" | sed -e 's/^/ /' echo 'Please run "make buildall -j".' exit 1 fi + +if [[ ! -e util/ec3po/.tests-passed ]]; then + echo 'Unit tests have not passed. Please run "util/ec3po/run_tests.sh".' + exit 1 +fi + +changed_ec3po_files=$(find ${ec3po_files} -newer util/ec3po/.tests-passed) +if [[ -n ${changed_ec3po_files} ]]; then + echo "Files have changed since last time EC-3PO unit tests passed:" + echo "${changed_ec3po_files}" | sed -e 's/^/ /' + echo 'Please run "util/ec3po/run_tests.sh".' + exit 1 +fi |