From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id qPBDHnerr2WlJQAAe85BDQ:P1 (envelope-from ) for ; Tue, 23 Jan 2024 13:05:11 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id qPBDHnerr2WlJQAAe85BDQ (envelope-from ) for ; Tue, 23 Jan 2024 13:05:11 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=mv4UudsD; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706011511; a=rsa-sha256; cv=none; b=ngQC6+BgwdURfafHrlUH0xD6cdjjM2PHOl6AARsVOxDUW2BrGHy8tM3jnhLPXh0cziog4B HX9Ki2wyWpBdBP3d6N+5t/BN1MCqvrNzzAL+hwu/KiiCJkWAIxYwSoeTRPEoZCOjulHJMm XssFwQUGd/9SLf8AH4bGhLrUsk5F4nQVrSXLLLt9IKJZEz5hgXo1spDsoD+LhiQD0HV6E8 hAMDIjeHd/20l35bzcCzEy93LOx7ptqE+0d609ddX2+RRf0ucO0jQheMLnITJsYHMlO68k cjN+edm/axDB3s4737vzE9ymovCizrdxnmDzEGhNN6wKeFg5TBG3VKQl9DOHiA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=mv4UudsD; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706011511; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2HVVwkXqdB+4T0q+QIDsNxwv/aboO0FLRtM752anwFg=; b=BjYXwJlOTBYNZtuC8Ko0LDGLpWgLe6mvMYc1JfSnQE35y0k5+6XSu/uZI+EWR9dkh9RniZ VNYbOF6CrGNif6PCtUWRICWUL0n/GmmQ9pREzyZIIwT3pFyUfwu3QdUwT7hNntYnUH1wgA LFeInL9Un9dASqAgvifsnDBTpkr6hq/bXbedqPfD/fm7UMYn2diRkj+RuGHhsuBQZiDSNT Em1Ih9m3aXHrLgOcCNqIc3bG2yqcGVW1xbYihDaHakUwkKRRKIGYvXmMDPEmDeLNv30Jxt 2uGLiQZphw3VquWiOENUxSsrY5WkffKP36P0XYUmHLws02hDI0mPaCIsE06PsA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0914826F69 for ; Tue, 23 Jan 2024 13:05:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSFVv-0001Na-I2; Tue, 23 Jan 2024 07:04:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSFVs-0001NM-Gs for emacs-orgmode@gnu.org; Tue, 23 Jan 2024 07:04:20 -0500 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rSFVn-0006SC-FX for emacs-orgmode@gnu.org; Tue, 23 Jan 2024 07:04:19 -0500 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5100c2f7a16so172534e87.1 for ; Tue, 23 Jan 2024 04:04:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706011449; x=1706616249; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=KD69ZQfrT+TChdaNOQE9uhADb+GGj2YYar/ifDnCE50=; b=mv4UudsDnlWvwysmFs9gzEtlSrL1b7pYBa5VrMeo5Sfa3j4o/lhtWFOYIK4wb+ywJx 2/1DUZdegzih255b3owZnng0BEHf1Dq7I9nquVeOqbZLnqnJGzboxwtJ0GHiJOBbKRti U3ujYM/yHeBPo5D5gR914jbYBn8ByEyTEr+z3UpdOs3ln4IM/4Ho+BlF1I0JFhSoB53h X7KUBNtIwi46fhksmhaeuR+v9/Hp0Cgl1mPX2ofytMVRZPZPLV0udC5FxTlrKinA+D7K muDQNawt1jAt3dU3qrB6OAPHGvEzAWicNTtGzBZ4Vbz9eMOcV/Mso48u6zTBJZhsJCJv zCHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706011449; x=1706616249; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KD69ZQfrT+TChdaNOQE9uhADb+GGj2YYar/ifDnCE50=; b=U5I1CCBRd5rnz4CAhar6xwrjuTuGMTdWnnZCDxHPQzBMBR3nRFklQ7Xqro53Vm1g3X 3RI1lFUj7y9msGApJFUqZ0ZPhzgLosrh+Fqi4sCjkMqI/xUmlSPZzLUDt4qRcWgkSkfa PX3AyK5l3NQ8CHutdU5tY+XKOlWJvouW11iDDSfXeaZbxJS2YHKOhEVvSo0zeD3wlE8n CDycRN/QJ9UOhO/qekkORFzsez1wS0Bi9ZnFNJuMm/CJHZBsDwzbAFRrmUSsk9fd6Ela Leh31REtCWyfVJ7ps/zHaR292e+bhjnJdUgU09LBkPZZMdrbIzlURuCdXVluS1Bx/bFe 7krg== X-Gm-Message-State: AOJu0YzpritZxAWB6z2KcgeJ7yw21D6dxUxWqQKT6qIAQWnWLqX51F0B 6X6ZYDzh3p9FmJGoicclqDvdLa1bFztyGFTW07RtS6Vchp8zCbGKlWj9Hco4 X-Google-Smtp-Source: AGHT+IEkJOSzUt8lb4HD4hUjCPNB6D5sSojAd3wOxNaYSPRNdDl7qxzCX6ExztUjvwGiuCXJ7Lxvog== X-Received: by 2002:a19:6747:0:b0:510:8bc:f681 with SMTP id e7-20020a196747000000b0051008bcf681mr612427lfj.15.1706011448829; Tue, 23 Jan 2024 04:04:08 -0800 (PST) Received: from sonyvaio ([92.47.56.38]) by smtp.gmail.com with ESMTPSA id p8-20020a05651212c800b0050e77b1f0c7sm2258546lfg.117.2024.01.23.04.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 04:04:06 -0800 (PST) From: Ilya Chernyshov To: Ihor Radchenko Cc: emacs-orgmode Subject: Re: [PATCH] testing: Delete duplicate tests In-Reply-To: <87il3tl7eb.fsf@localhost> References: <87cz0xndem.fsf@gmail.com> <87cz0wyw9m.fsf@localhost> <87y1ilitzo.fsf@localhost> <87fs3zybvj.fsf@gmail.com> <875y4viv14.fsf@localhost> <878r78ftvs.fsf@localhost> <87sf5cr7na.fsf@gmail.com> <87il3tl7eb.fsf@localhost> Date: Tue, 23 Jan 2024 18:03:58 +0600 Message-ID: <87il3kw91t.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=ichernyshovvv@gmail.com; helo=mail-lf1-x12f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Spam-Score: -5.57 X-Migadu-Queue-Id: 0914826F69 X-Migadu-Spam-Score: -5.57 X-TUID: 7JEf0OqhIRba --=-=-= Content-Type: text/plain Ihor Radchenko writes: > It has been a while since the last update in this thread. > Ilya, do you need any help with the patch? Hi, here is the updated patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-testing-lisp-test-duplicates-detector.el.patch >From 2385ba08a89f2966a6d71f92e8693e7def33e3fe Mon Sep 17 00:00:00 2001 From: Ilya Chernyshov Date: Mon, 22 Jan 2024 01:33:56 +0600 Subject: [PATCH] Add testing/lisp/test-duplicates-detector.el * testing/lisp/test-duplicates-detector.el: Add test unit that checks for duplicate ert-deftests and forms inside of them. * testing/lisp/test-org.el (test-org/file-contents): Delete duplicate `should-' form. * testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments, test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export, test-ob-lob/caching-call-line, test-ob-lob/named-caching-call-line, test-ob/just-one-results-block): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-ob.el (test-ob/just-one-results-block): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-ob-R.el (test-ob-R/results-file): Ignore duplicate forms via `org-test-ignore-duplicate'. * testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions): Ignore duplicate forms via `org-test-ignore-duplicate'. * testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1, test-ob/inline-src_blk-default-results-replace-line-2, test-ob/inline-src_blk-manual-results-replace, test-ob/inline-src_blk-results-silent, test-ob/just-one-results-block, test-ob/remove-inline-result, test-ob/goto-named-src-block): Ignore duplicate forms via `org-test-ignore-duplicate'. * testing/lisp/test-org-agenda.el (test-org-agenda/property-timestamp, test-org-agenda/sticky-agenda-filter-preset): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-element.el (test-org-element/cache-headline): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-list.el (test-org-list/list-navigation, test-org-list/move-item-down, test-org-list/move-item-up): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-src.el (test-org-src/basic): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org-table.el (test-org-table/org-at-TBLFM-p, test-org-table/org-table-TBLFM-begin, test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines, test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks): Ignore duplicate forms via `org-test-ignore-duplicate' * testing/lisp/test-org.el (test-org/goto-sibling, test-org/backward-element, test-org/up-element, test-org/org-ctrl-c-ctrl-c, test-org/forward-element): Ignore duplicate forms via `org-test-ignore-duplicate' --- testing/lisp/test-duplicates-detector.el | 316 +++++++++++++++++++++++ testing/lisp/test-ob-R.el | 5 +- testing/lisp/test-ob-haskell-ghci.el | 3 +- testing/lisp/test-ob-lob.el | 87 ++++--- testing/lisp/test-ob.el | 113 ++++---- testing/lisp/test-ol.el | 35 +-- testing/lisp/test-org-agenda.el | 9 +- testing/lisp/test-org-element.el | 18 +- testing/lisp/test-org-fold.el | 29 ++- testing/lisp/test-org-list.el | 31 ++- testing/lisp/test-org-src.el | 3 +- testing/lisp/test-org-table.el | 117 ++++----- testing/lisp/test-org.el | 38 ++- 13 files changed, 568 insertions(+), 236 deletions(-) create mode 100644 testing/lisp/test-duplicates-detector.el diff --git a/testing/lisp/test-duplicates-detector.el b/testing/lisp/test-duplicates-detector.el new file mode 100644 index 000000000..d39092a9e --- /dev/null +++ b/testing/lisp/test-duplicates-detector.el @@ -0,0 +1,316 @@ +;;; test-duplicates-detector.el --- Tests for finding duplicates in Org tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Ilya Chernyshov +;; Authors: Ilya Chernyshov + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: + +;; Unit tests that check for duplicate forms and tests in all Org test files. + +;; Forms are considered duplicate if they: + +;; 1. are `equal-including-properties', +;; 2. have the same nesting path, +;; 3. either are `should-' macros or have `should-' macros inside. + +;; To ignore a form or a group of forms, wrap them in +;; `org-test-ignore-duplicate'. + +;; `ert-deftest' are considered duplicate if their body are +;; `equal-including-properties.' When comparing, the docstrings are not taken +;; into account. + +;;; Code: + +(require 'org-test "../testing/org-test") + +;;;; Variables + +(defvar test-duplicates-detector-file-path + (expand-file-name "test-duplicates-detector.el" + (expand-file-name "lisp" org-test-dir))) + +(defvar test-duplicates-detector-files + (remove + test-duplicates-detector-file-path + (directory-files + (expand-file-name "lisp" org-test-dir) t "\\.el$"))) + +(defvar test-duplicates-detector-duplicate-forms nil + "A nested list of the form: + + (((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + (dup-form-1 . (numerical-order [numerical-order ...])) + [ (dup-form-2 . (numerical-order [numerical-order ...])) + (dup-form-3 . (numerical-order [numerical-order ...])) + ...]) + + ((file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + (dup-form-1 . (numerical-order [numerical-order ...])) + [ (dup-form-2 . (numerical-order [numerical-order ...])) + (dup-form-3 . (numerical-order [numerical-order ...])) + ...]) + + ... + ) + +Where + + (file test-name [(form-1 . numerical-order) + (form-2 . numerical-order) ...]) + +is a path to duplicates. For example, the path for the +duplicates in the following test: + + test-ob-haskell-ghci.el + + (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions () + \"When no session, use a new session. + \"none\" is a special name that means `no session'.\" + (let ((var-1 \"value\")) + (when var-1 + (should-not + (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) + (test-ob-haskell-ghci \":session none\" \"x=2\") + (should-not + (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) + (test-ob-haskell-ghci \":session none\" \"x=2\")))) + +would look like this: + + (\"test-ob-haskell-ghci.el\" + ob-haskell/session-named-none-means-one-shot-sessions + (let . 4) (when . 2)) + +And the records about the duplicates would look like this: + + ((test-ob-haskell-ghci \":session none\" \"x=2\") 5 3) + ((should-not + (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil))) 4 2)") + +(defvar test-duplicates-detector-forms nil + "Nested alist of found forms and paths to them (not filtered).") + +;;;; Macros + +(defmacro org-test-ignore-duplicate (&rest body) + "Eval BODY forms sequentially and return value of last one. + +The macro's body will be ignored by `test-duplicates-detector.el' +tests to skip duplicate forms inside the body." + (declare (indent 0)) + `(progn ,@body)) + +;;;; ERT tests + +(ert-deftest test-org-tests/find-duplicates () + "Try to find duplicate forms and ert-deftests in FILES." + (should-not + (test-duplicates-detector--find-duplicates + test-duplicates-detector-files))) + +;;;; Auxiliary functions + +(defun test-duplicates-detector--find-duplicates (files) + "Try to find duplicate forms and ert-deftests in FILES. + +Duplicate forms will be written to +`test-duplicates-detector-duplicate-forms'. + +`message' paths to them in a human-readable format." + (setq test-duplicates-detector-forms nil) + (let (found-deftests duplicate-tests) + (dolist (file files) + (with-current-buffer (find-file-noselect file) + (save-excursion + (goto-char (point-min)) + (while (search-forward "(ert-deftest" nil t) + (goto-char (match-beginning 0)) + (ignore-errors + (while-let ((deftest (or (read (current-buffer)) t)) + ((eq (car deftest) 'ert-deftest)) + (test-name (cadr deftest))) + (if-let ((f (seq-find + (lambda (x) + (equal-including-properties + ;; if cadddr is a docstring + (if (stringp (cadddr deftest)) + (cddddr deftest) + (cdddr deftest)) + (if (stringp (cadddr x)) + (cddddr x) + (cdddr x)))) + found-deftests))) + (push (cons test-name (cadr f)) duplicate-tests) + (push deftest found-deftests)) + (test-duplicates-detector--search-forms-recursively + deftest (list file (cadr deftest))))))))) + (setq test-duplicates-detector-duplicate-forms + (seq-filter + #'cdr + (mapcar + (lambda (file) + (cons + (car file) + (seq-filter + (lambda (x) + (and (caddr x) + (seq-intersection + '(should-not should should-error) + (flatten-list (car x))))) + (cdr file)))) + test-duplicates-detector-forms))) + (when test-duplicates-detector-duplicate-forms + (message + "Found duplicates (To ignore the duplicate forms, +wrap them in `org-test-ignore-duplicate'): +%s" + (mapconcat + (lambda (path) + (let* ((file (file-relative-name (caar path))) + (test-name (symbol-name (cadar path))) + (string-path (append (list file test-name) + (mapcar (lambda (x) + (symbol-name (car x))) + (cddar path)))) + (indent -1) + (print-level 3)) + (concat + (mapconcat + (lambda (x) + (concat (make-string (* (setq indent (1+ indent)) 2) ? ) + x "\n")) + string-path) + (mapconcat + (lambda (x) + (format "%s%S: %d times\n" + (make-string (* indent 2) ? ) + (car x) + (length (cdr x)))) + (cdr path))))) + test-duplicates-detector-duplicate-forms))) + (when duplicate-tests + (message "Duplicate ERT tests found:\n%s\n" + (mapconcat (lambda (x) (format "%S" x)) + duplicate-tests "\n"))) + (append test-duplicates-detector-duplicate-forms + duplicate-tests))) + +(defun test-duplicates-detector--search-forms-recursively (form form-path) + "Search for forms recursively in FORM. + +FORM-PATH is list of the form: + (\"file-path\" ert-test-symbol + (symbol-1 . sexp-order-1) (symbol-2 . sexp-order-2)) + +Write each form to `test-duplicates-detector-forms'" + (dotimes (iter (length form)) + (when (and + (car-safe (nth iter form)) + (not + (eq (car-safe (nth iter form)) + 'org-test-ignore-duplicate))) + (push iter (alist-get + (nth iter form) + (alist-get form-path test-duplicates-detector-forms + nil nil #'equal) + nil nil #'equal-including-properties)) + (unless (memq (car-safe (nth iter form)) + '(should-not should should-error)) + (test-duplicates-detector--search-forms-recursively + (nth iter form) + (append form-path (list (cons (car (nth iter form)) iter)))))))) + +;;;; Testing the detector itself + +(ert-deftest test-duplicates-detector-testing-find-duplicates () + "Test `test-duplicates-detector--find-duplicates'." + (should + (equal + (test-duplicates-detector--find-duplicates + (list test-duplicates-detector-file-path)) + `((((,test-duplicates-detector-file-path + test-org-tests/test-with-nested-duplicates) + ((let ((var "string")) (should (message "123 %s" var))) 6 4)) + ((,test-duplicates-detector-file-path + test-org-tests/test-with-duplicates-at-root) + ((should (message "123")) 6 4))) + ((test-org-tests/duplicate-test-2 . test-org-tests/duplicate-test-1)))))) + +;;;;; Tests with duplicate forms + +(ert-deftest test-org-tests/test-with-duplicates-at-root () + "Test with duplicates at the root." + (should (message "123")) + (format "%s" "string") + (should + (message "123"))) + +(ert-deftest test-org-tests/test-with-nested-duplicates () + "Test with nested duplicates." + (let ((var "string")) + (should + (message "123 %s" var))) + (format "%s" "string") + (let ((var "string")) + (should (message "123 %s" var))) + (format "%s" "string")) + +;;;;; Tests without duplicates + +(ert-deftest test-org-tests/test-without-duplicates-1 () + "Test without duplicates." + (let ((var-1 "asd")) + (concat "string" var-1)) + (should + (let ((var-1 "asd")) + (concat "string" var-1)))) + +(ert-deftest test-org-tests/test-without-duplicates-2 () + "Test without duplicates. +Equal `should' macros, but different nesting paths." + (let ((var "string")) + (should (format "123 %s" "asd"))) + (+ 5 6 9) + (should (format "123 %s" "asd"))) + +;;;;; Duplicate deftests (maybe different names, but same body) + +(ert-deftest test-org-tests/duplicate-test-1 () + "Docstring of duplicate-test-1." + (let ((var 99)) + (+ 5 6 9 var) + (should (format "123 %s" "asd"))) + (should (format "123 %s" "asd"))) + +(ert-deftest test-org-tests/duplicate-test-2 () + "Docstring of duplicate-test-2." + (let ((var 99)) + (+ 5 6 9 var) + (should (format "123 %s" "asd"))) + (should (format "123 %s" "asd"))) + +(provide 'test-duplicates-detector) + +;; Local Variables: +;; outline-regexp: "\\(;\\{3,\\} \\)" +;; End: + +;;; test-duplicates-detector.el ends here diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el index 9ffbf3afd..52e093edd 100644 --- a/testing/lisp/test-ob-R.el +++ b/testing/lisp/test-ob-R.el @@ -98,8 +98,9 @@ x #+END_SRC" (goto-char (point-min)) (org-babel-execute-maybe) (org-babel-goto-named-result "TESTSRC") (forward-line 1) - (should (string= "[[file:junk/test.org]]" - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= "[[file:junk/test.org]]" + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (goto-char (point-min)) (forward-line 1) (insert "#+header: :session\n") (goto-char (point-min)) (org-babel-execute-maybe) diff --git a/testing/lisp/test-ob-haskell-ghci.el b/testing/lisp/test-ob-haskell-ghci.el index cbd5f6f9a..55c0eb2b8 100644 --- a/testing/lisp/test-ob-haskell-ghci.el +++ b/testing/lisp/test-ob-haskell-ghci.el @@ -118,7 +118,8 @@ main "When no session, use a new session. \"none\" is a special name that means `no session'." (test-ob-haskell-ghci ":session none" "x=2" nil) - (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil))) + (org-test-ignore-duplicate + (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) (test-ob-haskell-ghci ":session none" "x=2" nil) (should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))) diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index 188fee4c0..1a3fdff16 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -62,44 +62,45 @@ (move-beginning-of-line 1) (forward-line 6) (message (buffer-substring (point-at-bol) (point-at-eol))) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) (beginning-of-line) (forward-char 27) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) - (forward-line 1) (beginning-of-line) (forward-char 27) - (should - (string= "testing" (caar (org-babel-execute-src-block - nil (org-babel-lob-get-info))))) - (forward-line 1) (beginning-of-line) - (should - (= 4 (org-babel-execute-src-block nil (org-babel-lob-get-info)))) - (forward-line 1) - (should - (string= "testing" (org-babel-execute-src-block - nil (org-babel-lob-get-info)))) + (org-test-ignore-duplicate + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) (beginning-of-line) (forward-char 27) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info)))) + (forward-line 1) (beginning-of-line) (forward-char 27) + (should + (string= "testing" (caar (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) + (forward-line 1) (beginning-of-line) + (should + (= 4 (org-babel-execute-src-block nil (org-babel-lob-get-info)))) + (forward-line 1) + (should + (string= "testing" (org-babel-execute-src-block + nil (org-babel-lob-get-info))))) (forward-line 1) (should (string= "123" (org-babel-execute-src-block nil (org-babel-lob-get-info)))))))) @@ -149,8 +150,9 @@ for export #+call: call-line-caching-example(\"qux\") :cache yes " ;; first execution should flip value to t - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) + (org-test-ignore-duplicate + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))) ;; if cached, second evaluation will retain the t value (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) @@ -167,8 +169,9 @@ for export #+call: call-line-caching-example(\"qux\") :cache yes " ;; first execution should flip value to t - (should - (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1)) + (org-test-ignore-duplicate + (should + (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))) ;; if cached, second evaluation will retain the t value (should (eq (org-babel-execute-src-block nil (org-babel-lob-get-info)) 1))))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 42c77ca56..c16b47954 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -362,13 +362,15 @@ at the beginning of a line." (org-test-with-temp-text test-line (goto-char (point-min)) (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (forward-char) (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "{{{") ;;(should-error (org-ctrl-c-ctrl-c)) (backward-char 4) ;; last char of block body @@ -380,11 +382,13 @@ at the beginning of a line." (let ((test-line " src_emacs-lisp{ 1 }")) (org-test-with-temp-text test-line - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (forward-char) (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=1=)}}}") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=1=)}}}") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "{ 1 ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=1=)}}}") @@ -426,9 +430,11 @@ at the beginning of a line." (org-babel-inline-result-wrap "=%s=")) (org-test-with-temp-text (concat "\n" test-line) - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (goto-char (point-min)) - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (forward-line) (should-error (org-ctrl-c-ctrl-c)) (forward-char) (org-babel-execute-maybe) @@ -443,9 +449,10 @@ at the beginning of a line." (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src") (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=y=)}}} end") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=y=)}}} end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=y=)}}} end") @@ -458,7 +465,8 @@ at the beginning of a line." (org-babel-inline-result-wrap "=%s=")) (org-test-with-temp-text (concat "\n" test-line) - (should-error (org-ctrl-c-ctrl-c)) + (org-test-ignore-duplicate + (should-error (org-ctrl-c-ctrl-c))) (goto-char (point-max)) (org-babel-execute-maybe) (beginning-of-line) @@ -475,9 +483,10 @@ at the beginning of a line." (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src") (org-babel-execute-maybe) - (should (string= - (concat test-line " {{{results(=y=)}}} end") - (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= + (concat test-line " {{{results(=y=)}}} end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " {{{results(=y=)}}} end") @@ -499,9 +508,10 @@ at the beginning of a line." (goto-char (point-max)) (insert (concat "\n" test-line " end")) (re-search-backward "src_") (org-babel-execute-maybe) - (should (string= (concat test-line " end") - (buffer-substring-no-properties - (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= (concat test-line " end") + (buffer-substring-no-properties + (point-at-bol) (point-at-eol))))) (re-search-forward "\" ") (org-babel-execute-maybe) (should (string= (concat test-line " end") (buffer-substring-no-properties @@ -644,7 +654,8 @@ duplicate results block." (org-test-with-temp-text "#+begin_src sh :results output\necho Hello\n#+end_src\n" (org-babel-execute-src-block) (org-babel-execute-src-block) ; second code block execution - (should (search-forward "Hello")) ; the string inside the source code block + (org-test-ignore-duplicate + (should (search-forward "Hello"))) ; the string inside the source code block (should (search-forward "Hello")) ; the same string in the results block (should-error (search-forward "Hello")))) @@ -1159,9 +1170,10 @@ x (point-at-bol) (point-at-eol)))) ;; Delete whitespace and result. (org-babel-remove-inline-result) - (should (string= inline-sb-dot - (buffer-substring-no-properties - (point-at-bol) (point-at-eol)))) + (org-test-ignore-duplicate + (should (string= inline-sb-dot + (buffer-substring-no-properties + (point-at-bol) (point-at-eol))))) ;; Add whitespace and result before dot. (search-forward inline-sb) (insert " " inline-res) @@ -2466,31 +2478,32 @@ abc #+RESULTS: abc : 2 " - ;; non-existent name - (should-not + (org-test-ignore-duplicate + ;; non-existent name + (should-not (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nno-name\n")) - ;; correct name - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nabc\n") - (should (= 14 (point))) - ;; call line - autocompletion - (forward-line 3) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; noweb reference - autocompletion - (forward-line 5) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; at symbol - autocompletion - (forward-line 7) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - ;; in results - autocompletion - (forward-line 8) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))) - (forward-line 9) - (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") - (should (= 14 (point))))) + ;; correct name + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\nabc\n") + (should (= 14 (point))) + ;; call line - autocompletion + (forward-line 3) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; noweb reference - autocompletion + (forward-line 5) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; at symbol - autocompletion + (forward-line 7) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + ;; in results - autocompletion + (forward-line 8) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point))) + (forward-line 9) + (execute-kbd-macro "\M-xorg-babel-goto-named-src-block\n\n") + (should (= 14 (point)))))) (ert-deftest test-ob/evaluate-body-with-coderefs () (should diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el index e0cec0854..6a44e5bdc 100644 --- a/testing/lisp/test-ol.el +++ b/testing/lisp/test-ol.el @@ -60,23 +60,24 @@ See https://github.com/yantar92/org/issues/4." (dolist (org-link-descriptive '(nil t)) (org-test-with-temp-text "* Org link test [[https://example.com][A link to a site]]" - (dotimes (_ 2) - (goto-char 1) - (re-search-forward "\\[") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "example") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "com") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "]") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (re-search-forward "\\[") - (should-not (org-invisible-p)) - (re-search-forward "link") - (should-not (org-invisible-p)) - (re-search-forward "]") - (should-not (org-xor org-link-descriptive (org-invisible-p))) - (org-toggle-link-display))))) + (org-test-ignore-duplicate + (dotimes (_ 2) + (goto-char 1) + (re-search-forward "\\[") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "example") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "com") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "]") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (re-search-forward "\\[") + (should-not (org-invisible-p)) + (re-search-forward "link") + (should-not (org-invisible-p)) + (re-search-forward "]") + (should-not (org-xor org-link-descriptive (org-invisible-p))) + (org-toggle-link-display)))))) ;;; Escape and Unescape Links diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el index 976d88a9e..ce7ae3c63 100644 --- a/testing/lisp/test-org-agenda.el +++ b/testing/lisp/test-org-agenda.el @@ -346,7 +346,8 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com" ;; `org-today' or not. (org-agenda-list nil "<2022-03-22 Tue>") (set-buffer org-agenda-buffer-name) - (should (= 3 (count-lines (point-min) (point-max)))) + (org-test-ignore-duplicate + (should (= 3 (count-lines (point-min) (point-max))))) ;; NOTE: Be aware that `org-agenda-list' may or may not display ;; past scheduled items depending whether the date is today ;; `org-today' or not. @@ -443,14 +444,16 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com" (set-buffer "*Org Agenda(f)*") (org-agenda-redo) (goto-char (point-min)) - (should (not (invisible-p (1- (search-forward "TODO Foo"))))) + (org-test-ignore-duplicate + (should (not (invisible-p (1- (search-forward "TODO Foo")))))) (org-test-agenda--kill-all-agendas) (org-agenda nil "f1") (org-agenda nil "b1") (set-buffer "*Org Agenda(f1:+CATEGORY=\"foo\")*") (org-agenda-redo) (goto-char (point-min)) - (should (not (invisible-p (1- (search-forward "TODO Foo"))))) + (org-test-ignore-duplicate + (should (not (invisible-p (1- (search-forward "TODO Foo")))))) (org-test-agenda--kill-all-agendas) (org-agenda nil "f2") (org-agenda nil "b2") diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index ca7d77e28..6e0e5c5ec 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -5203,11 +5203,12 @@ Aliquam erat volutpat. (org-element-at-point)) (insert ":CATEOGORY: cat\n") (search-backward "* Heading") - (should - (eq (org-element-property :end (org-element-at-point)) - (save-excursion - (search-forward "* Heading 2") - (line-beginning-position)))) + (org-test-ignore-duplicate + (should + (eq (org-element-property :end (org-element-at-point)) + (save-excursion + (search-forward "* Heading 2") + (line-beginning-position))))) (search-forward "* Heading 2") (beginning-of-line) (insert "\n\n") @@ -5247,9 +5248,10 @@ Aliquam erat volutpat. (org-element-at-point (point-max)) (insert "* heading 2") (beginning-of-line) - (should - (eq (point-max) - (org-element-property :end (org-element-at-point)))) + (org-test-ignore-duplicate + (should + (eq (point-max) + (org-element-property :end (org-element-at-point))))) (delete-char 1) (search-backward "* Heading") (should diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el index 9f15f0a38..7fd4b015c 100644 --- a/testing/lisp/test-org-fold.el +++ b/testing/lisp/test-org-fold.el @@ -329,20 +329,21 @@ Some text here ** AC * B " - (org-set-regexps-and-options) - (org-cycle-set-startup-visibility) - (search-forward "A") - (should-not (invisible-p (point))) - (search-forward "AB") - (should (invisible-p (point))) - (search-forward "ABA") - (should (invisible-p (point))) - (search-forward "ABAB") - (should (invisible-p (point))) - (search-forward "AC") - (should (invisible-p (point))) - (search-forward "B") - (should-not (invisible-p (point)))) + (org-test-ignore-duplicate + (org-set-regexps-and-options) + (org-cycle-set-startup-visibility) + (search-forward "A") + (should-not (invisible-p (point))) + (search-forward "AB") + (should (invisible-p (point))) + (search-forward "ABA") + (should (invisible-p (point))) + (search-forward "ABAB") + (should (invisible-p (point))) + (search-forward "AC") + (should (invisible-p (point))) + (search-forward "B") + (should-not (invisible-p (point))))) ;; "children" state. (should (org-test-with-temp-text diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 0ee3a14c2..89c42b400 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -61,11 +61,14 @@ ;; a list/sub-list, unless `org-list-use-circular-motion' ;; is non-nil. (goto-line 9) - (should-error (org-next-item)) - (let ((org-list-use-circular-motion t)) - (should (progn (org-next-item) t))) + (org-test-ignore-duplicate + (should-error (org-next-item))) + (org-test-ignore-duplicate + (let ((org-list-use-circular-motion t)) + (should (progn (org-next-item) t)))) (goto-line 14) - (should-error (org-next-item)) + (org-test-ignore-duplicate + (should-error (org-next-item))) (let ((org-list-use-circular-motion t)) (should (progn (org-next-item) t))) ;; 1.2. Should jump over sub-lists. @@ -91,11 +94,14 @@ ;; a list/sub-list, unless `org-list-use-circular-motion is ;; non-nil. (goto-line 7) - (should-error (org-previous-item)) - (let ((org-list-use-circular-motion t)) - (should (progn (org-previous-item) t))) + (org-test-ignore-duplicate + (should-error (org-previous-item))) + (org-test-ignore-duplicate + (let ((org-list-use-circular-motion t)) + (should (progn (org-previous-item) t)))) (goto-line 13) - (should-error (org-previous-item)) + (org-test-ignore-duplicate + (should-error (org-previous-item))) (let ((org-list-use-circular-motion t)) (should (progn (org-previous-item) t))) ;; 2.2. Should ignore sub-lists. @@ -705,7 +711,8 @@ b. Item 2" (search-backward "- item 1") (org-move-item-down) (search-forward "sub-body 1") - (should (org-invisible-p2)) + (org-test-ignore-duplicate + (should (org-invisible-p2))) (search-backward "sub-body 2") (should (org-invisible-p2)))) @@ -784,7 +791,8 @@ b. Item 2" (org-cycle)) (org-move-item-up) (forward-line) - (should (org-invisible-p2)) + (org-test-ignore-duplicate + (should (org-invisible-p2))) (search-forward " body 1") (should (org-invisible-p2))) ;; Preserve children visibility. @@ -803,7 +811,8 @@ b. Item 2" (search-backward "- item 2") (org-move-item-up) (search-forward "sub-body 2") - (should (org-invisible-p2)) + (org-test-ignore-duplicate + (should (org-invisible-p2))) (search-forward "sub-body 1") (should (org-invisible-p2)))) diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el index ebf8d8569..c079cc464 100644 --- a/testing/lisp/test-org-src.el +++ b/testing/lisp/test-org-src.el @@ -54,7 +54,8 @@ #+end_src " (goto-line 1) - (should-error (org-edit-special)) + (org-test-ignore-duplicate + (should-error (org-edit-special))) (goto-char (point-max)) (should-error (org-edit-special)))) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 92ccd2a05..8eda95f3e 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1120,7 +1120,8 @@ See also `test-org-table/copy-field'." " (goto-char (point-min)) (forward-line 2) - (should (equal (org-at-TBLFM-p) nil)) + (org-test-ignore-duplicate + (should (equal (org-at-TBLFM-p) nil))) (goto-char (point-min)) (forward-line 3) @@ -1139,25 +1140,21 @@ See also `test-org-table/copy-field'." " (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) - nil)) + (org-test-ignore-duplicate + (should (equal (org-table-TBLFM-begin) nil))) (goto-char (point-min)) (forward-line 1) - (should (equal (org-table-TBLFM-begin) - nil)) + (should (equal (org-table-TBLFM-begin) nil)) (goto-char (point-min)) (forward-line 3) - (should (= (org-table-TBLFM-begin) - 14)) + (org-test-ignore-duplicate + (should (= (org-table-TBLFM-begin) 14))) (goto-char (point-min)) (forward-line 4) - (should (= (org-table-TBLFM-begin) - 14)) - - )) + (should (= (org-table-TBLFM-begin) 14)))) (ert-deftest test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines () "For multiple #+TBLFM lines." @@ -1169,31 +1166,25 @@ See also `test-org-table/copy-field'." #+TBLFM: $2=$1*2 " - (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) - nil)) - - (goto-char (point-min)) - (forward-line 1) - (should (equal (org-table-TBLFM-begin) - nil)) + (org-test-ignore-duplicate + (goto-char (point-min)) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 3) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 1) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 4) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 3) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 5) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 4) + (should (= (org-table-TBLFM-begin) 14)) - )) + (goto-char (point-min)) + (forward-line 5) + (should (= (org-table-TBLFM-begin) 14))))) (ert-deftest test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks () (org-test-with-temp-text-in-file @@ -1209,49 +1200,41 @@ See also `test-org-table/copy-field'." #+TBLFM: $2=$1*2 " - (goto-char (point-min)) - (should (equal (org-table-TBLFM-begin) - nil)) + (org-test-ignore-duplicate + (goto-char (point-min)) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 1) - (should (equal (org-table-TBLFM-begin) - nil)) + (goto-char (point-min)) + (forward-line 1) + (should (equal (org-table-TBLFM-begin) nil)) - (goto-char (point-min)) - (forward-line 3) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 3) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 4) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 4) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 5) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 5) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 6) - (should (= (org-table-TBLFM-begin) - 14)) + (goto-char (point-min)) + (forward-line 6) + (should (= (org-table-TBLFM-begin) 14)) - (goto-char (point-min)) - (forward-line 8) - (should (= (org-table-TBLFM-begin) - 61)) + (goto-char (point-min)) + (forward-line 8) + (should (= (org-table-TBLFM-begin) 61)) - (goto-char (point-min)) - (forward-line 9) - (should (= (org-table-TBLFM-begin) - 61)) + (goto-char (point-min)) + (forward-line 9) + (should (= (org-table-TBLFM-begin) 61)) - (goto-char (point-min)) - (forward-line 10) - (should (= (org-table-TBLFM-begin) - 61)))) + (goto-char (point-min)) + (forward-line 10) + (should (= (org-table-TBLFM-begin) 61))))) (ert-deftest test-org-table/org-table-calc-current-TBLFM () (org-test-with-temp-text-in-file diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 822cbc67a..d379ee3bf 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2488,7 +2488,8 @@ Text. (should (org-goto-sibling)) (should (looking-at-p "^\\*\\* Heading 3")) (should-not (org-goto-sibling)) - (should (org-goto-sibling 'previous)) + (org-test-ignore-duplicate + (should (org-goto-sibling 'previous))) (should (looking-at-p "^\\*\\* Heading 2")) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 1")) @@ -2531,7 +2532,8 @@ test (should (org-goto-sibling)) (should (looking-at-p "^\\*\\* Heading 3")) (should-not (org-goto-sibling)) - (should (org-goto-sibling 'previous)) + (org-test-ignore-duplicate + (should (org-goto-sibling 'previous))) (should (looking-at-p "^\\*\\* Heading 2")) (should (org-goto-sibling 'previous)) (should (looking-at-p "^\\*\\* Heading 1")) @@ -3994,17 +3996,6 @@ SCHEDULED: <2017-05-06 Sat> (org-file-contents "http://this-url-must-not-exist")) (kill-buffer buffer)))) ;; Try to access an invalid URL, but do not throw an error. - (should-error - (let ((buffer (generate-new-buffer "url-retrieve-output"))) - (unwind-protect - ;; Simulate unsuccessful retrieval of a URL. - (cl-letf (((symbol-function 'url-retrieve-synchronously) - (lambda (&rest_) - (with-current-buffer buffer - (insert "HTTP/1.1 404 Not found\n\ndoes not matter")) - buffer))) - (org-file-contents "http://this-url-must-not-exist")) - (kill-buffer buffer)))) (should (let ((buffer (generate-new-buffer "url-retrieve-output"))) (unwind-protect @@ -4027,7 +4018,8 @@ SCHEDULED: <2017-05-06 Sat> * Heading text" (org-overview) - (should (org-fold-folded-p (point) 'outline)) + (org-test-ignore-duplicate + (should (org-fold-folded-p (point) 'outline))) (save-excursion (goto-char (point-min)) (org-ctrl-c-ctrl-c)) @@ -5127,7 +5119,8 @@ asd ;; same level. (goto-line 3) (org-forward-element) - (should (looking-at (regexp-quote "** Head 1.2"))) + (org-test-ignore-duplicate + (should (looking-at (regexp-quote "** Head 1.2")))) ;; 3.2. At an headline beginning: move to parent headline if no ;; headline at the same level. (goto-line 3) @@ -5138,7 +5131,8 @@ asd "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside." ;; 4.1. At a greater element: expected to skip contents. (org-forward-element) - (should (looking-at (regexp-quote "Outside."))) + (org-test-ignore-duplicate + (should (looking-at (regexp-quote "Outside.")))) ;; 4.2. At the end of greater element contents: expected to skip ;; to the end of the greater element. (goto-line 2) @@ -5177,7 +5171,8 @@ Outside." ;; 5.3 At sub-list beginning: expected to move after the sub-list. (goto-line 4) (org-forward-element) - (should (looking-at (regexp-quote " Inner paragraph."))) + (org-test-ignore-duplicate + (should (looking-at (regexp-quote " Inner paragraph.")))) ;; 5.4. At sub-list end: expected to move outside the sub-list. (goto-line 8) (org-forward-element) @@ -5264,7 +5259,8 @@ Outside." (should (looking-at " - sub2")) (goto-line 12) (org-backward-element) - (should (looking-at "- item1")) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) ;; 7.3. At end of list/sub-list: expected to move to list/sub-list ;; beginning. (goto-line 10) @@ -5272,7 +5268,8 @@ Outside." (should (looking-at " - sub1")) (goto-line 15) (org-backward-element) - (should (looking-at "- item1")) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) ;; 7.4. At blank-lines before list end: expected to move to top ;; item. (goto-line 14) @@ -5319,7 +5316,8 @@ Outside." ;; 4.2. At an item in a sub-list: move to parent item. (goto-line 4) (org-up-element) - (should (looking-at "- item1")) + (org-test-ignore-duplicate + (should (looking-at "- item1"))) ;; 4.3. At an item in top list: move to beginning of whole list. (goto-line 10) (org-up-element) -- 2.41.0 --=-=-=--