Skip to content

Instantly share code, notes, and snippets.

@danlamanna
Created August 20, 2015 21:03
Show Gist options
  • Select an option

  • Save danlamanna/c2102c3bc14d5b6c9d66 to your computer and use it in GitHub Desktop.

Select an option

Save danlamanna/c2102c3bc14d5b6c9d66 to your computer and use it in GitHub Desktop.
(defun helm-ctest-candidates()
(let* ((ctest-output (shell-command-to-string "cd ~/projects/romanesco/build && ctest -N"))
(tests (-butlast (-drop 1 (s-split "\n" ctest-output)))))
(-map (lambda(test-line)
(s-trim
(s-chop-prefix "Test"
(s-trim test-line)))) tests)))
(defun helm-ctest-build-command(tests)
(concat "ctest -I "
(s-join "," (-map (lambda(test-num)
(format "%d,%d," test-num test-num)) tests))))
(setq some-helm-source
`((name . "Tests")
(candidates . ,(helm-ctest-candidates))
(action . (("run tests" .
(lambda(candidate)
(let ((compile-command (format "cd ~/projects/romanesco/build && %s" (helm-ctest-build-command
(-map 'string-to-number
(-map (lambda(candidate-str)
(car (cdr (s-match "#\\([[:digit:]]+\\)" candidate-str))))
(helm-marked-candidates)))))))
(compile compile-command))))))))
(helm :sources '(some-helm-source))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment