github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/static_analysis/lint_python.sh (about)

     1  run_compileall() {
     2  	rsync -r --exclude-from=acceptancetests/.gitignore acceptancetests "${TEST_DIR}/"
     3  	cp -R scripts "${TEST_DIR}/"
     4  
     5  	CURRENT_DIRECTORY=$(pwd)
     6  	cd "${TEST_DIR}" || exit
     7  	OUT=$(python3 -m compileall acceptancetests scripts -q 2>&1 || true)
     8  	cd "${CURRENT_DIRECTORY}" || exit
     9  
    10  	if [ -n "${OUT}" ]; then
    11  		echo ""
    12  		echo "$(red 'Found some issues:')"
    13  		echo "${OUT}"
    14  		exit 1
    15  	fi
    16  }
    17  
    18  test_static_analysis_python() {
    19  	if [ "$(skip 'test_static_analysis_python')" ]; then
    20  		echo "==> TEST SKIPPED: static python analysis"
    21  		return
    22  	fi
    23  
    24  	(
    25  		set_verbosity
    26  
    27  		cd .. || exit
    28  
    29  		# Shell static analysis
    30  		if which python3 >/dev/null 2>&1; then
    31  			run_linter "run_compileall"
    32  		else
    33  			echo "python3 not found, python static analysis disabled"
    34  		fi
    35  	)
    36  }