Skip to content

Commit eed3bbe

Browse files
Merge pull request #362 from SatelCreative/fix/validatecodeonce_options
🐛 Fix issue with validatecodeonce options, ✨ add help menu and ability to run specific tests for validatecode
2 parents 31cce71 + 4d38222 commit eed3bbe

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ ENTRYPOINT ["/python/entrypoint.sh"]
1515

1616
# Add convenient aliases
1717
# Install python packages
18-
RUN echo "#!/bin/bash\n/python/entrypoint.sh startapp" >> /bin/startapp && chmod a+x /bin/startapp \
19-
&& echo "#!/bin/bash\n/python/entrypoint.sh developapp" >> /bin/developapp && chmod a+x /bin/developapp \
20-
&& echo "#!/bin/bash\n/python/entrypoint.sh validatecode" >> /bin/validatecode && chmod a+x /bin/validatecode \
21-
&& echo "#!/bin/bash\n/python/entrypoint.sh validatecodeonce" >> /bin/validatecodeonce && chmod a+x /bin/validatecodeonce \
22-
&& echo "#!/bin/bash\n/python/entrypoint.sh runtests" >> /bin/runtests && chmod a+x /bin/runtests
18+
RUN echo "#!/bin/bash\n/python/entrypoint.sh startapp \$@" >> /bin/startapp && chmod a+x /bin/startapp \
19+
&& echo "#!/bin/bash\n/python/entrypoint.sh developapp \$@" >> /bin/developapp && chmod a+x /bin/developapp \
20+
&& echo "#!/bin/bash\n/python/entrypoint.sh validatecode \$@" >> /bin/validatecode && chmod a+x /bin/validatecode \
21+
&& echo "#!/bin/bash\n/python/entrypoint.sh validatecodeonce \$@" >> /bin/validatecodeonce && chmod a+x /bin/validatecodeonce \
22+
&& echo "#!/bin/bash\n/python/entrypoint.sh runtests \$@" >> /bin/runtests && chmod a+x /bin/runtests
2323
# Change users
2424
USER python
2525

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ plugin.
116116
This code validation command executes the `/python/test_suite.sh` script which can
117117
be overwritten with custom code validation.
118118

119+
Options:\
120+
`-h` Print help menu.
121+
```
122+
validatecode -h
123+
```
124+
`-k` Invoke Pytest option `-k` to run specific tests based on a substring match to the test name.
125+
```
126+
validatecode -k test_get_products
127+
```
128+
119129
### `validatecodeonce`
120130

121131
Same as `validatecode` but executed once rather than continously running on

entrypoint.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,29 @@ developapp() {
4545

4646

4747
validatecode() {
48+
help() {
49+
echo
50+
echo "Usage: validatecode [-h|k]"
51+
echo
52+
echo "Automatically run code validation whenever the code changes."
53+
echo
54+
echo "Options:"
55+
echo "h Print this help menu."
56+
echo "k Invoke Pytest option -k to run specific tests based on a substring match to the test name."
57+
echo
58+
}
59+
60+
while getopts ":h" option; do
61+
case $option in
62+
h)
63+
help
64+
exit;;
65+
esac
66+
done
67+
4868
echo -e "\nREADY TO RUN THE CODE VALIDATION SUITE\nSave a python file to trigger the checks."
49-
5069
loadconfig
51-
watchmedo shell-command --patterns="*.py;*.txt" --recursive --command="/python/test_suite.sh" --drop .
70+
watchmedo shell-command --patterns="*.py;*.txt" --recursive --command="/python/test_suite.sh \$@" --drop .
5271
}
5372

5473
validatecodeonce() {

0 commit comments

Comments
 (0)