From 658229f1d1db9981d847849c47b081f39d40425f Mon Sep 17 00:00:00 2001 From: Marek L Date: Sun, 7 Jan 2024 18:52:33 +0000 Subject: [PATCH] Add quotes around sourcedir value in generated .ipkg file Resolves: https://github.com/idris-hackers/idris-mode/issues/622 --- idris-commands.el | 2 +- test/idris-commands-test.el | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/idris-commands.el b/idris-commands.el index 6c72fa5..95975e1 100644 --- a/idris-commands.el +++ b/idris-commands.el @@ -1275,7 +1275,7 @@ of the term to replace." (newline) (insert "opts = \"\"") (newline) - (when src-dir (insert "sourcedir = " src-dir) (newline)) + (when src-dir (insert "sourcedir = \"" src-dir "\"") (newline)) (insert "modules = ") (insert first-mod) (newline) diff --git a/test/idris-commands-test.el b/test/idris-commands-test.el index ec5b6fd..4d1f95e 100644 --- a/test/idris-commands-test.el +++ b/test/idris-commands-test.el @@ -280,6 +280,39 @@ myReverse xs = revAcc [] xs where (kill-buffer buffer) (idris-quit))))) +(ert-deftest idris-test-idris-start-project () + "Test generating valid .ipkg file." + (let ((mock-project-name "TestProject") + (mock-package-file-name "test-project.ipkg") + (mock-source-directory "src") + (mock-first-module "TestModule") + (mock-directory-name "test-start-project")) + (unwind-protect + (cl-letf (((symbol-function 'read-string) + (lambda (prompt &rest _) + (cond ((string-prefix-p "Project name:" prompt) + mock-project-name) + ((string-prefix-p "Package file name" prompt) + mock-package-file-name) + ((string-prefix-p "Source directory" prompt) + mock-source-directory) + ((string-prefix-p "First module name" prompt) + mock-first-module)))) + ((symbol-function 'read-directory-name) + (lambda (&rest _) mock-directory-name))) + (idris-start-project) + (with-current-buffer mock-package-file-name + (goto-char (point-min)) + (should (search-forward "package test-project")) + (should (search-forward "opts = \"\"")) + (should (search-forward "sourcedir = \"src\"")) + (should (search-forward "modules = TestModule")) + (kill-buffer))) + (if (get-buffer (concat mock-first-module ".idr")) + (kill-buffer (concat mock-first-module ".idr"))) + (delete-directory mock-directory-name t) + (idris-quit)))) + ;; Tests by Yasuhiko Watanabe ;; https://github.com/idris-hackers/idris-mode/pull/537/files (idris-ert-command-action "test-data/CaseSplit.idr" idris-case-split idris-test-eq-buffer)