1#!/bin/bash 2# Copyright (c) 2023 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15function install_pytest() { 16 if ! command -v pytest &> /dev/null; then 17 echo "Installing pytest..." 18 python -m pip install pytest "$@" 19 else 20 echo "pytest is already installed." 21 fi 22} 23 24function install_pytest_html() { 25 if ! pip show pytest-html &> /dev/null; then 26 echo "Installing pytest-html..." 27 python -m pip install pytest-html "$@" 28 else 29 echo "pytest-html is already installed." 30 fi 31} 32 33function install_pytest_metadata() { 34 if ! pip show pytest-metadata &> /dev/null; then 35 echo "Installing pytest-metadata..." 36 python -m pip install pytest-metadata "$@" 37 else 38 echo "pytest-metadata is already installed." 39 fi 40} 41 42function install_py() { 43 if ! pip show py &> /dev/null; then 44 echo "Installing py..." 45 python -m pip install py "$@" 46 else 47 echo "py is already installed." 48 fi 49} 50 51function install() { 52 install_pytest "$@" 53 install_pytest_html "$@" 54 install_pytest_metadata "$@" 55 install_py "$@" 56} 57 58function start() { 59 if [[ $# -eq 2 && $1 == "-i" ]]; then 60 install "$@" 61 elif [[ $# -eq 0 ]]; then 62 install "$@" 63 else 64 echo "args wrong" 65 fi 66} 67 68start "$@" 69