blob: a6693160200423d0d74437427e38244f5f117c74 [file] [log] [blame]
Andrew Lamb8e70ad02020-03-23 08:40:44 -06001#!/bin/bash -e
2#
3# Copyright 2020 The Chromium OS Authors. All rights reserved.
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
Sean McAllister6e2a4192021-01-28 14:56:47 -07009readonly bin_dir="$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"/bin
10
Andrew Lamb8e70ad02020-03-23 08:40:44 -060011# Move to this script's directory.
12cd "$(dirname "$0")"
13
14# Generate protos
15echo "Generating proto bindings..."
16./generate.sh
17
18# Create and activate venv.
19echo "Creating and activating venv..."
Sean McAllister6e2a4192021-01-28 14:56:47 -070020source "${bin_dir}/common.sh"
21create_venv
Andrew Lamb8e70ad02020-03-23 08:40:44 -060022
23# Discover and run unittests in payload_utils.
24echo "Running unittests..."
25python3 -m unittest discover -s payload_utils -p "*test.py"
26
Andrew Lamb0ed1b902020-06-08 17:03:47 -060027echo "Running pylint..."
28PYTHONPATH=payload_utils pylint "$(pwd)/payload_utils" \
29 --rcfile=payload_utils/pylintrc
30
Andrew Lamb2413c982020-05-29 12:15:36 -060031echo "Checking Python files formatted with yapf..."
32if ! yapf --style .style.yapf --diff -r payload_utils ; then
33 echo "Python files require reformatting. Please run 'yapf --style .style.yapf --in-place -r payload_utils'."
34 exit 1
35fi
36
Andrew Lamb8e70ad02020-03-23 08:40:44 -060037# Deactivate venv.
David Burgerf2b424b2020-06-12 10:49:28 -060038deactivate