Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created February 8, 2010 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlipcon/298677 to your computer and use it in GitHub Desktop.
Save toddlipcon/298677 to your computer and use it in GitHub Desktop.
(defun switch-to-test ()
"Switch to corresponding unit test."
(interactive)
(let ((newf
(if
(string-match "/Test[^/]+\\.java$" (buffer-file-name))
(let*
((newf (replace-regexp-in-string "/Test\\([^/]+\\.java\\)$" "/\\1" (buffer-file-name)))
(newf (replace-in-string newf "hadoop-hdfs/src/test/hdfs" "hadoop-hdfs/src/java"))
(newf (replace-in-string newf "hadoop-common/src/test/core" "hadoop-common/src/java"))
(newf (replace-in-string newf "hadoop-mapreduce/src/test/mapred" "hadoop-common/src/java")))
newf)
(let*
((newf (replace-regexp-in-string "/\\([^/]+\\.java\\)$" "/Test\\1" (buffer-file-name)))
(newf (replace-in-string newf "hadoop-hdfs/src/java" "hadoop-hdfs/src/test/hdfs"))
(newf (replace-in-string newf "hadoop-common/src/java" "hadoop-common/src/test/core"))
(newf (replace-in-string newf "hadoop-mapreduce/src/java" "hadoop-common/src/test/mapred")))
newf))))
(find-file newf)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment