diff --git a/README.md b/README.md index cfcecfd..fc6f360 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,16 @@ code change. This can be used for CI/CD purposes since it generates report files in the `/python/reports` folder. +Options:\ +`-h` Print help menu. +``` +validatecodeonce -h +``` +`-k` Invoke Pytest option `-k` to run specific tests based on a substring match to the test name. +``` +validatecodeonce -k test_get_products +``` + ### `runtests` (DEPRECATED) **DEPRECATED**: Use `validatecodeonce` instead diff --git a/entrypoint.sh b/entrypoint.sh index 20dad62..f879636 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -52,10 +52,29 @@ validatecode() { } validatecodeonce() { + help() { + echo + echo "Usage: validatecodeonce [-h|k]" + echo + echo "Trigger a single run of code validation." + echo + echo "Options:" + echo "h Print this help menu." + echo "k Invoke Pytest option -k to run specific tests based on a substring match to the test name." + echo + } + + while getopts ":h" option; do + case $option in + h) + help + exit;; + esac + done + echo -e "\nTriggering single run of code validation." - loadconfig - ../test_suite.sh reports + ../test_suite.sh $@ reports } diff --git a/test_suite.sh b/test_suite.sh index 662f46b..d1f7c07 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -3,6 +3,12 @@ REPORTS_FOLDER="/python/reports/" SECTION_PREFIX="\n#########" +while getopts ":k:" option; do + case $option in + k) + SPECIFIC_TESTS="-k ${OPTARG}" + esac +done checkuser() { WHOAMI=`whoami` @@ -35,7 +41,7 @@ then fi echo -ne "$SECTION_PREFIX RUN TESTS:\n\n" -python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS; STATUS1=$? +python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS $SPECIFIC_TESTS; STATUS1=$? echo -ne "$SECTION_PREFIX CHECK DOCKER USER IS PYTHON: " USEROUT=`checkuser`