summaryrefslogtreecommitdiff
path: root/util/ec3po/run_tests.sh
diff options
context:
space:
mode:
authorMatthew Blecker <matthewb@chromium.org>2021-08-26 13:59:01 -0700
committerCommit Bot <commit-bot@chromium.org>2021-08-27 01:41:46 +0000
commit352e821faab88e59f2e60df23b671564de595827 (patch)
tree25a028e4da102089d2bc6b7a95b7e9c66771faad /util/ec3po/run_tests.sh
parentbc1eadcd1df76ee9d698a3ce531b422654760726 (diff)
downloadchrome-ec-352e821faab88e59f2e60df23b671564de595827.tar.gz
ec3po: Update unittests to use ec3po.<module> import paths.
run_tests.sh no longer uses the Python unittest module's discovery functionality, which was forcing util/ec3po/ subdir to be directly in sys.path as a top-level module location, which is inconsistent with how ec3po modules are used outside of the tests. run_tests.sh no longer auto-discovers *_unittest.py files, instead they are individually listed as ec3po.<name>_unittest modules. It would be straightforward to implement test module autodiscovery, but probably isn't worth the complexity. BRANCH=none BUG=chromium:1031705,b:174894072,b:197618562 TEST=Within chroot, ran ./runtests.sh from within util/ec3po/ directory. Within chroot, ran ~/trunk/src/platform/ec/util/ec3po/run_tests.sh from a different directory. Verified use of the files-under-test (as opposed to the files installed in site-packages/) by adding broken code to console.py and then re-running both invoctions above. Both then failed as intended. Change-Id: I40c180f1d66a4d3befc548f4d763357e6cc24201 Signed-off-by: Matthew Blecker <matthewb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3123835 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'util/ec3po/run_tests.sh')
-rwxr-xr-xutil/ec3po/run_tests.sh12
1 files changed, 9 insertions, 3 deletions
diff --git a/util/ec3po/run_tests.sh b/util/ec3po/run_tests.sh
index 09e1a545d0..ba513abe30 100755
--- a/util/ec3po/run_tests.sh
+++ b/util/ec3po/run_tests.sh
@@ -4,6 +4,12 @@
# 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.
-python3 -m unittest discover -b -s util/ec3po/ -p "*_unittest.py" \
- && touch util/ec3po/.tests-passed
+set -e
+
+my_dir="$(realpath -e -- "$(dirname -- "$0")")"
+parent_dir="$(realpath -e -- "$my_dir/..")"
+
+PYTHONPATH="$parent_dir" python3 -s -m unittest \
+ ec3po.console_unittest \
+ ec3po.interpreter_unittest \
+ && touch -- "$my_dir/.tests-passed"