Adds bash script to run GUI tests individually

This commit is contained in:
Saptak S 2020-04-02 04:19:50 +05:30
parent b129ffba86
commit acd41b3b70
4 changed files with 32 additions and 5 deletions

View File

@ -51,7 +51,7 @@ jobs:
- run: - run:
name: Run unit tests name: Run unit tests
command: | 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-3.7:
<<: *test-template <<: *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. OnionShare includes PyTest unit tests. To run tests, you can run `pytest` against the `tests/` directory.
```sh ```sh
poetry run pytest tests/ poetry run ./tests/run.sh
``` ```
You can run GUI tests like this: You can run GUI tests like this:
```sh ```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: If you would like to also run the GUI unit tests in 'tor' mode, start Tor Browser in the background, then run:
```sh ```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. 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: 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 ```sh
xvfb-run poetry run pytest --rungui -vvv --no-qt-log tests/ xvfb-run poetry run ./tests/run.sh --rungui
``` ```
# Making releases # Making releases

View File

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