 (defun erlang-eunit-module-name (file-path)
   (interactive)
   (file-name-sans-extension (file-name-nondirectory file-path)))
-
-;;; Return the directory name which is common to both src and test
-;;;     /tmp/foo/src/x.erl        --> /tmp/foo
-;;;     /tmp/foo/test/x_tests.erl --> /tmp/foo
-(defun erlang-eunit-file-root-dir-name (file-path)
-  (erlang-eunit-dir-parent-dirname (file-name-directory file-path)))
-
-;;; Return the parent directory name of a directory
-;;;     /tmp/foo/ --> /tmp
-;;;     /tmp/foo  --> /tmp
-(defun erlang-eunit-dir-parent-dirname (dir-name)
-  (file-name-directory (directory-file-name dir-name)))
 
 ;;; Older emacsen don't have string-match-p.
 (defun erlang-eunit-string-match-p (regexp string &optional start)

;;; Return the name and path of the EUnit test file
;;, (input may be either the source filename itself or the EUnit test filename)
(defun erlang-eunit-test-filename (file-path)
  (erlang-eunit-rewrite-filename file-path "test" "_tests"))

;;; Return the name and path of the source file
;;, (input may be either the source filename itself or the EUnit test filename)
(defun erlang-eunit-src-filename (file-path)
  (erlang-eunit-rewrite-filename file-path "src" ""))

;;; Rewrite a filename from the src or test filename to the other
(defun erlang-eunit-rewrite-filename (orig-file-path dest-dirname dest-suffix)
  (let* ((root-dir-name    (erlang-eunit-file-root-dir-name orig-file-path))
	 (src-module-name  (erlang-eunit-source-module-name orig-file-path))
	 (dest-base-name   (concat src-module-name dest-suffix ".erl"))
	 (dest-dir-name-1  (file-name-directory orig-file-path))
	 (dest-dir-name-2  (filename-join root-dir-name dest-dirname))
	 (dest-file-name-1 (filename-join dest-dir-name-1 dest-base-name))
	 (dest-file-name-2 (filename-join dest-dir-name-2 dest-base-name)))
    ;; This function tries to be a bit intelligent: 
    ;; * if there already is a test (or source) file in the same
    ;;   directory as a source (or test) file, it'll be picked
    ;; * if there already is a test (or source) file in a separate
    ;;   test (or src) directory, it'll be picked
    ;; * otherwise it'll resort to whatever alternative (same or
    ;;   separate directories) that the user has chosen
    (cond ((file-readable-p dest-file-name-1) 
	   dest-file-name-1)
	  ((file-readable-p dest-file-name-2) 
	   dest-file-name-2)
	  (erlang-eunit-separate-src-and-test-directories
	   dest-file-name-2)
	  (t
	   dest-file-name-1))))

;;; Checks whether a file is a EUnit test file or not
(defun erlang-eunit-test-file-p (file-path)

(eval-when-compile
  (require 'cl))

(defvar erlang-eunit-src-candidate-dirs '("../src" ".")
  "*Name of directories which to search for source files matching
an EUnit test file.  The first directory in the list will be used,
if there is no match.")

(defvar erlang-eunit-test-candidate-dirs '("../test" ".")
  "*Name of directories which to search for EUnit test files matching
a source file.  The first directory in the list will be used,
if there is no match.")

;;;
;;; Switch between src/EUnit test buffers
