summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--snakemake-test.el20
-rw-r--r--snakemake.el5
2 files changed, 19 insertions, 6 deletions
diff --git a/snakemake-test.el b/snakemake-test.el
index eeb2e5f..274ce56 100644
--- a/snakemake-test.el
+++ b/snakemake-test.el
@@ -80,6 +80,11 @@ rule cc_wildcards:
rule dd_subdir:
input: \"aa.out\"
output: \"subdir/dd.out\"
+ shell: \"cat {input} > {output}\"
+
+rule:
+ input: \"anon.in\"
+ output: \"anon.out\"
shell: \"cat {input} > {output}\""))
,@body)
(delete-directory snakemake-test-dir t)))))
@@ -710,13 +715,13 @@ rule abc:
(ert-deftest snakemake-test-rule-targets ()
(should
- (equal '("aa" "bb" "dd_subdir")
+ (equal '("aa" "bb" "dd_subdir" "5")
(snakemake-with-temp-dir
(snakemake-rule-targets)))))
(ert-deftest snakemake-test-all-rules ()
(should
- (equal '("aa" "bb" "cc_wildcards" "dd_subdir")
+ (equal '("aa" "bb" "cc_wildcards" "dd_subdir" "5")
(snakemake-with-temp-dir
(snakemake-all-rules)))))
@@ -724,7 +729,7 @@ rule abc:
(should
(equal
(and snakemake-file-target-program
- '("aa.out" "bb.out" "subdir/dd.out"))
+ '("aa.out" "bb.out" "subdir/dd.out" "anon.out"))
(snakemake-with-temp-dir
(snakemake-file-targets)))))
@@ -809,7 +814,14 @@ rule abc:
(snakemake-mode)
(insert-file-contents "Snakefile")
(re-search-forward "rule cc_wildcards:")
- (snakemake-rule-at-point 'target)))))
+ (snakemake-rule-at-point 'target))))
+ (should-not
+ (snakemake-with-temp-dir
+ (with-temp-buffer
+ (snakemake-mode)
+ (insert-file-contents "Snakefile")
+ (re-search-forward "rule:")
+ (snakemake-rule-at-point)))))
(provide 'snakemake-test)
;;; snakemake-test.el ends here
diff --git a/snakemake.el b/snakemake.el
index f2ca732..cc6bc3f 100644
--- a/snakemake.el
+++ b/snakemake.el
@@ -328,8 +328,9 @@ currently limited to a single-item list."
(re-search-backward snakemake-rule-or-subworkflow-re)
(let ((rule (and (string= (match-string-no-properties 1) "rule")
(match-string-no-properties 2))))
- (and (or (not targets-only) (snakemake-check-target rule))
- (list rule))))))
+ (when rule
+ (and (or (not targets-only) (snakemake-check-target rule))
+ (list rule)))))))
(defun snakemake--prompt (prompt default)
(concat prompt