#!/bin/bash

source env/bin/activate
echo ""
echo "checking for linting errors"
flake8 --select E,W --max-line-length=140 --ignore E722,W503,W504,E128 jarviscli/ installer
echo "lint errors checked"
echo ""
cd jarviscli/
echo "checking for unit test"
python3 -m unittest discover
echo "unit tests checked"
echo ""
cd ..

#!/bin/bash

source env/bin/activate
echo ""
echo "checking for linting errors"
flake8 --select E,W --max-line-length=140 --ignore E722,W503,W504,E128 jarviscli/ installer
echo "lint errors checked"
echo ""
(
cd jarviscli || exit
echo "checking for unit test"
python3 -m unittest discover
echo "unit tests checked"
echo ""
cd ..
)

Fix scenario when cd fails before other commands
Fix scenario when cd fails before other commands

Change 'unittest discover' call to run in a Sub-shell.

if sequences such as 'cd dir; do something; cd ..', if 'cd dir' happen to fail (e.g. if dir was deleted or user lacks permission to access it), 'do something' will be executed in the wrong directory producing unwanted results.
