test-org-lint.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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:1:inline reference] [fn:1]"
  346. (org-lint '(undefined-footnote-reference))))
  347. (should-not
  348. (org-test-with-temp-text "Text[fn::anonymous reference]"
  349. (org-lint '(undefined-footnote-reference)))))
  350. (ert-deftest test-org-lint/unreferenced-footnote-definition ()
  351. "Test `org-lint-unreferenced-footnote-definition' checker."
  352. (should
  353. (org-test-with-temp-text "[fn:1] Definition"
  354. (org-lint '(unreferenced-footnote-definition))))
  355. (should-not
  356. (org-test-with-temp-text "Text[fn:1]\n[fn:1] Definition"
  357. (org-lint '(unreferenced-footnote-definition)))))
  358. (ert-deftest test-org-lint/colon-in-name ()
  359. "Test `org-lint-colon-in-name' checker."
  360. (should
  361. (org-test-with-temp-text "#+name: tab:name\n| a |"
  362. (org-lint '(colon-in-name))))
  363. (should-not
  364. (org-test-with-temp-text "#+name: name\n| a |"
  365. (org-lint '(colon-in-name)))))
  366. (ert-deftest test-org-lint/misplaced-planning-info ()
  367. "Test `org-lint-misplaced-planning-info' checker."
  368. (should
  369. (org-test-with-temp-text "SCHEDULED: <2012-03-29 thu.>"
  370. (org-lint '(misplaced-planning-info))))
  371. (should
  372. (org-test-with-temp-text "
  373. * H
  374. Text
  375. SCHEDULED: <2012-03-29 thu.>"
  376. (org-lint '(misplaced-planning-info))))
  377. (should-not
  378. (org-test-with-temp-text "
  379. * H
  380. SCHEDULED: <2012-03-29 thu.>"
  381. (org-lint '(misplaced-planning-info)))))
  382. (ert-deftest test-org-lint/incomplete-drawer ()
  383. "Test `org-lint-incomplete-drawer' checker."
  384. (should
  385. (org-test-with-temp-text ":DRAWER:"
  386. (org-lint '(incomplete-drawer))))
  387. (should
  388. (org-test-with-temp-text ":DRAWER:\n:ODD:\n:END:"
  389. (org-lint '(incomplete-drawer))))
  390. (should-not
  391. (org-test-with-temp-text ":DRAWER:\n:END:"
  392. (org-lint '(incomplete-drawer)))))
  393. (ert-deftest test-org-lint/indented-diary-sexp ()
  394. "Test `org-lint-indented-diary-sexp' checker."
  395. (should
  396. (org-test-with-temp-text " %%(foo)"
  397. (org-lint '(indented-diary-sexp))))
  398. (should-not
  399. (org-test-with-temp-text "%%(foo)"
  400. (org-lint '(indented-diary-sexp)))))
  401. (ert-deftest test-org-lint/invalid-block ()
  402. "Test `org-lint-invalid-block' checker."
  403. (should
  404. (org-test-with-temp-text "#+begin_foo"
  405. (org-lint '(invalid-block))))
  406. (should-not
  407. (org-test-with-temp-text "#+begin_foo\n#+end_foo"
  408. (org-lint '(invalid-block)))))
  409. (ert-deftest test-org-lint/invalid-keyword-syntax ()
  410. "Test `org-lint-invalid-keyword-syntax' checker."
  411. (should
  412. (org-test-with-temp-text "#+keyword"
  413. (org-lint '(invalid-keyword-syntax))))
  414. (should-not
  415. (org-test-with-temp-text "#+keyword:"
  416. (org-lint '(invalid-keyword-syntax)))))
  417. (ert-deftest test-org-lint/extraneous-element-in-footnote-section ()
  418. "Test `org-lint-extraneous-element-in-footnote-section' checker."
  419. (should
  420. (org-test-with-temp-text "* Footnotes\nI'm not a footnote definition"
  421. (let ((org-footnote-section "Footnotes"))
  422. (org-lint '(extraneous-element-in-footnote-section)))))
  423. (should-not
  424. (org-test-with-temp-text "* Footnotes\n[fn:1] I'm a footnote definition"
  425. (let ((org-footnote-section "Footnotes"))
  426. (org-lint '(extraneous-element-in-footnote-section))))))
  427. (ert-deftest test-org-lint/quote-section ()
  428. "Test `org-lint-quote-section' checker."
  429. (should
  430. (org-test-with-temp-text "* QUOTE H"
  431. (org-lint '(quote-section))))
  432. (should
  433. (org-test-with-temp-text "* COMMENT QUOTE H"
  434. (org-lint '(quote-section)))))
  435. (ert-deftest test-org-lint/file-application ()
  436. "Test `org-lint-file-application' checker."
  437. (should
  438. (org-test-with-temp-text "[[file+emacs:foo.org]]"
  439. (org-lint '(file-application)))))
  440. (ert-deftest test-org-lint/percenc-encoding-link-escape ()
  441. "Test `org-lint-percent-encoding-link-escape' checker."
  442. (should
  443. (org-test-with-temp-text "[[A%20B]]"
  444. (org-lint '(percent-encoding-link-escape))))
  445. (should
  446. (org-test-with-temp-text "[[%5Bfoo%5D]]"
  447. (org-lint '(percent-encoding-link-escape))))
  448. (should
  449. (org-test-with-temp-text "[[A%2520B]]"
  450. (org-lint '(percent-encoding-link-escape))))
  451. (should-not
  452. (org-test-with-temp-text "[[A B]]"
  453. (org-lint '(percent-encoding-link-escape))))
  454. (should-not
  455. (org-test-with-temp-text "[[A%30B]]"
  456. (org-lint '(percent-encoding-link-escape))))
  457. (should-not
  458. (org-test-with-temp-text "[[A%20%30B]]"
  459. (org-lint '(percent-encoding-link-escape))))
  460. (should-not
  461. (org-test-with-temp-text "<file:A%20B>"
  462. (org-lint '(percent-encoding-link-escape))))
  463. (should-not
  464. (org-test-with-temp-text "[[A B%]]"
  465. (org-lint '(percent-encoding-link-escape)))))
  466. (ert-deftest test-org-lint/wrong-header-argument ()
  467. "Test `org-lint-wrong-header-argument' checker."
  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 "call_foo[: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 "#+property: header-args :barbaz yes"
  485. (org-lint '(wrong-header-argument))))
  486. (should
  487. (org-test-with-temp-text "
  488. * H
  489. :PROPERTIES:
  490. :HEADER-ARGS: barbaz yes
  491. :END:"
  492. (org-lint '(wrong-header-argument))))
  493. (should
  494. (org-test-with-temp-text "
  495. * H
  496. :PROPERTIES:
  497. :HEADER-ARGS: :barbaz yes
  498. :END:"
  499. (org-lint '(wrong-header-argument))))
  500. (should
  501. (org-test-with-temp-text "
  502. #+header: :barbaz yes
  503. #+begin_src emacs-lisp
  504. \(+ 1 1)
  505. #+end_src"
  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. (should
  511. (org-test-with-temp-text "src_emacs-lisp[:barbaz yes]{}"
  512. (org-lint '(wrong-header-argument)))))
  513. (ert-deftest test-org-lint/wrong-header-value ()
  514. "Test `org-lint-wrong-header-value' checker."
  515. (should
  516. (org-test-with-temp-text "
  517. #+header: :cache maybe
  518. #+begin_src emacs-lisp
  519. \(+ 1 1)
  520. #+end_src"
  521. (org-lint '(wrong-header-value))))
  522. (should
  523. (org-test-with-temp-text "
  524. #+header: :exports both none
  525. #+begin_src emacs-lisp
  526. \(+ 1 1)
  527. #+end_src"
  528. (org-lint '(wrong-header-value))))
  529. (should-not
  530. (org-test-with-temp-text "
  531. #+header: :cache yes
  532. #+begin_src emacs-lisp
  533. \(+ 1 1)
  534. #+end_src"
  535. (org-lint '(wrong-header-value)))))
  536. (ert-deftest test-org/spurious-colons ()
  537. "Test `org-list-spurious-colons' checker."
  538. (should-not
  539. (org-test-with-temp-text "* H :tag:tag2:"
  540. (org-lint '(spurious-colons))))
  541. (should
  542. (org-test-with-temp-text "* H :tag::tag2:"
  543. (org-lint '(spurious-colons))))
  544. (should
  545. (org-test-with-temp-text "* H :tag::"
  546. (org-lint '(spurious-colons)))))
  547. (ert-deftest test-org-lint/non-existent-bibliography ()
  548. "Test `org-lint-non-existent-bibliography' checker."
  549. (should
  550. (org-test-with-temp-text "#+bibliography: Idonotexist.bib"
  551. (org-lint '(non-existent-bibliography)))))
  552. (ert-deftest test-org-lint/missing-print-bibliography ()
  553. "Test `org-lint-missing-print-bibliography' checker."
  554. (should
  555. (org-test-with-temp-text "[cite:@foo]"
  556. (org-lint '(missing-print-bibliography))))
  557. (should-not
  558. (org-test-with-temp-text "[cite:@foo]\n#+print_bibliography:"
  559. (org-lint '(missing-print-bibliography))))
  560. (should-not
  561. (org-test-with-temp-text ""
  562. (org-lint '(missing-print-bibliography)))))
  563. (ert-deftest test-org-lint/invalid-cite-export-declaration ()
  564. "Test `org-lint-invalid-cite-export-declaration' checker."
  565. (should
  566. (org-test-with-temp-text "#+cite_export: "
  567. (org-lint '(invalid-cite-export-declaration))))
  568. (should
  569. (org-test-with-temp-text "#+cite_export: 2"
  570. (org-lint '(invalid-cite-export-declaration))))
  571. (should
  572. (org-test-with-temp-text "#+cite_export: basic bar baz qux"
  573. (org-lint '(invalid-cite-export-declaration))))
  574. (should
  575. (org-test-with-temp-text "#+cite_export: basic \"bar"
  576. (org-lint '(invalid-cite-export-declaration))))
  577. (should
  578. (org-test-with-temp-text "#+cite_export: unknown"
  579. (org-lint '(invalid-cite-export-declaration))))
  580. (should-not
  581. (org-test-with-temp-text "#+cite_export: basic"
  582. (org-lint '(invalid-cite-export-declaration)))))
  583. (ert-deftest test-org-lint/incomplete-citation ()
  584. "Test `org-lint-incomplete-citation' checker."
  585. (should
  586. (org-test-with-temp-text "[cite:foo]"
  587. (org-lint '(incomplete-citation))))
  588. (should
  589. (org-test-with-temp-text "[cite:@foo"
  590. (org-lint '(incomplete-citation))))
  591. (should-not
  592. (org-test-with-temp-text "[cite:@foo]"
  593. (org-lint '(incomplete-citation)))))
  594. (provide 'test-org-lint)
  595. ;;; test-org-lint.el ends here