1 ;;; test-org-lint.el --- Tests for Org Lint -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016 Nicolas Goaziou
5 ;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 (ert-deftest test-org-lint
/duplicate-custom-id
()
23 "Test `org-lint-duplicate-custom-id' checker."
25 (org-test-with-temp-text "
35 (org-lint '(duplicate-custom-id))))
37 (org-test-with-temp-text "
47 (org-lint '(duplicate-custom-id)))))
49 (ert-deftest test-org-lint
/duplicate-name
()
50 "Test `org-lint-duplicate-name' checker."
52 (org-test-with-temp-text "
58 (org-lint '(duplicate-name))))
60 (org-test-with-temp-text "
66 (org-lint '(duplicate-name)))))
68 (ert-deftest test-org-lint
/duplicate-target
()
69 "Test `org-lint-duplicate-target' checker."
71 (org-test-with-temp-text "<<foo>> <<foo>>"
72 (org-lint '(duplicate-target))))
74 (org-test-with-temp-text "<<foo>> <<bar>>"
75 (org-lint '(duplicate-target)))))
77 (ert-deftest test-org-lint
/duplicate-footnote-definition
()
78 "Test `org-lint-duplicate-footnote-definition' checker."
80 (org-test-with-temp-text "
84 (org-lint '(duplicate-footnote-definition))))
86 (org-test-with-temp-text "
90 (org-lint '(duplicate-footnote-definition)))))
92 (ert-deftest test-org-lint
/orphaned-affiliated-keywords
()
93 "Test `org-lint-orphaned-affiliated-keywords' checker."
95 (org-test-with-temp-text "#+name: foo"
96 (org-lint '(orphaned-affiliated-keywords)))))
98 (ert-deftest test-org-lint
/deprecated-export-blocks
()
99 "Test `org-lint-deprecated-export-blocks' checker."
101 (org-test-with-temp-text "
105 (org-lint '(deprecated-export-blocks)))))
107 (ert-deftest test-org-lint
/deprecated-header-syntax
()
108 "Test `org-lint-deprecated-header-syntax' checker."
110 (org-test-with-temp-text "#+property: cache yes"
111 (org-lint '(deprecated-header-syntax))))
113 (org-test-with-temp-text "
118 (org-lint '(deprecated-header-syntax)))))
120 (ert-deftest test-org-lint
/missing-language-in-src-block
()
121 "Test `org-lint-missing-language-in-src-block' checker."
123 (org-test-with-temp-text "
127 (org-lint '(missing-language-in-src-block)))))
129 (ert-deftest test-org-lint
/missing-backend-in-export-block
()
130 "Test `org-lint-missing-backend-in-export-block' checker."
132 (org-test-with-temp-text "
136 (org-lint '(missing-backend-in-export-block)))))
138 (ert-deftest test-org-lint
/invalid-babel-call-block
()
139 "Test `org-lint-invalid-babel-call-block' checker."
141 (org-test-with-temp-text "#+call:"
142 (org-lint '(invalid-babel-call-block))))
144 (org-test-with-temp-text "#+call: foo() [:exports code]"
145 (org-lint '(invalid-babel-call-block)))))
147 (ert-deftest test-org-lint
/deprecated-category-setup
()
148 "Test `org-lint-deprecated-category-setup' checker."
150 (org-test-with-temp-text "#+category: foo\n#+category: bar"
151 (org-lint '(deprecated-category-setup)))))
153 (ert-deftest test-org-lint
/invalid-coderef-link
()
154 "Test `org-lint-invalid-coderef-link' checker."
156 (org-test-with-temp-text "[[(unknown)]]"
157 (org-lint '(invalid-coderef-link))))
159 (org-test-with-temp-text "[[(foo)]]
160 #+begin_src emacs-lisp -l \"; ref:%s\"
163 (org-lint '(invalid-coderef-link)))))
165 (ert-deftest test-org-lint
/invalid-custom-id-link
()
166 "Test `org-lint-invalid-custom-id-link' checker."
168 (org-test-with-temp-text "[[#unknown]]"
169 (org-lint '(invalid-custom-id-link))))
171 (org-test-with-temp-text "[[#foo]]
176 (org-lint '(invalid-custom-id-link)))))
178 (ert-deftest test-org-lint
/invalid-fuzzy-link
()
179 "Test `org-lint-invalid-fuzzy-link' checker."
181 (org-test-with-temp-text "[[*unknown]]"
182 (org-lint '(invalid-fuzzy-link))))
184 (org-test-with-temp-text "[[*foo]]\n* foo"
185 (org-lint '(invalid-fuzzy-link))))
187 (org-test-with-temp-text "[[unknown]]"
188 (org-lint '(invalid-fuzzy-link))))
190 (org-test-with-temp-text "[[foo]]\n#+name: foo\nParagraph"
191 (org-lint '(invalid-fuzzy-link))))
193 (org-test-with-temp-text "[[foo]]\n<<foo>>"
194 (org-lint '(invalid-fuzzy-link)))))
196 (ert-deftest test-org-lint
/special-property-in-properties-drawer
()
197 "Test `org-lint-special-property-in-properties-drawer' checker."
199 (org-test-with-temp-text "
204 (org-lint '(special-property-in-properties-drawer)))))
206 (ert-deftest test-org-lint
/obsolete-properties-drawer
()
207 "Test `org-lint-obsolete-properties-drawer' checker."
209 (org-test-with-temp-text "
215 (org-lint '(obsolete-properties-drawer))))
217 (org-test-with-temp-text "
220 This is not a node property
222 (org-lint '(obsolete-properties-drawer)))))
224 (ert-deftest test-org-lint
/invalid-effort-property
()
225 "Test `org-lint-invalid-effort-property' checker."
227 (org-test-with-temp-text "* H\n:PROPERTIES:\n:EFFORT: something\n:END:"
228 (org-lint '(invalid-effort-property))))
230 (org-test-with-temp-text "* H\n:PROPERTIES:\n:EFFORT: 1:23\n:END:"
231 (org-lint '(invalid-effort-property)))))
233 (ert-deftest test-org-lint
/link-to-local-file
()
234 "Test `org-lint-link-to-local-file' checker."
236 (org-test-with-temp-text "[[file:/Idonotexist.org]]"
237 (org-lint '(link-to-local-file)))))
239 (ert-deftest test-org-lint
/non-existent-setupfile-parameter
()
240 "Test `org-lint-non-existent-setupfile-parameter' checker."
242 (org-test-with-temp-text "#+setupfile: Idonotexist.org"
243 (org-lint '(non-existent-setupfile-parameter)))))
245 (ert-deftest test-org-lint
/wrong-include-link-parameter
()
246 "Test `org-lint-wrong-include-link-parameter' checker."
248 (org-test-with-temp-text "#+include:"
249 (org-lint '(wrong-include-link-parameter))))
251 (org-test-with-temp-text "#+include: Idonotexist.org"
252 (org-lint '(wrong-include-link-parameter))))
254 (org-test-with-temp-text-in-file ""
255 (let ((file (buffer-file-name)))
256 (org-test-with-temp-text (format "#+include: \"%s::#foo\"" file
)
257 (org-lint '(wrong-include-link-parameter))))))
259 (org-test-with-temp-text-in-file "* foo"
260 (let ((file (buffer-file-name)))
261 (org-test-with-temp-text (format "#+include: \"%s::*foo\"" file
)
262 (org-lint '(wrong-include-link-parameter)))))))
264 (ert-deftest test-org-lint
/obsolete-include-markup
()
265 "Test `org-lint-obsolete-include-markup' checker."
267 (org-test-with-temp-text-in-file ""
268 (let ((file (buffer-file-name)))
269 (org-test-with-temp-text (format "#+include: \"%s\" html" file
)
270 (org-lint '(obsolete-include-markup))))))
272 (org-test-with-temp-text-in-file ""
273 (let ((file (buffer-file-name)))
274 (org-test-with-temp-text (format "#+include: \"%s\" export html" file
)
275 (org-lint '(obsolete-include-markup)))))))
277 (ert-deftest test-org-lint
/unknown-options-item
()
278 "Test `org-lint-unknown-options-item' checker."
280 (org-test-with-temp-text "#+options: foobarbaz:t"
281 (org-lint '(unknown-options-item)))))
283 (ert-deftest test-org-lint
/invalid-macro-argument-and-template
()
284 "Test `org-lint-invalid-macro-argument-and-template' checker."
286 (org-test-with-temp-text "{{{undefined()}}}"
287 (org-lint '(invalid-macro-argument-and-template))))
289 (org-test-with-temp-text
290 "#+macro: wrongsignature $1 $2\n{{{wrongsignature(1, 2, 3)}}}"
291 (org-lint '(invalid-macro-argument-and-template))))
293 (org-test-with-temp-text "#+macro:"
294 (org-lint '(invalid-macro-argument-and-template))))
296 (org-test-with-temp-text "#+macro: missingtemplate"
297 (org-lint '(invalid-macro-argument-and-template))))
299 (org-test-with-temp-text "#+macro: unusedplaceholders $1 $3"
300 (org-lint '(invalid-macro-argument-and-template))))
302 (org-test-with-temp-text
303 "#+macro: valid $1 $2\n{{{valid(1, 2)}}}"
304 (org-lint '(invalid-macro-argument-and-template)))))
306 (ert-deftest test-org-lint
/undefined-footnote-reference
()
307 "Test `org-lint-undefined-footnote-reference' checker."
309 (org-test-with-temp-text "Text[fn:1]"
310 (org-lint '(undefined-footnote-reference))))
312 (org-test-with-temp-text "Text[fn:1]\n[fn:1] Definition"
313 (org-lint '(undefined-footnote-reference)))))
315 (ert-deftest test-org-lint
/unreferenced-footnote-definition
()
316 "Test `org-lint-unreferenced-footnote-definition' checker."
318 (org-test-with-temp-text "[fn:1] Definition"
319 (org-lint '(unreferenced-footnote-definition))))
321 (org-test-with-temp-text "Text[fn:1]\n[fn:1] Definition"
322 (org-lint '(unreferenced-footnote-definition)))))
324 (ert-deftest test-org-lint
/colon-in-name
()
325 "Test `org-lint-colon-in-name' checker."
327 (org-test-with-temp-text "#+name: tab:name\n| a |"
328 (org-lint '(colon-in-name))))
330 (org-test-with-temp-text "#+name: name\n| a |"
331 (org-lint '(colon-in-name)))))
333 (ert-deftest test-org-lint
/misplaced-planning-info
()
334 "Test `org-lint-misplaced-planning-info' checker."
336 (org-test-with-temp-text "SCHEDULED: <2012-03-29 thu.>"
337 (org-lint '(misplaced-planning-info))))
339 (org-test-with-temp-text "
342 SCHEDULED: <2012-03-29 thu.>"
343 (org-lint '(misplaced-planning-info))))
345 (org-test-with-temp-text "
347 SCHEDULED: <2012-03-29 thu.>"
348 (org-lint '(misplaced-planning-info)))))
350 (ert-deftest test-org-lint
/incomplete-drawer
()
351 "Test `org-lint-incomplete-drawer' checker."
353 (org-test-with-temp-text ":DRAWER:"
354 (org-lint '(incomplete-drawer))))
356 (org-test-with-temp-text ":DRAWER:\n:END:"
357 (org-lint '(incomplete-drawer)))))
359 (ert-deftest test-org-lint
/indented-diary-sexp
()
360 "Test `org-lint-indented-diary-sexp' checker."
362 (org-test-with-temp-text " %%(foo)"
363 (org-lint '(indented-diary-sexp))))
365 (org-test-with-temp-text "%%(foo)"
366 (org-lint '(indented-diary-sexp)))))
368 (ert-deftest test-org-lint
/invalid-block
()
369 "Test `org-lint-invalid-block' checker."
371 (org-test-with-temp-text "#+begin_foo"
372 (org-lint '(invalid-block))))
374 (org-test-with-temp-text "#+begin_foo\n#+end_foo"
375 (org-lint '(invalid-block)))))
377 (ert-deftest test-org-lint
/invalid-keyword-syntax
()
378 "Test `org-lint-invalid-keyword-syntax' checker."
380 (org-test-with-temp-text "#+keyword"
381 (org-lint '(invalid-keyword-syntax))))
383 (org-test-with-temp-text "#+keyword:"
384 (org-lint '(invalid-keyword-syntax)))))
386 (ert-deftest test-org-lint
/extraneous-element-in-footnote-section
()
387 "Test `org-lint-extraneous-element-in-footnote-section' checker."
389 (org-test-with-temp-text "* Footnotes\nI'm not a footnote definition"
390 (let ((org-footnote-section "Footnotes"))
391 (org-lint '(extraneous-element-in-footnote-section)))))
393 (org-test-with-temp-text "* Footnotes\n[fn:1] I'm a footnote definition"
394 (let ((org-footnote-section "Footnotes"))
395 (org-lint '(extraneous-element-in-footnote-section))))))
397 (ert-deftest test-org-lint
/quote-section
()
398 "Test `org-lint-quote-section' checker."
400 (org-test-with-temp-text "* QUOTE H"
401 (org-lint '(quote-section))))
403 (org-test-with-temp-text "* COMMENT QUOTE H"
404 (org-lint '(quote-section)))))
406 (ert-deftest test-org-lint
/file-application
()
407 "Test `org-lint-file-application' checker."
409 (org-test-with-temp-text "[[file+emacs:foo.org]]"
410 (org-lint '(file-application)))))
412 (ert-deftest test-org-lint
/wrong-header-argument
()
413 "Test `org-lint-wrong-header-argument' checker."
415 (org-test-with-temp-text "#+call: foo() barbaz yes"
416 (org-lint '(wrong-header-argument))))
418 (org-test-with-temp-text "#+call: foo() :barbaz yes"
419 (org-lint '(wrong-header-argument))))
421 (org-test-with-temp-text "call_foo[barbaz yes]()"
422 (org-lint '(wrong-header-argument))))
424 (org-test-with-temp-text "call_foo[:barbaz yes]()"
425 (org-lint '(wrong-header-argument))))
427 (org-test-with-temp-text "#+property: header-args barbaz yes"
428 (org-lint '(wrong-header-argument))))
430 (org-test-with-temp-text "#+property: header-args :barbaz yes"
431 (org-lint '(wrong-header-argument))))
433 (org-test-with-temp-text "
436 :HEADER-ARGS: barbaz yes
438 (org-lint '(wrong-header-argument))))
440 (org-test-with-temp-text "
443 :HEADER-ARGS: :barbaz yes
445 (org-lint '(wrong-header-argument))))
447 (org-test-with-temp-text "
448 #+header: :barbaz yes
449 #+begin_src emacs-lisp
452 (org-lint '(wrong-header-argument))))
454 (org-test-with-temp-text "src_emacs-lisp[barbaz yes]{}"
455 (org-lint '(wrong-header-argument))))
457 (org-test-with-temp-text "src_emacs-lisp[:barbaz yes]{}"
458 (org-lint '(wrong-header-argument)))))
460 (ert-deftest test-org-lint
/wrong-header-value
()
461 "Test `org-lint-wrong-header-value' checker."
463 (org-test-with-temp-text "
464 #+header: :cache maybe
465 #+begin_src emacs-lisp
468 (org-lint '(wrong-header-value))))
470 (org-test-with-temp-text "
471 #+header: :exports both none
472 #+begin_src emacs-lisp
475 (org-lint '(wrong-header-value))))
477 (org-test-with-temp-text "
479 #+begin_src emacs-lisp
482 (org-lint '(wrong-header-value)))))
484 (ert-deftest test-org-lint
/empty-headline-with-tags
()
485 "Test `org-lint-empty-headline-with-tags' checker."
487 (org-test-with-temp-text "* :tag:"
488 (org-lint '(empty-headline-with-tags))))
490 (org-test-with-temp-text "* :tag: "
491 (org-lint '(empty-headline-with-tags))))
493 (org-test-with-temp-text "* notag: "
494 (org-lint '(empty-headline-with-tags)))))
496 (provide 'test-org-lint
)
497 ;;; test-org-lint.el ends here