diff --git a/.circleci/config.yml b/.circleci/config.yml index 794cefaba..44a0cec29 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -118,7 +118,7 @@ jobs: name: Run unit tests command: | cd software/debug - poetry install + poetry install --no-interaction poetry run pytest -v diff --git a/.gitignore b/.gitignore index d16067cdd..532a373a1 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,22 @@ test_data/ #Conan created files CMakeUserPresets.json + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json diff --git a/docs/.gitignore b/docs/.gitignore index 64bc485be..fd39b782c 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,22 +1,3 @@ _build _static _templates - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json diff --git a/software/common/base.sh b/software/common/base.sh index 7ca60a10f..515f97c08 100755 --- a/software/common/base.sh +++ b/software/common/base.sh @@ -80,6 +80,18 @@ function clean_dir() { fi } +function create_clean_dir() { + dir_name=$1 + clean_dir "$dir_name" + if mkdir "$dir_name"; then + echo "Clean directory created: $dir_name" + return "$EXIT_SUCCESS" + else + echo "Creating directory failed: $dir_name" + return "$EXIT_FAILURE" + fi +} + function install_py() { sudo apt update sudo apt install -y \ diff --git a/software/controller/controller.sh b/software/controller/controller.sh index 61bbdd3de..04b7f67a9 100755 --- a/software/controller/controller.sh +++ b/software/controller/controller.sh @@ -180,12 +180,16 @@ generate_coverage_reports() { } +function run_debug() { + ../debug/debug.sh "$@" +} + # prints info from device manifest, if SN is defined in environment print_device_info() { if [ -n "$SN" ] then echo "SN has been defined in environment, will be deploying to the following device:" - ../debug/debug.sh -c "device find $SN" + run_debug -c "device find $SN" fi } @@ -193,7 +197,7 @@ print_device_info() { # prints ST-Link serial number by defined alias get_hla_serial() { device_alias="$1" - ../debug/debug.sh -c "device find $device_alias h" + run_debug -c "device find $device_alias h" } # build @@ -408,9 +412,9 @@ elif [ "$1" == "debug" ]; then shift if [ -n "$SN" ] then - ../debug/debug.sh -d "$SN" "$@" + run_debug -d "$SN" "$@" else - ../debug/debug.sh "$@" + run_debug "$@" fi exit_good @@ -442,7 +446,7 @@ elif [ "$1" == "integrate" ]; then # DEVICES # ########### elif [ "$1" == "devices" ]; then - ../debug/debug.sh -c "device list" + run_debug -c "device list" exit_good ################ diff --git a/software/debug/.gitignore b/software/debug/.gitignore index d4637b29c..4adbb7927 100644 --- a/software/debug/.gitignore +++ b/software/debug/.gitignore @@ -1,21 +1,2 @@ # generated network protocol code debug/protocols/* - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json diff --git a/software/debug/debug.sh b/software/debug/debug.sh index d451e3d62..6763debb5 100755 --- a/software/debug/debug.sh +++ b/software/debug/debug.sh @@ -8,29 +8,22 @@ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -# Fail if any command fails -set -e -set -o pipefail - -# Print each command as it executes -if [ -n "$VERBOSE" ]; then - set -o xtrace -fi - # Silent pushd -pushd () { - command pushd "$@" > /dev/null +function pushd() { + command pushd "$@" > /dev/null } # Silent popd -popd () { - command popd > /dev/null +function popd() { + command popd > /dev/null } - # This script should work no matter where you call it from. MY_PATH="$(dirname "$0")" pushd $MY_PATH -PYTHONPATH=$MY_PATH ./debug_cli.py "${@:1}" + +poetry install --no-root --quiet +poetry run debug "${@:1}" + popd diff --git a/software/gui/gui.sh b/software/gui/gui.sh index e60678ea1..3137923d3 100755 --- a/software/gui/gui.sh +++ b/software/gui/gui.sh @@ -84,7 +84,7 @@ configure_conan() { } run_cppcheck() { - clean_dir build/cppcheck + create_clean_dir build/cppcheck cppcheck --enable=all --std=c++17 --inconclusive --force --inline-suppr --quiet \ --enable=information --check-config \ -I ../common/generated_libs/protocols \ @@ -220,7 +220,7 @@ elif [ "$1" == "build" ]; then checks_opt="no" fi - clean_dir build + create_clean_dir build pushd build if [ "$checks_opt" == "yes" ]; then @@ -268,7 +268,7 @@ elif [ "$1" == "test" ]; then j_opt="-j${NUM_CPUS}" fi - clean_dir build + create_clean_dir build pushd build cmake -DCMAKE_BUILD_TYPE=Debug -DCOV=1 ..