diff options
author | Fredrik Salomonsson <plattfot@posteo.net> | 2021-01-31 11:51:59 -0800 |
---|---|---|
committer | Fredrik Salomonsson <plattfot@posteo.net> | 2021-01-31 16:55:15 -0800 |
commit | f70cb0343bbe64eb733a6a56ef071ed731d5f62a (patch) | |
tree | 4c9254afad015e3be2af51f1c5b925edb7c72fba /tests | |
parent | ccc8e77924e0def27340db05c969d94395a11707 (diff) | |
download | pinentry-rofi-f70cb0343bbe64eb733a6a56ef071ed731d5f62a.tar.gz |
Add logic for passing locale to rofi
Using the options `lc-ctype` and `lc-messages` to set the LC_ALL
option that is then set in the environment when calling rofi. Having
issues with rofi failing to set locale when using guix.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/pinentry-rofi.scm | 106 |
1 files changed, 77 insertions, 29 deletions
diff --git a/tests/pinentry-rofi.scm b/tests/pinentry-rofi.scm index b0b7b87..ac159b1 100755 --- a/tests/pinentry-rofi.scm +++ b/tests/pinentry-rofi.scm @@ -27,7 +27,7 @@ (test-begin "pinentry-rofi") ;; (test-begin "pinentry") -(let ((pinentry (make-pinentry #t "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #t "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry? pinentry)) (test-assert (pinentry-ok pinentry)) (test-equal "Prompt" (pinentry-prompt pinentry)) @@ -39,7 +39,7 @@ (test-assert (not (pinentry-visibility pinentry))) (test-assert (not (pinentry-error pinentry)))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (not (pinentry-ok pinentry)))) ;; (test-end "pinentry") @@ -97,44 +97,68 @@ (test-equal "Ok\n_Cancel" (input-string "_Ok\n__Cancel")) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (pinentry-set set-pinentry-notok-button! pinentry "Not ok") (test-equal "Not ok" (pinentry-notok-button pinentry)) (test-assert (pinentry-ok pinentry))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-error #t (pinentry-set pinentry-notok-button pinentry "Not ok"))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-option pinentry "OPTION default-ok=Okay")) (test-equal "Okay" (pinentry-ok-button pinentry)) (test-equal "Cancel" (pinentry-cancel-button pinentry)) (test-equal "Prompt" (pinentry-prompt pinentry)) + (test-equal "C" (pinentry-lc-ctype pinentry)) + (test-equal "C" (pinentry-lc-messages pinentry)) (test-assert (pinentry-ok pinentry))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-option pinentry "OPTION default-cancel=No")) (test-equal "Ok" (pinentry-ok-button pinentry)) (test-equal "No" (pinentry-cancel-button pinentry)) (test-equal "Prompt" (pinentry-prompt pinentry)) + (test-equal "C" (pinentry-lc-ctype pinentry)) + (test-equal "C" (pinentry-lc-messages pinentry)) (test-assert (pinentry-ok pinentry))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-option pinentry "OPTION default-prompt=Password:")) (test-equal "Ok" (pinentry-ok-button pinentry)) (test-equal "Cancel" (pinentry-cancel-button pinentry)) (test-equal "Password:" (pinentry-prompt pinentry)) + (test-equal "C" (pinentry-lc-ctype pinentry)) + (test-equal "C" (pinentry-lc-messages pinentry)) (test-assert (pinentry-ok pinentry))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) + (test-assert (pinentry-option pinentry "OPTION lc-ctype=en_US.UTF-8")) + (test-equal "Ok" (pinentry-ok-button pinentry)) + (test-equal "Cancel" (pinentry-cancel-button pinentry)) + (test-equal "Prompt" (pinentry-prompt pinentry)) + (test-equal "en_US.UTF-8" (pinentry-lc-ctype pinentry)) + (test-equal "C" (pinentry-lc-messages pinentry)) + (test-assert (pinentry-ok pinentry))) + +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) + (test-assert (pinentry-option pinentry "OPTION lc-messages=en_US.UTF-8")) + (test-equal "Ok" (pinentry-ok-button pinentry)) + (test-equal "Cancel" (pinentry-cancel-button pinentry)) + (test-equal "Prompt" (pinentry-prompt pinentry)) + (test-equal "C" (pinentry-lc-ctype pinentry)) + (test-equal "en_US.UTF-8" (pinentry-lc-messages pinentry)) + (test-assert (pinentry-ok pinentry))) + +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-option pinentry "OPTION foo bar"))) -(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (not (pinentry-option pinentry " OPTION foo bar"))) (test-assert (not (pinentry-option pinentry "OPTION"))) (test-assert (not (pinentry-option pinentry "Foo")))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log")) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C")) (output "") (fake-port (make-soft-port (vector @@ -151,14 +175,14 @@ (test-assert (not (pinentry-getinfo pinentry "GETINFO"))) (test-assert (not (pinentry-getinfo pinentry "Foo")))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-setkeyinfo pinentry "SETKEYINFO Foo")) (test-assert (pinentry-ok pinentry)) (test-assert (not (pinentry-setkeyinfo pinentry " SETKEYINFO foo bar"))) (test-assert (not (pinentry-setkeyinfo pinentry "SETKEYINFO"))) (test-assert (not (pinentry-setkeyinfo pinentry "Foo")))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-setok pinentry "SETOK Foo")) (test-equal "Foo" (pinentry-ok-button pinentry)) (test-assert (pinentry-ok pinentry)) @@ -171,7 +195,7 @@ (test-assert (not (pinentry-setok pinentry "Foo"))) (test-equal "Ok okay" (pinentry-ok-button pinentry))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-setnotok pinentry "SETNOTOK Foo")) (test-equal "Foo" (pinentry-notok-button pinentry)) (test-assert (pinentry-ok pinentry)) @@ -184,7 +208,7 @@ (test-assert (not (pinentry-setnotok pinentry "Foo"))) (test-equal "Not Ok" (pinentry-notok-button pinentry))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C"))) (test-assert (pinentry-setcancel pinentry "SETCANCEL Foo")) (test-equal "Foo" (pinentry-cancel-button pinentry)) (test-assert (pinentry-ok pinentry)) @@ -197,7 +221,7 @@ (test-assert (not (pinentry-setcancel pinentry "Foo"))) (test-equal "Abort" (pinentry-cancel-button pinentry))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Desc" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Desc" ":1" "test.log" "C" "C"))) (test-assert (pinentry-setdesc pinentry "SETDESC Foo")) (test-equal "Foo" (pinentry-desc pinentry)) (test-assert (pinentry-ok pinentry)) @@ -210,7 +234,7 @@ (test-assert (not (pinentry-setdesc pinentry "Foo"))) (test-equal "<u>T</u>his is a description <u>O</u>n two lines" (pinentry-desc pinentry))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Error" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Error" ":1" "test.log" "C" "C"))) (test-assert (pinentry-seterror pinentry "SETERROR Foo")) (test-equal "Foo" (pinentry-error pinentry)) (test-assert (pinentry-ok pinentry)) @@ -223,7 +247,7 @@ (test-assert (not (pinentry-seterror pinentry "Foo"))) (test-equal "<u>T</u>his is an error <u>O</u>n two lines" (pinentry-error pinentry))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Prompt" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Prompt" ":1" "test.log" "C" "C"))) (test-assert (pinentry-setprompt pinentry "SETPROMPT Foo")) (test-equal "Foo" (pinentry-prompt pinentry)) (test-assert (pinentry-ok pinentry)) @@ -236,11 +260,11 @@ (test-assert (not (pinentry-setprompt pinentry "Foo"))) (test-equal "<u>T</u>his is a prompt <u>O</u>n two lines" (pinentry-prompt pinentry))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Prompt" ":1" "test.log"))) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Prompt" ":1" "test.log" "C" "C"))) (test-error "(quit #t)" (pinentry-bye pinentry "BYE")) (test-assert (not (pinentry-bye pinentry "Hej då")))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log")) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8")) (output "") (fake-port (make-soft-port (vector @@ -267,7 +291,10 @@ (test-assert (not visibility)) (test-assert (not only-match)) (test-assert (not buttons)) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "password") #:port fake-port)) (test-equal (format #f "D password") output) @@ -286,7 +313,10 @@ (test-assert (not visibility)) (test-assert (not only-match)) (test-assert (not buttons)) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "password") #:port fake-port)) (test-equal (format #f "D password") output) @@ -304,7 +334,10 @@ (test-assert (not visibility)) (test-assert (not only-match)) (test-assert (not buttons)) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "") #:port fake-port)) (test-equal (format #f "ERR 83886179 Operation cancelled <rofi>\n") output) @@ -322,14 +355,17 @@ (test-assert (not visibility)) (test-assert (not only-match)) (test-assert (not buttons)) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) " ") #:port fake-port)) (test-equal (format #f "ERR 83886179 Operation cancelled <rofi>\n") output) (test-assert (not (pinentry-getinfo pinentry " GETPIN"))) (test-assert (not (pinentry-getinfo pinentry "Foo")))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log")) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8")) (description "This is a description") (error "Something went wrong") (display ":1")) @@ -347,7 +383,10 @@ (test-assert visibility) (test-assert only-match) (test-equal `("Ok" "Cancel") buttons) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "Ok"))) (test-assert (pinentry-ok pinentry)) (set-pinentry-error! pinentry error) @@ -375,7 +414,10 @@ (test-assert visibility) (test-assert only-match) (test-equal `("Ok" "Cancel") buttons) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "Cancel") #:port fake-port)) (test-equal (format #f "ERR 277 Operation cancelled\n") output)) @@ -383,7 +425,7 @@ (test-assert (not (pinentry-getinfo pinentry " CONFIRM"))) (test-assert (not (pinentry-getinfo pinentry "Foo")))) -(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log")) +(let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8")) (description "This is a description") (display ":1")) (set-pinentry-desc! pinentry description) @@ -400,7 +442,10 @@ (test-assert visibility) (test-assert only-match) (test-equal `("Ok") buttons) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "Ok"))) (test-assert (pinentry-ok pinentry)) (set-pinentry-ok! pinentry #f) @@ -416,7 +461,10 @@ (test-assert visibility) (test-assert only-match) (test-equal `("Ok") buttons) - (test-equal `(("DISPLAY" . ,display)) env) + (test-equal `(("DISPLAY" . ,display) + ("LC_CTYPE" . "C") + ("LC_MESSAGES" . "en_US.UTF-8")) + env) "Ok"))) (test-assert (pinentry-ok pinentry)) (test-assert (not (pinentry-getinfo pinentry " CONFIRM --one-button"))) |