Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra functionality: run tests in runtests.jl #142

Open
CasBex opened this issue Aug 2, 2023 · 0 comments
Open

Extra functionality: run tests in runtests.jl #142

CasBex opened this issue Aug 2, 2023 · 0 comments

Comments

@CasBex
Copy link

CasBex commented Aug 2, 2023

In my development workflow I like to write lots of tests and comment in/out in runtests.jl when necessary. To aid with this I have written two functions to automatically run tests either using Pkg.test() or using include("project/test/runtests.jl") to avoid recompiling every time. I was wondering whether you would be interested in adding these to the repo?

To not keep you in suspense the definitions are below

  (defun julia-repl-run-tests (arg)
    (interactive "P")
    (julia-repl-activate-parent arg)
    (julia-repl--send-string "Pkg.test()"))
  (defun julia-repl-include-tests (arg)
    (interactive "P")
    (if arg
	(progn
	  (message "activating home project")
	  (julia-repl--send-string "import Pkg; Pkg.activate()"))
      (cl-flet ((find-projectfile (filename)
				  (locate-dominating-file (buffer-file-name) filename)))
	(if-let ((projectfile (or (find-projectfile "Project.toml")
				  (find-projectfile "JuliaProject.toml"))))
	    (progn
	      (message "activating %s" projectfile)
	      (julia-repl--send-string
	       (concat "import Pkg; Pkg.activate(\""
		       (expand-file-name (file-name-directory projectfile))
		       "\"); include(\""
		       (expand-file-name
			(concat (file-name-directory projectfile)
				(file-name-as-directory "test")
				"runtests.jl"))
		       "\")")))
	  (message "could not find project file")))))

You will notice that the last one is mainly a copy of julia-repl-activate-parent. It may thus be interesting to create an auxiliary function julia-repl-find-project-directory to avoid code duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant