From ca8c5bba4c53ef34a3b0ee972d65f7aa6013f036 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Fri, 4 Jun 2021 11:23:48 +0530 Subject: [PATCH] tests: functional: Get rid of dependency on xvfb This removes the dependencies xvfb and pytest-xvfb. --splinter-headless can be used as a substitute for running tests in headless mode. [sunil: Edit description as running run-tests starts plinth in container] [sunil: Retain the xauth command] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa Reviewed-by: Sunil Mohan Adapa --- HACKING.md | 17 +++++++++++++---- container | 2 +- plinth/tests/functional/install.sh | 5 ++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/HACKING.md b/HACKING.md index d54b2936f..90634c718 100644 --- a/HACKING.md +++ b/HACKING.md @@ -71,13 +71,23 @@ development environment inside a systemd-nspawn container. host$ ./container up ``` -4. To run unit and functional tests for an app: +1. To run unit tests: ```bash - host$ ./container run-tests --pytest-args -v --include-functional --no-xvfb plinth/modules/{app name} + host$ ./container run-tests ``` -5. SSH into the running container with the following command: +1. To run unit and functional tests for an app: + + ```bash + host$ ./container run-tests --pytest-args -v --include-functional --splinter-headless plinth/modules/{app-name} + ``` + + Drop the option `--splinter-headless` if you want to see the tests running + in browser windows. Not specifying a module in the above command would run + functional tests for all the apps and also unit tests. + +1. SSH into the running container with the following command: ```bash host$ ./container ssh @@ -443,7 +453,6 @@ host$ pip3 install splinter host$ pip3 install pytest-splinter host$ pip3 install pytest-xdist # optional, to run tests in parallel host$ sudo apt install firefox -host$ sudo apt install xvfb python3-pytest-xvfb # optional, to avoid opening browser windows host$ sudo apt install smbclient # optional, to test samba ``` diff --git a/container b/container index 95ede7667..56c536868 100755 --- a/container +++ b/container @@ -227,7 +227,7 @@ then echo fi - if [[ "{pytest_command}" =~ "--no-xvfb" ]] + if [[ "{pytest_command}" != *"--splinter-headless"* ]] then # Use the X11 authority file from the fbx user to run GUI programs xauth merge /home/fbx/.Xauthority diff --git a/plinth/tests/functional/install.sh b/plinth/tests/functional/install.sh index 6b8932627..846fa9b9c 100755 --- a/plinth/tests/functional/install.sh +++ b/plinth/tests/functional/install.sh @@ -5,10 +5,9 @@ IFS=$'\n\t' echo "Installing requirements" sudo apt-get install -yq --no-install-recommends \ python3-pytest python3-pytest-django python3-pytest-xdist \ - python3-pip python3-wheel firefox-esr git smbclient\ - xvfb + python3-pip python3-wheel firefox-esr git smbclient -pip3 install splinter pytest-splinter pytest-xvfb pytest-reporter-html1 +pip3 install --user splinter pytest-splinter pytest-reporter-html1 echo "Installing geckodriver" (