Adds bash script to run GUI tests individually

This commit is contained in:
Saptak S 2020-04-02 04:19:50 +05:30
parent 145021b2e5
commit d417754e45
No known key found for this signature in database
GPG Key ID: 2D9B32E54C68A3FB
4 changed files with 32 additions and 5 deletions

View File

@ -51,7 +51,7 @@ jobs:
- run:
name: Run unit tests
command: |
xvfb-run -s "-screen 0 1280x1024x24" poetry run pytest --rungui -vvv --no-qt-log tests/
xvfb-run -s "-screen 0 1280x1024x24" poetry run ./tests/run.sh --rungui
test-3.7:
<<: *test-template

View File

@ -267,19 +267,19 @@ This will prompt you to codesign three binaries and execute one unsigned binary.
OnionShare includes PyTest unit tests. To run tests, you can run `pytest` against the `tests/` directory.
```sh
poetry run pytest tests/
poetry run ./tests/run.sh
```
You can run GUI tests like this:
```sh
poetry run pytest --rungui tests/
poetry run ./tests/run.sh --rungui
```
If you would like to also run the GUI unit tests in 'tor' mode, start Tor Browser in the background, then run:
```sh
poetry run pytest --rungui --runtor tests/
poetry run ./tests/run.sh --rungui --runtor
```
Keep in mind that the Tor tests take a lot longer to run than local mode, but they are also more comprehensive.
@ -287,7 +287,7 @@ Keep in mind that the Tor tests take a lot longer to run than local mode, but th
You can also choose to wrap the tests in `xvfb-run` so that a ton of OnionShare windows don't pop up on your desktop (you may need to install the `xorg-x11-server-Xvfb` package), like this:
```sh
xvfb-run poetry run pytest --rungui -vvv --no-qt-log tests/
xvfb-run poetry run ./tests/run.sh --rungui
```
# Making releases

View File

@ -71,6 +71,7 @@ class GuiBaseTest(unittest.TestCase):
@classmethod
def tearDownClass(cls):
# Quit
cls.gui.qtapp.clipboard().clear()
QtCore.QTimer.singleShot(200, cls.gui.close_dialog.accept_button.click)
cls.gui.close()

26
tests/run.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# The script runs python tests
# Firstly, all CLI tests are run
# Then, all the GUI tests are run individually
# to avoid segmentation fault
PARAMS=""
while [ ! $# -eq 0 ]
do
case "$1" in
--rungui)
PARAMS="$PARAMS --rungui"
;;
--runtor)
PARAMS="$PARAMS --runtor"
;;
esac
shift
done
pytest $PARAMS -vvv ./tests/test_cli*.py
for filename in ./tests/test_gui_*.py; do
pytest $PARAMS -vvv --no-qt-log $filename
done