Skip to content

✨ Add help menu and ability to run specific tests for validatecodeonce #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 21 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
8 changes: 7 additions & 1 deletion test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down