Jason Pellerin avatar Jason Pellerin committed 4873393

First semi-functional proj root test

Comments (0)

Files changed (1)

 ;;             (local-set-key "\C-cp." 'nosetests-pdb-one)))
 
 (defvar nose-project-names '("eco/bin/test"))
+(defvar nose-project-root-files '("setup.py" ".hg" ".git"))
+(defvar nose-project-root-test 'nose-project-root)
 (defvar nose-global-name "nosetests")
 
 (defun run-nose (&optional tests debug)
   "run nosetests"
   (let* ((nose (nose-find-test-runner))
-         (where (expand-file-name "../.." (file-name-directory nose)))
+         (where (nose-find-project-root))
          (args (if debug "--pdb" ""))
          (tnames (if tests tests "")))
     (funcall (if debug 'pdb '(lambda (command)
                                (compilation-start command
                                                   nil
                                                   (lambda (mode) (concat "*nosetests*")))))
-             (format "%s -v %s -w %s -c %s/setup.cfg %s"
+             (format "%s -v %s -w %s -c %ssetup.cfg %s"
                      (nose-find-test-runner) args where where tnames)))
   )
 
       (goto-char remember-point)
       result)))
 
+(defun nose-find-project-root (&optional dirname)  
+  (interactive)
+  (when (null dirname) (setq dirname (file-name-directory buffer-file-name)))
+  (cond ((nose-project-root dirname) (expand-file-name dirname))
+        ((string= (expand-file-name dirname) "/") nil)
+        (t (nose-find-project-root
+            (file-name-directory (directory-file-name dirname))))))
+
+(defun nose-project-root (dirname)
+  (reduce '(lambda (x y) (or x y))
+          (mapcar (lambda (d) (member d (directory-files dirname)))
+                  nose-project-root-files)))
+       
 (provide 'nose)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.