Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
scripts:check-script [2020/04/20 19:10] – créée erreur32 | scripts:check-script [2022/11/08 16:43] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 7: | Ligne 7: | ||
We have a simple **stat.sh** script: | We have a simple **stat.sh** script: | ||
- | <code> | + | <sxh sh; title: simple stat.sh script> |
# | # | ||
Ligne 22: | Ligne 22: | ||
echo " | echo " | ||
echo " | echo " | ||
- | </code> | + | |
+ | </sxh> | ||
This script evaluate the number of python files and the number of python code lines in the files. | This script evaluate the number of python files and the number of python code lines in the files. | ||
Ligne 31: | Ligne 33: | ||
Then make test suits for **stat.sh**. We make a directory **testsuit** which contain test python files. | Then make test suits for **stat.sh**. We make a directory **testsuit** which contain test python files. | ||
- | **testsuit/ | + | <sxh sh; title: |
- | <code> | + | |
import foo | import foo | ||
print(foo) | print(foo) | ||
- | </code> | + | |
+ | </sxh> | ||
**testsuit/ | **testsuit/ | ||
- | <code> | + | <sxh sh; title: testsuit/ |
BAR = 1 | BAR = 1 | ||
BUZ = BAR + 2 | BUZ = BAR + 2 | ||
- | </code> | + | |
+ | </sxh> | ||
Ok! Our test suit is ready! | Ok! Our test suit is ready! | ||
Ligne 52: | Ligne 57: | ||
Create file **tests.bashtest**: | Create file **tests.bashtest**: | ||
- | <code> | + | <cli> |
$ ./stat.sh testsuit/ | $ ./stat.sh testsuit/ | ||
Evaluate *.py statistics | Evaluate *.py statistics | ||
Ligne 58: | Ligne 63: | ||
PYTHON LINES: | PYTHON LINES: | ||
- | </code> | + | </cli> |
This is our test! This is simple. Try to run it. | This is our test! This is simple. Try to run it. | ||
- | <code> | + | <sxh sh> |
# install bashtest if required! | # install bashtest if required! | ||
$ pip install bashtest | $ pip install bashtest | ||
- | </code> | + | |
+ | </sxh> | ||
- | <code> | + | <sxh sh> |
+ | |||
# run tests | # run tests | ||
$ bashtest *.bashtest | $ bashtest *.bashtest | ||
Ligne 75: | Ligne 83: | ||
1 passed and 0 failed. | 1 passed and 0 failed. | ||
Test passed. | Test passed. | ||
- | </code> | + | |
+ | </sxh> | ||
Thats all. We wrote one test. You can write more tests if you want. | Thats all. We wrote one test. You can write more tests if you want. | ||
Ligne 105: | Ligne 114: | ||
Happy testing! | Happy testing! | ||
+ | {{tag> |