Skip to content

Instantly share code, notes, and snippets.

@psanford
Last active July 23, 2021 17:48
Show Gist options
  • Save psanford/d175c10ca28b1566de358fe336a9fb2f to your computer and use it in GitHub Desktop.
Save psanford/d175c10ca28b1566de358fe336a9fb2f to your computer and use it in GitHub Desktop.
(defun pms-go-run-test (&optional more-test-args)
"Runs tests for current package"
(interactive)
(when (buffer-file-name)
(save-buffer))
(compile (concat "go test -v -count=1 -mod=mod" more-test-args) 'go-compilation)
(ring-insert pms-previous-test-ring
(cons
`(lambda () (pms-go-run-test ,more-test-args))
(current-buffer))))
(defun pms-go-single-test-function (&optional more-test-args)
"Runs the current test function only"
(interactive)
(save-excursion
(let ((func-name (go--function-name)))
(when (not (string-prefix-p "Test" func-name))
(error "Not in a test function: %s" func-name))
(compile (concat "go test -v -count=1 -mod=mod -run ^" func-name "$" more-test-args) 'go-compilation)
(ring-insert pms-previous-test-ring
(cons
`(lambda () (pms-go-run-test ,more-test-args))
(current-buffer))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment