Skip to content

Commit aa580b6

Browse files
authored
Merge pull request #623 from keram/issue-622-idris-start-project-ipkg
Add quotes around sourcedir value in generated .ipkg file
2 parents 37c6b81 + 658229f commit aa580b6

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

idris-commands.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ of the term to replace."
12751275
(newline)
12761276
(insert "opts = \"\"")
12771277
(newline)
1278-
(when src-dir (insert "sourcedir = " src-dir) (newline))
1278+
(when src-dir (insert "sourcedir = \"" src-dir "\"") (newline))
12791279
(insert "modules = ")
12801280
(insert first-mod)
12811281
(newline)

test/idris-commands-test.el

+33
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,39 @@ myReverse xs = revAcc [] xs where
280280
(kill-buffer buffer)
281281
(idris-quit)))))
282282

283+
(ert-deftest idris-test-idris-start-project ()
284+
"Test generating valid .ipkg file."
285+
(let ((mock-project-name "TestProject")
286+
(mock-package-file-name "test-project.ipkg")
287+
(mock-source-directory "src")
288+
(mock-first-module "TestModule")
289+
(mock-directory-name "test-start-project"))
290+
(unwind-protect
291+
(cl-letf (((symbol-function 'read-string)
292+
(lambda (prompt &rest _)
293+
(cond ((string-prefix-p "Project name:" prompt)
294+
mock-project-name)
295+
((string-prefix-p "Package file name" prompt)
296+
mock-package-file-name)
297+
((string-prefix-p "Source directory" prompt)
298+
mock-source-directory)
299+
((string-prefix-p "First module name" prompt)
300+
mock-first-module))))
301+
((symbol-function 'read-directory-name)
302+
(lambda (&rest _) mock-directory-name)))
303+
(idris-start-project)
304+
(with-current-buffer mock-package-file-name
305+
(goto-char (point-min))
306+
(should (search-forward "package test-project"))
307+
(should (search-forward "opts = \"\""))
308+
(should (search-forward "sourcedir = \"src\""))
309+
(should (search-forward "modules = TestModule"))
310+
(kill-buffer)))
311+
(if (get-buffer (concat mock-first-module ".idr"))
312+
(kill-buffer (concat mock-first-module ".idr")))
313+
(delete-directory mock-directory-name t)
314+
(idris-quit))))
315+
283316
;; Tests by Yasuhiko Watanabe
284317
;; https://github.com/idris-hackers/idris-mode/pull/537/files
285318
(idris-ert-command-action "test-data/CaseSplit.idr" idris-case-split idris-test-eq-buffer)

0 commit comments

Comments
 (0)