comparison .elisp/nose.el @ 85:4b9b90486260

Fix an error in nose.el
author Augie Fackler <durin42@gmail.com>
date Tue, 14 Apr 2009 22:46:45 -0500
parents f013f40e7b63
children 79eec81404c3
comparison
equal deleted inserted replaced
84:f013f40e7b63 85:4b9b90486260
46 "run nosetests" 46 "run nosetests"
47 (let* ((nose (nose-find-test-runner)) 47 (let* ((nose (nose-find-test-runner))
48 (where (nose-find-project-root)) 48 (where (nose-find-project-root))
49 (args (if debug "--pdb" "")) 49 (args (if debug "--pdb" ""))
50 (tnames (if tests tests ""))) 50 (tnames (if tests tests "")))
51 (funcall (if debug 51 (funcall (if debug
52 'pdb 52 'pdb
53 '(lambda (command) 53 '(lambda (command)
54 (compilation-start command 54 (compilation-start command
55 nil 55 nil
56 (lambda (mode) (concat "*nosetests*"))))) 56 (lambda (mode) (concat "*nosetests*")))))
57 (format "%s -v %s -w %s -c %ssetup.cfg %s" 57 (format "%s -v %s -w %s -c %ssetup.cfg %s"
86 (interactive) 86 (interactive)
87 (nosetests-one t)) 87 (nosetests-one t))
88 88
89 (defun nose-find-test-runner () 89 (defun nose-find-test-runner ()
90 (message 90 (message
91 (let ((result 91 (let ((result
92 (reduce '(lambda (x y) (or x y)) 92 (reduce '(lambda (x y) (or x y))
93 (mapcar 'nose-find-test-runner-names nose-project-names)))) 93 (mapcar 'nose-find-test-runner-names nose-project-names))))
94 (if result 94 (if result
95 result 95 result
96 nose-global-name)))) 96 nose-global-name))))
97 97
98 (defun nose-find-test-runner-names (runner) 98 (defun nose-find-test-runner-names (runner)
99 "find eggs/bin/test in a parent dir of current buffer's file" 99 "find eggs/bin/test in a parent dir of current buffer's file"
100 (nose-find-test-runner-in-dir-named 100 (nose-find-test-runner-in-dir-named
101 (file-name-directory buffer-file-name) runner)) 101 (file-name-directory buffer-file-name) runner))
102 102
103 (defun nose-find-test-runner-in-dir-named (dn runner) 103 (defun nose-find-test-runner-in-dir-named (dn runner)
104 (let ((fn (expand-file-name runner dn))) 104 (let ((fn (expand-file-name runner dn)))
105 (cond ((file-regular-p fn) fn) 105 (cond ((file-regular-p fn) fn)
115 (outer-def (car outer)) 115 (outer-def (car outer))
116 (outer-obj (cdr outer))) 116 (outer-obj (cdr outer)))
117 (cond ((equal outer-def "def") outer-obj) 117 (cond ((equal outer-def "def") outer-obj)
118 ((equal inner-obj outer-obj) outer-obj) 118 ((equal inner-obj outer-obj) outer-obj)
119 (t (format "%s.%s" outer-obj inner-obj))))) 119 (t (format "%s.%s" outer-obj inner-obj)))))
120 120
121 (defun inner-testable () 121 (defun inner-testable ()
122 (save-excursion 122 (save-excursion
123 (re-search-backward 123 (re-search-backward
124 "^ \\{0,4\\}\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t) 124 "^ \\{0,4\\}\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t)
125 (buffer-substring-no-properties (match-beginning 2) (match-end 2)))) 125 (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
126 126
127 (defun outer-testable () 127 (defun outer-testable ()
128 (save-excursion 128 (save-excursion
129 (re-search-backward 129 (re-search-backward
130 "^\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t) 130 "^\\(class\\|def\\)[ \t]+\\([a-zA-Z0-9_]+\\)" nil t)
131 (let ((result 131 (let ((result
132 (buffer-substring-no-properties (match-beginning 2) (match-end 2)))) 132 (buffer-substring-no-properties (match-beginning 2) (match-end 2))))
133 133
134 (cons 134 (cons
135 (buffer-substring-no-properties (match-beginning 1) (match-end 1)) 135 (buffer-substring-no-properties (match-beginning 1) (match-end 1))
136 result)))) 136 result))))
137 137
138 (defun nose-find-project-root (&optional dirname) 138 (defun nose-find-project-root (&optional dirname)
139 (interactive) 139 (interactive)
140 (let ((dn 140 (let ((dn
141 (if dirname 141 (if dirname
142 dirname 142 dirname
143 (file-name-directory buffer-file-name)))) 143 (file-name-directory buffer-file-name))))
144 (cond ((nose-project-root dn) (expand-file-name dn)) 144 (cond ((nose-project-root dn) (expand-file-name dn))
145 ((equal (expand-file-name dn) "/") nil) 145 ((equal (expand-file-name dn) "/") nil)
146 (t1 (nose-find-project-root 146 (t (nose-find-project-root
147 (file-name-directory (directory-file-name dn))))))) 147 (file-name-directory (directory-file-name dn)))))))
148 148
149 (defun nose-project-root (dirname) 149 (defun nose-project-root (dirname)
150 (reduce '(lambda (x y) (or x y)) 150 (reduce '(lambda (x y) (or x y))
151 (mapcar (lambda (d) (member d (directory-files dirname))) 151 (mapcar (lambda (d) (member d (directory-files dirname)))
152 nose-project-root-files))) 152 nose-project-root-files)))
153 153
154 (provide 'nose) 154 (provide 'nose)