test-org-lint.el 20 KB

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