* eat-tests.el (eat-test-set-cwd): Update test

This commit is contained in:
Akib Azmain Turja 2022-12-07 00:12:22 +06:00
parent 62a09caef1
commit 8188f71562
No known key found for this signature in database
GPG key ID: 5535FCF54D88616B

View file

@ -5752,25 +5752,32 @@ Write plain text and newline to move cursor."
(ert-deftest eat-test-set-cwd () (ert-deftest eat-test-set-cwd ()
"Test setting current working directory." "Test setting current working directory."
(eat--tests-with-term '() (eat--tests-with-term '()
(let ((cwd default-directory)) (let ((cwd default-directory)
(should (string= (eat-term-cwd (terminal)) default-directory)) (host (system-name)))
(should (string= (car (eat-term-cwd (terminal))) host))
(should (string= (cdr (eat-term-cwd (terminal))) cwd))
(setf (eat-term-set-cwd-function (terminal)) (setf (eat-term-set-cwd-function (terminal))
(lambda (term dir) (lambda (term hostname dir)
(should (eq term (terminal))) (should (eq term (terminal)))
(setq cwd dir))) (setq cwd dir)
(setq host hostname)))
;; file://HOST/PATH/. ;; file://HOST/PATH/.
(output (format "\e]7;file://%s/foo/bar/\e\\" (system-name))) (output (format "\e]51;e;A;%s;%s\e\\"
(base64-encode-string "frob")
(base64-encode-string "/foo/bar/")))
(should (string= host "frob"))
(should (string= (car (eat-term-cwd (terminal))) "frob"))
(should (string= cwd "/foo/bar/")) (should (string= cwd "/foo/bar/"))
(should (string= (eat-term-cwd (terminal)) "/foo/bar/")) (should (string= (cdr (eat-term-cwd (terminal))) "/foo/bar/"))
(should-term :cursor '(1 . 1))
;; file://HOST/PATH (note the missing trailing slash). ;; file://HOST/PATH (note the missing trailing slash).
(output (format "\e]7;file://%s/bar/baz\a" (system-name))) (output (format "\e]51;e;A;%s;%s\e\\"
(base64-encode-string "foo")
(base64-encode-string "/bar/baz")))
(should (string= host "foo"))
(should (string= (car (eat-term-cwd (terminal))) "foo"))
(should (string= cwd "/bar/baz/")) (should (string= cwd "/bar/baz/"))
(should (string= (eat-term-cwd (terminal)) "/bar/baz/")) (should (string= (cdr (eat-term-cwd (terminal))) "/bar/baz/"))
;; file://SOME-OTHER-HOST/PATH/
(output (format "\e]7;file://%s/baz/foo/\e\\"
(if (string= (system-name) "foo") "bar" "foo")))
(should (string= cwd "/bar/baz/"))
(should (string= (eat-term-cwd (terminal)) "/bar/baz/"))
(should-term :cursor '(1 . 1))))) (should-term :cursor '(1 . 1)))))