2013-11-05 Glenn Morris <rgm@gnu.org>
+ Make it possible to run tests with a different working directory.
+ * automated/flymake-tests.el (flymake-tests-data-directory): New.
+ (flymake-tests--current-face): Use flymake-tests-data-directory.
+ (warning-predicate-function-gcc, warning-predicate-rx-perl)
+ (warning-predicate-function-perl): Adapt for above change.
+ * automated/zlib-tests.el (zlib-tests-data-directory): New.
+ (zlib--decompress): Use zlib-tests-data-directory.
+
* automated/eieio-tests.el (eieio-test-37-persistent-classes):
Remove test that makes no sense.
(require 'ert)
(require 'flymake)
+(defvar flymake-tests-data-directory
+ (expand-file-name "flymake/warnpred" (getenv "EMACS_TEST_DIRECTORY"))
+ "Directory containing flymake test data.")
+
\f
;; Warning predicate
(defun flymake-tests--current-face (file predicate)
- (let ((buffer (find-file-noselect file)))
+ (let ((buffer (find-file-noselect
+ (expand-file-name file flymake-tests-data-directory))))
(unwind-protect
- (with-current-buffer (find-file-noselect file)
+ (with-current-buffer buffer
(setq-local flymake-warning-predicate predicate)
(goto-char (point-min))
(flymake-mode 1)
"Test GCC warning via regexp predicate."
:expected-result (if (executable-find "gcc") :passed :failed)
(should (eq 'flymake-warnline
- (flymake-tests--current-face
- "flymake/warnpred/test.c"
- "^[Ww]arning"))))
+ (flymake-tests--current-face "test.c" "^[Ww]arning"))))
(ert-deftest warning-predicate-function-gcc ()
"Test GCC warning via function predicate."
:passed
:failed)
(should (eq 'flymake-warnline
- (flymake-tests--current-face
- "flymake/warnpred/test.c"
+ (flymake-tests--current-face "test.c"
(lambda (msg) (string-match "^[Ww]arning" msg))))))
(ert-deftest warning-predicate-rx-perl ()
"Test perl warning via regular expression predicate."
:expected-result (if (executable-find "perl") :passed :failed)
(should (eq 'flymake-warnline
- (flymake-tests--current-face
- "flymake/warnpred/test.pl"
- "^Scalar value"))))
+ (flymake-tests--current-face "test.pl" "^Scalar value"))))
(ert-deftest warning-predicate-function-perl ()
"Test perl warning via function predicate."
:expected-result (if (executable-find "perl") :passed :failed)
(should (eq 'flymake-warnline
(flymake-tests--current-face
- "flymake/warnpred/test.pl"
+ "test.pl"
(lambda (msg) (string-match "^Scalar value" msg))))))
(provide 'flymake-tests)
(require 'ert)
+(defvar zlib-tests-data-directory
+ (expand-file-name "data/decompress" (getenv "EMACS_TEST_DIRECTORY"))
+ "Directory containing zlib test data.")
+
(ert-deftest zlib--decompress ()
"Test decompressing a gzipped file."
(when (and (fboundp 'zlib-available-p)
(should (string=
(with-temp-buffer
(set-buffer-multibyte nil)
- (insert-file-contents-literally "data/decompress/foo-gzipped")
+ (insert-file-contents-literally
+ (expand-file-name "foo-gzipped" zlib-tests-data-directory))
(zlib-decompress-region (point-min) (point-max))
(buffer-string))
"foo\n"))))