                 ((erlang-eunit-test-generator-p test-name)
                  (format "eunit:test({generator, %s, %s}%s)."
                          module-name test-name (erlang-eunit-opts)))
-                (t (format "%% WARNING: '%s' is not a test function" test-name)))))
+                (t
+                 (format "%% WARNING: '%s' is not a test function"
+                         test-name)))))
     (erlang-eunit-inferior-erlang-send-command command)))
 
 ;;; Run EUnit tests for the current module

      ;; test file on the other hand, is optional, since eunit tests may
      ;; be placed in the source file instead.  Any compilation error
      ;; will prevent the subsequent steps to be run (hence the `and')
      (and (erlang-eunit-compile-file src-filename)
	   (if (file-readable-p test-filename)
	       (erlang-eunit-compile-file test-filename)
	     t)
	   (funcall run-tests)))))

(defun erlang-eunit-compile-file (file-path)
  (if (file-readable-p file-path)
      (save-excursion
	(set-buffer (find-file-noselect file-path))
	(erlang-compile)
	(erlang-eunit-last-compilation-successful-p))
    (let ((msg (format "Could not read %s" file-path)))
      (erlang-eunit-inferior-erlang-send-command 
       (format "%% WARNING: %s" msg))
      (error msg))))
  
(defun erlang-eunit-last-compilation-successful-p ()
  (save-excursion
    (set-buffer inferior-erlang-buffer)

;;;     /tmp/foo/test/x_tests.erl --> x
(defun erlang-eunit-source-module-name (file-path)
  (interactive)
  (let ((module-name (erlang-eunit-module-name file-path)))
    (if (string-match "^\\(.+\\)_tests$" module-name)
        (substring module-name (match-beginning 1) (match-end 1))
      module-name)))

;;; Return the module name of the file
;;;     /tmp/foo/src/x.erl        --> x
