summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOlivier Certner <olce.emacs@certner.fr>2023-04-06 10:16:33 +0200
committerDmitry Gutov <dmitry@gutov.dev>2023-04-19 03:47:20 +0300
commit7a921b6b284a8b5755c61045f4db03f09ff0a386 (patch)
treeb5e82544c7d3723f381a9fa2cc57f7f4ccf541a7 /test
parent9093834d0b590bc15ed994bd62f18f7b47a48f55 (diff)
downloademacs-7a921b6b284a8b5755c61045f4db03f09ff0a386.tar.gz
VC: CVS: Fix "Root" file parsing
The new "Root" file parsing has been based on CVS' documentation, which gives the following format for *remote* repositories: [:method:][[user][:password]@]hostname[:[port]]/pathname/to/repository and for local ones: :local:/pathname/to/repository or :local:c:/pathname/to/repository or alternatively ':local:' replaced by ':fork:', or ':local:' omitted when the path starts with a slash. [The actual parsing code in CVS is actually a bit more restrictive. See 'root.c'.] Most notably, the previous version could not parse an absolute pathname without an explicit :local: method or :pserver: lines with passwords. * lisp/vc/vc-cvs.el (vc-cvs-parse-root): Rewrite. (vc-cvs-repository-hostname): Cope with `vc-cvs-parse-root' returning an empty hostname (can only happen if the "Root" file is invalid), returning nil in this case. (vc-cvs-parse-uhp): Remove this standalone function formerly used only by `vc-cvs-parse-root' and which doesn't allow correct parsing anyway. * test/lisp/vc/vc-cvs-tests.el: New file, with tests for common "Root" file content.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/vc/vc-cvs-tests.el107
1 files changed, 107 insertions, 0 deletions
diff --git a/test/lisp/vc/vc-cvs-tests.el b/test/lisp/vc/vc-cvs-tests.el
new file mode 100644
index 00000000000..99ac9c8eb96
--- /dev/null
+++ b/test/lisp/vc/vc-cvs-tests.el
@@ -0,0 +1,107 @@
+;;; vc-cvs-tests.el --- tests for vc/vc-cvs.el -*- lexical-binding:t -*-
+
+;; Copyright (C) 2023 Free Software Foundation, Inc.
+
+;; Author: Olivier Certner <olce.emacs@certner.fr>
+;; Maintainer: emacs-devel@gnu.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'vc-cvs)
+
+(ert-deftest vc-cvs-test-parse-root--local-no-method ()
+ (vc-cvs-test--check-parse-root
+ "/home/joe/repo"
+ '("local" nil nil "/home/joe/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--local-windows-drive-letter ()
+ (vc-cvs-test--check-parse-root
+ ":local:c:/users/joe/repo"
+ '("local" nil nil "c:/users/joe/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--ext-no-method-host-no-port-colon ()
+ (vc-cvs-test--check-parse-root
+ "host/home/serv/repo"
+ '("ext" nil "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--pserver-host-no-port-colon ()
+ (vc-cvs-test--check-parse-root
+ ":pserver:host/home/serv/repo"
+ '("pserver" nil "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--pserver-host-port-colon ()
+ (vc-cvs-test--check-parse-root
+ ":pserver:host:/home/serv/repo"
+ '("pserver" nil "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--ext-no-method-user-host-no-port-colon ()
+ (vc-cvs-test--check-parse-root
+ "usr@host/home/serv/repo"
+ '("ext" "usr" "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--ext-no-method-user-host-port-colon ()
+ (vc-cvs-test--check-parse-root
+ "usr@host:/home/serv/repo"
+ '("ext" "usr" "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--pserver-user-password-host-no-port-colon ()
+ (vc-cvs-test--check-parse-root
+ ":pserver:usr:passwd@host/home/serv/repo"
+ '("pserver" "usr" "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--pserver-user-password-host-port-colon ()
+ (vc-cvs-test--check-parse-root
+ ":pserver:usr:passwd@host:/home/serv/repo"
+ '("pserver" "usr" "host" "/home/serv/repo")))
+
+(ert-deftest vc-cvs-test-parse-root--pserver-user-password-host-port ()
+ (vc-cvs-test--check-parse-root
+ ":pserver:usr:passwd@host:28/home/serv/repo"
+ '("pserver" "usr" "host" "/home/serv/repo")))
+
+;; Next 3 tests are just to err on the side of caution. It doesn't
+;; seem that CVS 1.12 can ever produce such lines.
+
+(ert-deftest
+ vc-cvs-test-parse-root--ext-no-method-user-password-host-no-port-colon
+ ()
+ (vc-cvs-test--check-parse-root
+ "usr:passwd@host/home/serv/repo"
+ '("ext" "usr" "host" "/home/serv/repo")))
+
+(ert-deftest
+ vc-cvs-test-parse-root--ext-no-method-user-password-host-port-colon
+ ()
+ (vc-cvs-test--check-parse-root
+ "usr:passwd@host:/home/serv/repo"
+ '("ext" "usr" "host" "/home/serv/repo")))
+
+(ert-deftest
+ vc-cvs-test-parse-root--ext-no-method-user-password-host-port
+ ()
+ (vc-cvs-test--check-parse-root
+ "usr:passwd@host:28/home/serv/repo"
+ '("ext" "usr" "host" "/home/serv/repo")))
+
+
+(defun vc-cvs-test--check-parse-root (input expected-output)
+ (should (equal (vc-cvs-parse-root input) expected-output)))
+
+;;; vc-cvs-tests.el ends here