-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function `eldev-inherit-options' aimed at assisting in defining n…
…ew commands that are in some way similar to existing ones.
- Loading branch information
Showing
7 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(require 'test/common) | ||
|
||
|
||
(ert-deftest eldev-defcommand-1 () | ||
;; `project-g/Eldev' defines a new command that is like `test', but for a specific file. | ||
(eldev--test-run "project-g" ("test-integration") | ||
(should (string-match-p "passed.+project-g-integration-1" stdout)) | ||
(should (string-match-p "Ran 1 test" stdout)) | ||
(should (= exit-code 0))) | ||
;; The new command inherits most options from standard `test'. | ||
(eldev--test-run "project-g" ("test-integration" "--stop" "-B" "--expect=1") | ||
(should (string-match-p "passed.+project-g-integration-1" stdout)) | ||
(should (string-match-p "Ran 1 test" stdout)) | ||
(should (= exit-code 0))) | ||
;; But it doesn't inherit option `--file', as it doesn't make sense for it. | ||
(eldev--test-run "project-g" ("test-integration" "--file" "*.el") | ||
(should (string-match-p "Unknown option .--file." stderr)) | ||
(should (= exit-code 1)))) | ||
|
||
|
||
(provide 'test/extending) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
;; This project deliberately uses additional loading root for its tests. | ||
(eldev-add-loading-roots 'test "test") | ||
|
||
|
||
;; Mainly for testing `eldev-parse-command-line' and `eldev-inherit-options' in a more or | ||
;; less realistic setup. Same as command `test', but run tests from a fixed file. | ||
(eldev-defcommand project-g-test-integration (&rest parameters) | ||
:command test-integration | ||
:custom-parsing t | ||
:category testing | ||
(let* ((parsed (eldev-parse-command-line parameters :command 'test-integration)) | ||
(command-line (plist-get parsed :all-options))) | ||
(when (plist-get parsed :without-options) | ||
(signal 'eldev-wrong-command-usage `(t "Too many command parameters"))) | ||
(eldev-test "test-g-integration.el"))) | ||
|
||
(eldev-inherit-options 'test-integration 'test (lambda (option handler) (not (eq handler #'eldev-test-files)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(require 'test-g-util) | ||
|
||
(ert-deftest project-g-integration-1 () | ||
;; Basically just as `project-g-1'; important is that it also passes. | ||
(should (equal (project-g-hello) (project-g-test-util-hello)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters