test-org-lint.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. ;;; test-org-lint.el --- Tests for Org Lint -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2016, 2019 Nicolas Goaziou
  3. ;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ;;; Code:
  15. (ert-deftest test-org-lint/add-checker ()
  16. "Test `org-lint-add-checker'."
  17. ;; Name should be a non-nil symbol.
  18. (should-error (org-lint-add-checker nil "Nil check" #'ignore))
  19. (should-error (org-lint-add-checker 2 "Odd check" #'ignore))
  20. ;; Check function should be valid.
  21. (should-error (org-lint-add-checker 'check "check" (gensym)))
  22. ;; Checkers must be named uniquely.
  23. (should
  24. (= 1
  25. (let ((org-lint--checkers nil))
  26. (org-lint-add-checker 'check "check" #'ignore)
  27. (length org-lint--checkers))))
  28. (should-not
  29. (= 2
  30. (let ((org-lint--checkers nil))
  31. (org-lint-add-checker 'check "check" #'ignore)
  32. (org-lint-add-checker 'check "other check" #'ignore)
  33. (length org-lint--checkers)))))
  34. (ert-deftest test-org-lint/duplicate-custom-id ()
  35. "Test `org-lint-duplicate-custom-id' checker."
  36. (should
  37. (org-test-with-temp-text "
  38. * H1
  39. :PROPERTIES:
  40. :CUSTOM_ID: foo
  41. :END:
  42. * H2
  43. :PROPERTIES:
  44. :CUSTOM_ID: foo
  45. :END:"
  46. (org-lint '(duplicate-custom-id))))
  47. (should-not
  48. (org-test-with-temp-text "
  49. * H1
  50. :PROPERTIES:
  51. :CUSTOM_ID: foo
  52. :END:
  53. * H2
  54. :PROPERTIES:
  55. :CUSTOM_ID: bar
  56. :END:"
  57. (org-lint '(duplicate-custom-id)))))
  58. (ert-deftest test-org-lint/duplicate-name ()
  59. "Test `org-lint-duplicate-name' checker."
  60. (should
  61. (org-test-with-temp-text "
  62. #+name: foo
  63. Paragraph1
  64. #+name: foo
  65. Paragraph 2"
  66. (org-lint '(duplicate-name))))
  67. (should-not
  68. (org-test-with-temp-text "
  69. #+name: foo
  70. Paragraph1
  71. #+name: bar
  72. Paragraph 2"
  73. (org-lint '(duplicate-name)))))
  74. (ert-deftest test-org-lint/duplicate-target ()
  75. "Test `org-lint-duplicate-target' checker."
  76. (should
  77. (org-test-with-temp-text "<<foo>> <<foo>>"
  78. (org-lint '(duplicate-target))))
  79. (should-not
  80. (org-test-with-temp-text "<<foo>> <<bar>>"
  81. (org-lint '(duplicate-target)))))
  82. (ert-deftest test-org-lint/duplicate-footnote-definition ()
  83. "Test `org-lint-duplicate-footnote-definition' checker."
  84. (should
  85. (org-test-with-temp-text "
  86. \[fn:1] Definition 1
  87. \[fn:1] Definition 2"
  88. (org-lint '(duplicate-footnote-definition))))
  89. (should-not
  90. (org-test-with-temp-text "
  91. \[fn:1] Definition 1
  92. \[fn:2] Definition 2"
  93. (org-lint '(duplicate-footnote-definition)))))
  94. (ert-deftest test-org-lint/orphaned-affiliated-keywords ()
  95. "Test `org-lint-orphaned-affiliated-keywords' checker."
  96. (should
  97. (org-test-with-temp-text "#+name: foo"
  98. (org-lint '(orphaned-affiliated-keywords)))))
  99. (ert-deftest test-org-lint/deprecated-export-blocks ()
  100. "Test `org-lint-deprecated-export-blocks' checker."
  101. (should
  102. (org-test-with-temp-text "
  103. #+begin_latex
  104. ...
  105. #+end_latex"
  106. (org-lint '(deprecated-export-blocks)))))
  107. (ert-deftest test-org-lint/deprecated-header-syntax ()
  108. "Test `org-lint-deprecated-header-syntax' checker."
  109. (should
  110. (org-test-with-temp-text "#+property: cache yes"
  111. (org-lint '(deprecated-header-syntax))))
  112. (should
  113. (org-test-with-temp-text "
  114. * H
  115. :PROPERTIES:
  116. :cache: yes
  117. :END:"
  118. (org-lint '(deprecated-header-syntax)))))
  119. (ert-deftest test-org-lint/missing-language-in-src-block ()
  120. "Test `org-lint-missing-language-in-src-block' checker."
  121. (should
  122. (org-test-with-temp-text "
  123. #+begin_src
  124. ...
  125. #+end_src"
  126. (org-lint '(missing-language-in-src-block)))))
  127. (ert-deftest test-org-lint/missing-backend-in-export-block ()
  128. "Test `org-lint-missing-backend-in-export-block' checker."
  129. (should
  130. (org-test-with-temp-text "
  131. #+begin_export
  132. ...
  133. #+end_export"
  134. (org-lint '(missing-backend-in-export-block)))))
  135. (ert-deftest test-org-lint/invalid-babel-call-block ()
  136. "Test `org-lint-invalid-babel-call-block' checker."
  137. (should
  138. (org-test-with-temp-text "#+call:"
  139. (org-lint '(invalid-babel-call-block))))
  140. (should
  141. (org-test-with-temp-text "#+call: foo() [:exports code]"
  142. (org-lint '(invalid-babel-call-block)))))
  143. (ert-deftest test-org-lint/deprecated-category-setup ()
  144. "Test `org-lint-deprecated-category-setup' checker."
  145. (should
  146. (org-test-with-temp-text "#+category: foo\n#+category: bar"
  147. (org-lint '(deprecated-category-setup)))))
  148. (ert-deftest test-org-lint/invalid-coderef-link ()
  149. "Test `org-lint-invalid-coderef-link' checker."
  150. (should
  151. (org-test-with-temp-text "[[(unknown)]]"
  152. (org-lint '(invalid-coderef-link))))
  153. (should-not
  154. (org-test-with-temp-text "[[(foo)]]
  155. #+begin_src emacs-lisp -l \"; ref:%s\"
  156. (+ 1 1) ; ref:foo
  157. #+end_src"
  158. (org-lint '(invalid-coderef-link)))))
  159. (ert-deftest test-org-lint/invalid-custom-id-link ()
  160. "Test `org-lint-invalid-custom-id-link' checker."
  161. (should
  162. (org-test-with-temp-text "[[#unknown]]"
  163. (org-lint '(invalid-custom-id-link))))
  164. (should-not
  165. (org-test-with-temp-text "[[#foo]]
  166. * H
  167. :PROPERTIES:
  168. :CUSTOM_ID: foo
  169. :END:"
  170. (org-lint '(invalid-custom-id-link)))))
  171. (ert-deftest test-org-lint/invalid-fuzzy-link ()
  172. "Test `org-lint-invalid-fuzzy-link' checker."
  173. (should
  174. (org-test-with-temp-text "[[*unknown]]"
  175. (org-lint '(invalid-fuzzy-link))))
  176. (should-not
  177. (org-test-with-temp-text "[[*foo]]\n* foo"
  178. (org-lint '(invalid-fuzzy-link))))
  179. (should
  180. (org-test-with-temp-text "[[unknown]]"
  181. (org-lint '(invalid-fuzzy-link))))
  182. (should-not
  183. (org-test-with-temp-text "[[foo]]\n#+name: foo\nParagraph"
  184. (org-lint '(invalid-fuzzy-link))))
  185. (should-not
  186. (org-test-with-temp-text "[[foo]]\n<<foo>>"
  187. (org-lint '(invalid-fuzzy-link)))))
  188. (ert-deftest test-org-lint/special-property-in-properties-drawer ()
  189. "Test `org-lint-special-property-in-properties-drawer' checker."
  190. (should
  191. (org-test-with-temp-text "
  192. * H
  193. :PROPERTIES:
  194. :TODO: foo
  195. :END:"
  196. (org-lint '(special-property-in-properties-drawer)))))
  197. (ert-deftest test-org-lint/obsolete-properties-drawer ()
  198. "Test `org-lint-obsolete-properties-drawer' checker."
  199. (should-not
  200. (org-test-with-temp-text "
  201. * H
  202. :PROPERTIES:
  203. :SOMETHING: foo
  204. :END:"
  205. (org-lint '(obsolete-properties-drawer))))
  206. (should-not
  207. (org-test-with-temp-text "
  208. * H
  209. SCHEDULED: <2012-03-29>
  210. :PROPERTIES:
  211. :SOMETHING: foo
  212. :END:"
  213. (org-lint '(obsolete-properties-drawer))))
  214. (should-not
  215. (org-test-with-temp-text ":PROPERTIES:
  216. :SOMETHING: foo
  217. :END:"
  218. (org-lint '(obsolete-properties-drawer))))
  219. (should-not
  220. (org-test-with-temp-text "# Comment
  221. :PROPERTIES:
  222. :SOMETHING: foo
  223. :END:"
  224. (org-lint '(obsolete-properties-drawer))))
  225. (should
  226. (org-test-with-temp-text "
  227. * H
  228. Paragraph
  229. :PROPERTIES:
  230. :SOMETHING: foo
  231. :END:"
  232. (org-lint '(obsolete-properties-drawer))))
  233. (should
  234. (org-test-with-temp-text "
  235. * H
  236. :PROPERTIES:
  237. This is not a node property
  238. :END:"
  239. (org-lint '(obsolete-properties-drawer))))
  240. (should
  241. (org-test-with-temp-text "Paragraph
  242. :PROPERTIES:
  243. :FOO: bar
  244. :END:"
  245. (org-lint '(obsolete-properties-drawer)))))
  246. (ert-deftest test-org-lint/invalid-effort-property ()
  247. "Test `org-lint-invalid-effort-property' checker."
  248. (should
  249. (org-test-with-temp-text "* H\n:PROPERTIES:\n:EFFORT: something\n:END:"
  250. (org-lint '(invalid-effort-property))))
  251. (should-not
  252. (org-test-with-temp-text "* H\n:PROPERTIES:\n:EFFORT: 1:23\n:END:"
  253. (org-lint '(invalid-effort-property)))))
  254. (ert-deftest test-org-lint/link-to-local-file ()
  255. "Test `org-lint-link-to-local-file' checker."
  256. (should
  257. (org-test-with-temp-text "[[file:/Idonotexist.org]]"
  258. (org-lint '(link-to-local-file)))))
  259. (ert-deftest test-org-lint/non-existent-setupfile-parameter ()
  260. "Test `org-lint-non-existent-setupfile-parameter' checker."
  261. (should
  262. (org-test-with-temp-text "#+setupfile: Idonotexist.org"
  263. (org-lint '(non-existent-setupfile-parameter))))
  264. (should-not
  265. (org-test-with-temp-text "#+setupfile: https://I.do/not.exist.org"
  266. (org-lint '(non-existent-setupfile-parameter)))))
  267. (ert-deftest test-org-lint/wrong-include-link-parameter ()
  268. "Test `org-lint-wrong-include-link-parameter' checker."
  269. (should
  270. (org-test-with-temp-text "#+include:"
  271. (org-lint '(wrong-include-link-parameter))))
  272. (should
  273. (org-test-with-temp-text "#+include: Idonotexist.org"
  274. (org-lint '(wrong-include-link-parameter))))
  275. (should
  276. (org-test-with-temp-text-in-file ""
  277. (let ((file (buffer-file-name)))
  278. (org-test-with-temp-text (format "#+include: \"%s::#foo\"" file)
  279. (org-lint '(wrong-include-link-parameter))))))
  280. (should-not
  281. (org-test-with-temp-text-in-file "* foo"
  282. (let ((file (buffer-file-name)))
  283. (org-test-with-temp-text (format "#+include: \"%s::*foo\"" file)
  284. (org-lint '(wrong-include-link-parameter)))))))
  285. (ert-deftest test-org-lint/obsolete-include-markup ()
  286. "Test `org-lint-obsolete-include-markup' checker."
  287. (should
  288. (org-test-with-temp-text-in-file ""
  289. (let ((file (buffer-file-name)))
  290. (org-test-with-temp-text (format "#+include: \"%s\" html" file)
  291. (org-lint '(obsolete-include-markup))))))
  292. (should-not
  293. (org-test-with-temp-text-in-file ""
  294. (let ((file (buffer-file-name)))
  295. (org-test-with-temp-text (format "#+include: \"%s\" export html" file)
  296. (org-lint '(obsolete-include-markup)))))))
  297. (ert-deftest test-org-lint/unknown-options-item ()
  298. "Test `org-lint-unknown-options-item' checker."
  299. (should
  300. (org-test-with-temp-text "#+options: foobarbaz:t"
  301. (org-lint '(unknown-options-item))))
  302. (should
  303. (org-test-with-temp-text "#+options: H:"
  304. (org-lint '(unknown-options-item)))))
  305. (ert-deftest test-org-lint/invalid-macro-argument-and-template ()
  306. "Test `org-lint-invalid-macro-argument-and-template' checker."
  307. (should
  308. (org-test-with-temp-text "{{{undefined()}}}"
  309. (org-lint '(invalid-macro-argument-and-template))))
  310. (should
  311. (org-test-with-temp-text
  312. "#+macro: wrongsignature $1 $2\n{{{wrongsignature(1, 2, 3)}}}"
  313. (org-lint '(invalid-macro-argument-and-template))))
  314. (should
  315. (org-test-with-temp-text "#+macro:"
  316. (org-lint '(invalid-macro-argument-and-template))))
  317. (should
  318. (org-test-with-temp-text "#+macro: missingtemplate"
  319. (org-lint '(invalid-macro-argument-and-template))))
  320. (should
  321. (org-test-with-temp-text "#+macro: unusedplaceholders $1 $3"
  322. (org-lint '(invalid-macro-argument-and-template))))
  323. (should-not
  324. (org-test-with-temp-text
  325. "#+macro: valid $1 $2\n{{{valid(1, 2)}}}"
  326. (org-lint '(invalid-macro-argument-and-template))))
  327. (should
  328. (org-test-with-temp-text "{{{keyword}}}"
  329. (org-lint '(invalid-macro-argument-and-template))))
  330. (should
  331. (org-test-with-temp-text "{{{keyword(one, too many)}}}"
  332. (org-lint '(invalid-macro-argument-and-template)))))
  333. (ert-deftest test-org-lint/undefined-footnote-reference ()
  334. "Test `org-lint-undefined-footnote-reference' checker."
  335. (should
  336. (org-test-with-temp-text "Text[fn:1]"
  337. (org-lint '(undefined-footnote-reference))))
  338. (should-not
  339. (org-test-with-temp-text "Text[fn:1]\n[fn:1] Definition"
  340. (org-lint '(undefined-footnote-reference))))
  341. (should-not
  342. (org-test-with-temp-text "Text[fn:1:inline reference]"
  343. (org-lint '(undefined-footnote-reference))))
  344. (should-not
  345. (org-test-with-temp-text "Text[fn::anonymous reference]"
  346. (org-lint '(undefined-footnote-reference)))))
  347. (ert-deftest test-org-lint/unreferenced-footnote-definition ()
  348. "Test `org-lint-unreferenced-footnote-definition' checker."
  349. (should
  350. (org-test-with-temp-text "[fn:1] Definition"
  351. (org-lint '(unreferenced-footnote-definition))))
  352. (should-not
  353. (org-test-with-temp-text "Text[fn:1]\n[fn:1] Definition"
  354. (org-lint '(unreferenced-footnote-definition)))))
  355. (ert-deftest test-org-lint/colon-in-name ()
  356. "Test `org-lint-colon-in-name' checker."
  357. (should
  358. (org-test-with-temp-text "#+name: tab:name\n| a |"
  359. (org-lint '(colon-in-name))))
  360. (should-not
  361. (org-test-with-temp-text "#+name: name\n| a |"
  362. (org-lint '(colon-in-name)))))
  363. (ert-deftest test-org-lint/misplaced-planning-info ()
  364. "Test `org-lint-misplaced-planning-info' checker."
  365. (should
  366. (org-test-with-temp-text "SCHEDULED: <2012-03-29 thu.>"
  367. (org-lint '(misplaced-planning-info))))
  368. (should
  369. (org-test-with-temp-text "
  370. * H
  371. Text
  372. SCHEDULED: <2012-03-29 thu.>"
  373. (org-lint '(misplaced-planning-info))))
  374. (should-not
  375. (org-test-with-temp-text "
  376. * H
  377. SCHEDULED: <2012-03-29 thu.>"
  378. (org-lint '(misplaced-planning-info)))))
  379. (ert-deftest test-org-lint/incomplete-drawer ()
  380. "Test `org-lint-incomplete-drawer' checker."
  381. (should
  382. (org-test-with-temp-text ":DRAWER:"
  383. (org-lint '(incomplete-drawer))))
  384. (should
  385. (org-test-with-temp-text ":DRAWER:\n:ODD:\n:END:"
  386. (org-lint '(incomplete-drawer))))
  387. (should-not
  388. (org-test-with-temp-text ":DRAWER:\n:END:"
  389. (org-lint '(incomplete-drawer)))))
  390. (ert-deftest test-org-lint/indented-diary-sexp ()
  391. "Test `org-lint-indented-diary-sexp' checker."
  392. (should
  393. (org-test-with-temp-text " %%(foo)"
  394. (org-lint '(indented-diary-sexp))))
  395. (should-not
  396. (org-test-with-temp-text "%%(foo)"
  397. (org-lint '(indented-diary-sexp)))))
  398. (ert-deftest test-org-lint/invalid-block ()
  399. "Test `org-lint-invalid-block' checker."
  400. (should
  401. (org-test-with-temp-text "#+begin_foo"
  402. (org-lint '(invalid-block))))
  403. (should-not
  404. (org-test-with-temp-text "#+begin_foo\n#+end_foo"
  405. (org-lint '(invalid-block)))))
  406. (ert-deftest test-org-lint/invalid-keyword-syntax ()
  407. "Test `org-lint-invalid-keyword-syntax' checker."
  408. (should
  409. (org-test-with-temp-text "#+keyword"
  410. (org-lint '(invalid-keyword-syntax))))
  411. (should-not
  412. (org-test-with-temp-text "#+keyword:"
  413. (org-lint '(invalid-keyword-syntax)))))
  414. (ert-deftest test-org-lint/extraneous-element-in-footnote-section ()
  415. "Test `org-lint-extraneous-element-in-footnote-section' checker."
  416. (should
  417. (org-test-with-temp-text "* Footnotes\nI'm not a footnote definition"
  418. (let ((org-footnote-section "Footnotes"))
  419. (org-lint '(extraneous-element-in-footnote-section)))))
  420. (should-not
  421. (org-test-with-temp-text "* Footnotes\n[fn:1] I'm a footnote definition"
  422. (let ((org-footnote-section "Footnotes"))
  423. (org-lint '(extraneous-element-in-footnote-section))))))
  424. (ert-deftest test-org-lint/quote-section ()
  425. "Test `org-lint-quote-section' checker."
  426. (should
  427. (org-test-with-temp-text "* QUOTE H"
  428. (org-lint '(quote-section))))
  429. (should
  430. (org-test-with-temp-text "* COMMENT QUOTE H"
  431. (org-lint '(quote-section)))))
  432. (ert-deftest test-org-lint/file-application ()
  433. "Test `org-lint-file-application' checker."
  434. (should
  435. (org-test-with-temp-text "[[file+emacs:foo.org]]"
  436. (org-lint '(file-application)))))
  437. (ert-deftest test-org-lint/percenc-encoding-link-escape ()
  438. "Test `org-lint-percent-encoding-link-escape' checker."
  439. (should
  440. (org-test-with-temp-text "[[A%20B]]"
  441. (org-lint '(percent-encoding-link-escape))))
  442. (should
  443. (org-test-with-temp-text "[[%5Bfoo%5D]]"
  444. (org-lint '(percent-encoding-link-escape))))
  445. (should
  446. (org-test-with-temp-text "[[A%2520B]]"
  447. (org-lint '(percent-encoding-link-escape))))
  448. (should-not
  449. (org-test-with-temp-text "[[A B]]"
  450. (org-lint '(percent-encoding-link-escape))))
  451. (should-not
  452. (org-test-with-temp-text "[[A%30B]]"
  453. (org-lint '(percent-encoding-link-escape))))
  454. (should-not
  455. (org-test-with-temp-text "[[A%20%30B]]"
  456. (org-lint '(percent-encoding-link-escape))))
  457. (should-not
  458. (org-test-with-temp-text "<file:A%20B>"
  459. (org-lint '(percent-encoding-link-escape))))
  460. (should-not
  461. (org-test-with-temp-text "[[A B%]]"
  462. (org-lint '(percent-encoding-link-escape)))))
  463. (ert-deftest test-org-lint/wrong-header-argument ()
  464. "Test `org-lint-wrong-header-argument' checker."
  465. (should
  466. (org-test-with-temp-text "#+call: foo() barbaz yes"
  467. (org-lint '(wrong-header-argument))))
  468. (should
  469. (org-test-with-temp-text "#+call: foo() :barbaz yes"
  470. (org-lint '(wrong-header-argument))))
  471. (should
  472. (org-test-with-temp-text "call_foo[barbaz yes]()"
  473. (org-lint '(wrong-header-argument))))
  474. (should
  475. (org-test-with-temp-text "call_foo[:barbaz yes]()"
  476. (org-lint '(wrong-header-argument))))
  477. (should
  478. (org-test-with-temp-text "#+property: header-args barbaz yes"
  479. (org-lint '(wrong-header-argument))))
  480. (should
  481. (org-test-with-temp-text "#+property: header-args :barbaz yes"
  482. (org-lint '(wrong-header-argument))))
  483. (should
  484. (org-test-with-temp-text "
  485. * H
  486. :PROPERTIES:
  487. :HEADER-ARGS: barbaz yes
  488. :END:"
  489. (org-lint '(wrong-header-argument))))
  490. (should
  491. (org-test-with-temp-text "
  492. * H
  493. :PROPERTIES:
  494. :HEADER-ARGS: :barbaz yes
  495. :END:"
  496. (org-lint '(wrong-header-argument))))
  497. (should
  498. (org-test-with-temp-text "
  499. #+header: :barbaz yes
  500. #+begin_src emacs-lisp
  501. \(+ 1 1)
  502. #+end_src"
  503. (org-lint '(wrong-header-argument))))
  504. (should
  505. (org-test-with-temp-text "src_emacs-lisp[barbaz yes]{}"
  506. (org-lint '(wrong-header-argument))))
  507. (should
  508. (org-test-with-temp-text "src_emacs-lisp[:barbaz yes]{}"
  509. (org-lint '(wrong-header-argument)))))
  510. (ert-deftest test-org-lint/wrong-header-value ()
  511. "Test `org-lint-wrong-header-value' checker."
  512. (should
  513. (org-test-with-temp-text "
  514. #+header: :cache maybe
  515. #+begin_src emacs-lisp
  516. \(+ 1 1)
  517. #+end_src"
  518. (org-lint '(wrong-header-value))))
  519. (should
  520. (org-test-with-temp-text "
  521. #+header: :exports both none
  522. #+begin_src emacs-lisp
  523. \(+ 1 1)
  524. #+end_src"
  525. (org-lint '(wrong-header-value))))
  526. (should-not
  527. (org-test-with-temp-text "
  528. #+header: :cache yes
  529. #+begin_src emacs-lisp
  530. \(+ 1 1)
  531. #+end_src"
  532. (org-lint '(wrong-header-value)))))
  533. (ert-deftest test-org/spurious-colons ()
  534. "Test `org-list-spurious-colons' checker."
  535. (should-not
  536. (org-test-with-temp-text "* H :tag:tag2:"
  537. (org-lint '(spurious-colons))))
  538. (should
  539. (org-test-with-temp-text "* H :tag::tag2:"
  540. (org-lint '(spurious-colons))))
  541. (should
  542. (org-test-with-temp-text "* H :tag::"
  543. (org-lint '(spurious-colons)))))
  544. (ert-deftest test-org-lint/non-existent-bibliography ()
  545. "Test `org-lint-non-existent-bibliography' checker."
  546. (should
  547. (org-test-with-temp-text "#+bibliography: Idonotexist.bib"
  548. (org-lint '(non-existent-bibliography)))))
  549. (ert-deftest test-org-lint/missing-print-bibliography ()
  550. "Test `org-lint-missing-print-bibliography' checker."
  551. (should
  552. (org-test-with-temp-text "[cite:@foo]"
  553. (org-lint '(missing-print-bibliography))))
  554. (should-not
  555. (org-test-with-temp-text "[cite:@foo]\n#+print_bibliography:"
  556. (org-lint '(missing-print-bibliography))))
  557. (should-not
  558. (org-test-with-temp-text ""
  559. (org-lint '(missing-print-bibliography)))))
  560. (ert-deftest test-org-lint/invalid-cite-export-declaration ()
  561. "Test `org-lint-invalid-cite-export-declaration' checker."
  562. (should
  563. (org-test-with-temp-text "#+cite_export: "
  564. (org-lint '(invalid-cite-export-declaration))))
  565. (should
  566. (org-test-with-temp-text "#+cite_export: 2"
  567. (org-lint '(invalid-cite-export-declaration))))
  568. (should
  569. (org-test-with-temp-text "#+cite_export: basic bar baz qux"
  570. (org-lint '(invalid-cite-export-declaration))))
  571. (should
  572. (org-test-with-temp-text "#+cite_export: basic \"bar"
  573. (org-lint '(invalid-cite-export-declaration))))
  574. (should
  575. (org-test-with-temp-text "#+cite_export: unknown"
  576. (org-lint '(invalid-cite-export-declaration))))
  577. (should-not
  578. (org-test-with-temp-text "#+cite_export: basic"
  579. (org-lint '(invalid-cite-export-declaration)))))
  580. (ert-deftest test-org-lint/incomplete-citation ()
  581. "Test `org-lint-incomplete-citation' checker."
  582. (should
  583. (org-test-with-temp-text "[cite:foo]"
  584. (org-lint '(incomplete-citation))))
  585. (should
  586. (org-test-with-temp-text "[cite:@foo"
  587. (org-lint '(incomplete-citation))))
  588. (should-not
  589. (org-test-with-temp-text "[cite:@foo]"
  590. (org-lint '(incomplete-citation)))))
  591. (provide 'test-org-lint)
  592. ;;; test-org-lint.el ends here