me
/
guix
Archived
1
0
Fork 0

gnu: onionshare: Update to 2.5 and disable tests.

* gnu/packages/tor.scm (onionshare): Update to 2.5.
[tests?]: Set to #f.
[phases]: Use gexps.
{patch-tests}: Delete phase.
{check}: Invoke pytest through xvfb-run.
master
Maxim Cournoyer 2022-07-11 23:47:21 -04:00
parent b54a243ec1
commit aedd7dc8e0
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 44 additions and 73 deletions

View File

@ -11,6 +11,7 @@
;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2020 André Batista <nandre@riseup.net> ;;; Copyright © 2020 André Batista <nandre@riseup.net>
;;; Copyright © 2021 Danial Behzadi <dani.behzi@ubuntu.com> ;;; Copyright © 2021 Danial Behzadi <dani.behzi@ubuntu.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -53,7 +54,8 @@
#:use-module (gnu packages qt) #:use-module (gnu packages qt)
#:use-module (gnu packages autotools) #:use-module (gnu packages autotools)
#:use-module (gnu packages tls) #:use-module (gnu packages tls)
#:use-module (gnu packages w3m)) #:use-module (gnu packages w3m)
#:use-module (gnu packages xorg))
(define-public tor (define-public tor
(package (package
@ -312,88 +314,57 @@ OnionShare.")
(license (list license:gpl3+ license:expat)))) (license (list license:gpl3+ license:expat))))
(define-public onionshare (define-public onionshare
(package (inherit onionshare-cli) (package
(inherit onionshare-cli)
(name "onionshare") (name "onionshare")
(arguments (arguments
(substitute-keyword-arguments (package-arguments onionshare-cli) (substitute-keyword-arguments (package-arguments onionshare-cli)
((#:phases phases) ((#:phases phases)
`(modify-phases ,phases #~(modify-phases #$phases
(replace 'change-directory (replace 'change-directory
(lambda _ (chdir "desktop/src"))) (lambda _ (chdir "desktop/")))
(add-after 'unpack 'patch-tests (add-after 'install 'install-data
(lambda _ (lambda _
;; Disable tests that require starting servers, which will hang (install-file "org.onionshare.OnionShare.svg"
;; during build: (string-append #$output
;; - test_autostart_and_autostop_timer_mismatch "/share/icons/hicolor/scalable/apps"))
;; - test_autostart_timer (install-file "org.onionshare.OnionShare.desktop"
;; - test_autostart_timer_too_short (string-append #$output
;; - test_autostop_timer_too_short "/share/applications"))))
(substitute* "desktop/tests/test_gui_share.py" (replace 'check
(("import os" &) (lambda* (#:key tests? #:allow-other-keys)
(string-append "import pytest\n" &)) (when tests?
(("( *)def test_autost(art|op)_(timer(_too_short)?|and_[^(]*)\\(" & >) ;; Remove multiline load-path adjustment, so that
(string-append > "@pytest.mark.skip\n" &))) ;; onionshare-cli modules are loaded from input
;; - test_13_quit_with_server_started_should_warn (substitute* "tests/conftest.py"
(substitute* "desktop/tests/test_gui_tabs.py" (("\"cli\",")
(("import os" &) "\"/nonexistent\""))
(string-append "import pytest\n" &)) ;; Avoid `getprotobyname` issues:
(("( *)def test_13" & >) (setenv "EVENTLET_NO_GREENDNS" "yes")
(string-append > "@pytest.mark.skip\n" &))) ;; Make Qt render "offscreen":
;; Remove multiline load-path adjustment, so that onionshare-cli (setenv "QT_QPA_PLATFORM" "offscreen")
;; modules are loaded from input (setenv "HOME" "/tmp")
(use-modules (ice-9 regex) (apply invoke "xvfb-run" "pytest" "-vv"
(ice-9 rdelim)) (find-files "tests" "^test_gui.*\\.py$")))))))
(with-atomic-file-replacement "desktop/tests/conftest.py" ;; Most tests fail: "2 failed, 8 warnings, 44 errors in 6.06s", due to
(let ((start-rx (make-regexp "^# Allow importing"))) ;; error "RuntimeError: Please destroy the Application singleton before
(lambda (in out) ;; creating a new Application instance." (see:
(let loop () ;; https://github.com/onionshare/onionshare/issues/1603).
(let ((line (read-line in 'concat))) ((#:tests? _ #f)
(if (regexp-exec start-rx line) #f)))
(begin ; slurp until closing paren
(let slurp ()
(let ((line (read-line in 'concat)))
(if (string=? line ")\n")
(dump-port in out) ; done
(slurp)))))
(begin
(display line out)
(loop))))))))))
(replace 'check
(lambda* (#:key tests? inputs outputs #:allow-other-keys)
(when tests?
;; Some tests need a writable homedir:
(setenv "HOME" "/tmp")
;; Ensure installed modules can be found:
(add-installed-pythonpath inputs outputs)
;; Avoid `getprotobyname` issues:
(setenv "EVENTLET_NO_GREENDNS" "yes")
;; Make Qt render "offscreen":
(setenv "QT_QPA_PLATFORM" "offscreen")
;; Must be run from "desktop" dir:
(with-directory-excursion ".."
(invoke "./tests/run.sh")))))
(add-after 'install 'install-data
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(share (string-append out "/share")))
(install-file "org.onionshare.OnionShare.svg"
(string-append share "/icons/hicolor/scalable/apps"))
(install-file "org.onionshare.OnionShare.desktop"
(string-append share "/applications")))))))))
(native-inputs (native-inputs
(list python-pytest)) (list python-pytest))
(inputs (inputs
;; TODO: obfs4proxy ;; The desktop client uses onionshare-cli like a python module. But
;; propagating onionshare-cli's inputs is not great, since a user would
;; not expect to have those installed when using onionshare-cli as a
;; standalone utility. So add onionshare-cli's inputs here.
(modify-inputs (package-inputs onionshare-cli) (modify-inputs (package-inputs onionshare-cli)
(prepend onionshare-cli (prepend onionshare-cli ;TODO: package obfs4proxy
python-shiboken-2 python-shiboken-2
python-pyside-2 python-pyside-2
python-qrcode python-qrcode
;; The desktop client uses onionshare-cli like a python module. But xvfb-run)))
;; propagating onionshare-cli's inputs is not great, since a user would
;; not expect to have those installed when using onionshare-cli as a
;; standalone utility. So add onionshare-cli's inputs here.
)))
(description "OnionShare lets you securely and anonymously share files, (description "OnionShare lets you securely and anonymously share files,
host websites, and chat with friends using the Tor network."))) host websites, and chat with friends using the Tor network.")))