1#!/bin/bash -e 2# 3# Copyright 2020 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6# 7# Runs python unittests in a venv. 8 9# Move to this script's directory. 10cd "$(dirname "$0")" 11 12# Generate protos 13echo "Generating proto bindings..." 14./generate.sh 15 16# Discover and run unittests in payload_utils. 17echo "Running unittests..." 18vpython3 -m unittest discover -s payload_utils -p "*test.py" 19 20echo "Running pylint..." 21PYTHONPATH=payload_utils vpython3 -m pylint "$(pwd)/payload_utils" \ 22 --rcfile=payload_utils/pylintrc 23 24echo "Checking Python files formatted with yapf..." 25if ! vpython3 -m yapf --style .style.yapf --diff -r payload_utils ; then 26 echo "Python files require reformatting. Please run 'yapf --style .style.yapf --in-place -r payload_utils'." 27 exit 1 28fi 29