From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: dick.r.chiang@gmail.com Newsgroups: gmane.emacs.bugs Subject: bug#38825: no subject Date: Mon, 30 Dec 2019 16:58:57 -0500 Message-ID: <87sgl18ogu.fsf@dick> Mime-Version: 1.0 Content-Type: text/x-diff Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="243670"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 38825@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 30 23:00:28 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1im35P-0011Gp-Rj for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Dec 2019 23:00:27 +0100 Original-Received: from localhost ([::1]:36976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1im35F-0005ef-QH for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Dec 2019 17:00:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52650) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1im354-0005dt-0z for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 17:00:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1im352-0003va-4A for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 17:00:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1im351-0003tH-4E for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 17:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1im351-0003m4-2W for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 17:00:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: dick.r.chiang@gmail.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Dec 2019 22:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38825 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.157774314314397 (code B ref -1); Mon, 30 Dec 2019 22:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Dec 2019 21:59:03 +0000 Original-Received: from localhost ([127.0.0.1]:33559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1im343-0003k7-9s for submit@debbugs.gnu.org; Mon, 30 Dec 2019 16:59:03 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1im342-0003jy-Hq for submit@debbugs.gnu.org; Mon, 30 Dec 2019 16:59:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45766) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1im340-0005ai-TW for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 16:59:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1im33z-00022Q-Ce for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 16:59:00 -0500 Original-Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:39962) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1im33z-00021H-7k for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2019 16:58:59 -0500 Original-Received: by mail-qt1-x835.google.com with SMTP id e6so30526454qtq.7 for ; Mon, 30 Dec 2019 13:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version :content-disposition:content-description; bh=2MVTXgGy83VXFfByim6+W++nsKRd7cesqq7i9bd3DhU=; b=ZbYaM52shBb9jIVPIsVoxGQ0BVVinvE2rPjN+92ygVW5+vIi2vktiCRBY5yeG6v46z ew0X14+0oXdvguYfc8FS85kz71G0l7g4KzPFwzB+3lgsQUEmw9Q0+YH0PwpE+MU6b3O6 /GpIKjb1cnuozFsAQmuZWDG1gV+FFpnL/QoEzjlLsK/HHa/fOeiAht4gIFTAjJXPz7zd 12LMScIcX4e2fV3EPZVuv12Zb3qQAG45wSA8CuEGOdCgkEvnC8dC8iEvzrvbPfcgUXh5 LySO/Tfvy+W6wXGyQzAXm0EKdxA+qFCDw9S9BgEwfY4nZL80+5lBTDuzjt5cR+vcfezS 8N3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-disposition:content-description; bh=2MVTXgGy83VXFfByim6+W++nsKRd7cesqq7i9bd3DhU=; b=IyEzmoSnBQGicEF0WVxrf5EHBbveXWYUYzGAlP9cBOrIttDl51qs7qs5FzuKB/01qa eSwwEoE0c3wK/W4jz5OdR1uw6iKrJmK8iYPZmy/6nWduLkKFJdO2WnDoD5cbfABxvu6d Z5wBnsUTxRH2HyyLICEG64n041Ei9cDKVLo93n9bwG33oKLDSLTefGoJYVyann1d6CT0 ovfECpE1bVwiPbCxXLextTIsoks5GRtkD92qX1+gqdc2qh4mkMs+p9rxEnVv9g0dJOih cP27SeqDQrrduaUe2Mwomfsie4YVPHBtwvMbw6a8Af3VOtP+Lol9Ut5RRZgpnEUHu0Y6 OqXg== X-Gm-Message-State: APjAAAV8IymXcDBCPbTSq5Q4TxSrSXfjnhKWF7XcAnA4XLMrxwrru+1o oY/a2VUc7e6CSSIT0UtI2mOQwuo/ X-Google-Smtp-Source: APXvYqxvtGx9C5nJiAHTEavPfHBYzXTxQPb3ibFHniHm7bQiwAYOzwcqsIwgVWGvDuy0LnQxYVBZVw== X-Received: by 2002:ac8:36f5:: with SMTP id b50mr51256773qtc.268.1577743138361; Mon, 30 Dec 2019 13:58:58 -0800 (PST) Original-Received: from localhost (pool-100-33-98-8.nycmny.fios.verizon.net. [100.33.98.8]) by smtp.gmail.com with ESMTPSA id x24sm14315690qtx.1.2019.12.30.13.58.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Dec 2019 13:58:57 -0800 (PST) Content-Disposition: inline; filename=0001-Terminate-comint-password-function-tests.patch Content-Description: patch X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173968 Archived-At: >From 7d9c0dd38e1581070adaa55fc1e6d4d99133c395 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 30 Dec 2019 16:35:28 -0500 Subject: [PATCH] Terminate `comint-password-function' tests * test/lisp/comint-tests.el (comint-test-no-password-function, comint-test-password-function-with-value, comint-test-password-function-with-nil): refactor (comint-tests/test-password-function): actually test `comint-send-invisible' and inhibit inadvertent interactive query --- test/lisp/comint-tests.el | 77 +++++++++++---------------------------- 1 file changed, 21 insertions(+), 56 deletions(-) diff --git a/test/lisp/comint-tests.el b/test/lisp/comint-tests.el index c04134599f..29787d980d 100644 --- a/test/lisp/comint-tests.el +++ b/test/lisp/comint-tests.el @@ -52,73 +52,38 @@ comint-testsuite-password-strings (dolist (str comint-testsuite-password-strings) (should (string-match comint-password-prompt-regexp str)))) -(ert-deftest comint-test-no-password-function () - "Test that `comint-password-function' not being set does not -alter normal password flow." - (cl-letf - (((symbol-function 'read-passwd) - (lambda (_prompt &optional _confirm _default) - "PaSsWoRd123"))) - (let ((cat (executable-find "cat"))) - (when cat +(defun comint-tests/test-password-function (password-function) + "PASSWORD-FUNCTION can return nil or a string." + (when-let ((cat (executable-find "cat"))) + (let ((comint-password-function password-function)) + (cl-letf (((symbol-function 'read-passwd) + (lambda (&rest _args) "non-nil"))) (with-temp-buffer (make-comint-in-buffer "test-comint-password" (current-buffer) cat) (let ((proc (get-buffer-process (current-buffer)))) - (comint-send-string proc "Password: ") - (accept-process-output proc 0 1 t) - (comint-send-eof) - (accept-process-output proc 0 1 t) - (should (string-equal (buffer-substring-no-properties (point-min) (point-max)) - "Password: PaSsWoRd123\n")) - (when (process-live-p proc) - (kill-process proc)) - (accept-process-output proc 0 1 t))))))) + (set-process-query-on-exit-flag proc nil) + (comint-send-invisible "Password: ") + (accept-process-output proc 0.1) + (should (string-equal + (buffer-substring-no-properties (point-min) (point-max)) + (concat (or (and password-function + (funcall password-function)) + "non-nil") "\n"))))))))) + +(ert-deftest comint-test-no-password-function () + "Test that `comint-password-function' not being set does not +alter normal password flow." + (comint-tests/test-password-function nil)) (ert-deftest comint-test-password-function-with-value () "Test that `comint-password-function' alters normal password flow. Hook function returns alternative password." - (cl-letf - (((symbol-function 'read-passwd) - (lambda (_prompt &optional _confirm _default) - "PaSsWoRd123"))) - (let ((cat (executable-find "cat")) - (comint-password-function (lambda (_prompt) "MaGiC-PaSsWoRd789"))) - (when cat - (with-temp-buffer - (make-comint-in-buffer "test-comint-password" (current-buffer) cat) - (let ((proc (get-buffer-process (current-buffer)))) - (comint-send-string proc "Password: ") - (accept-process-output proc 0 1 t) - (comint-send-eof) - (accept-process-output proc 0 1 t) - (should (string-equal (buffer-substring-no-properties (point-min) (point-max)) - "Password: MaGiC-PaSsWoRd789\n")) - (when (process-live-p proc) - (kill-process proc)) - (accept-process-output proc 0 1 t))))))) + (comint-tests/test-password-function (lambda (&rest _args) "MaGiC-PaSsWoRd789"))) (ert-deftest comint-test-password-function-with-nil () "Test that `comint-password-function' does not alter the normal password flow if it returns a nil value." - (cl-letf - (((symbol-function 'read-passwd) - (lambda (_prompt &optional _confirm _default) - "PaSsWoRd456"))) - (let ((cat (executable-find "cat")) - (comint-password-function (lambda (_prompt) nil))) - (when cat - (with-temp-buffer - (make-comint-in-buffer "test-comint-password" (current-buffer) cat) - (let ((proc (get-buffer-process (current-buffer)))) - (comint-send-string proc "Password: ") - (accept-process-output proc 0 1 t) - (comint-send-eof) - (accept-process-output proc 0 1 t) - (should (string-equal (buffer-substring-no-properties (point-min) (point-max)) - "Password: PaSsWoRd456\n")) - (when (process-live-p proc) - (kill-process proc)) - (accept-process-output proc 0 1 t))))))) + (comint-tests/test-password-function #'ignore)) ;; Local Variables: ;; no-byte-compile: t -- 2.23.0