[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/merge-cedet-tests b85662e 218/316: New file, deriv
From: |
Edward John Steere |
Subject: |
[Emacs-diffs] scratch/merge-cedet-tests b85662e 218/316: New file, derived from logging functions in cedet-utest.el |
Date: |
Fri, 27 Jan 2017 20:03:41 +0000 (UTC) |
branch: scratch/merge-cedet-tests
commit b85662e395871f88e40722effe14a1bb2d1c579e
Author: Eric Ludlam <address@hidden>
Commit: Edward John Steere <address@hidden>
New file, derived from logging functions in cedet-utest.el
---
test/manual/cedet/cedet-uutil.el | 233 ++++++++++++++++++++++++++++++++++++++
1 file changed, 233 insertions(+)
diff --git a/test/manual/cedet/cedet-uutil.el b/test/manual/cedet/cedet-uutil.el
new file mode 100644
index 0000000..eca795e
--- /dev/null
+++ b/test/manual/cedet/cedet-uutil.el
@@ -0,0 +1,233 @@
+;;; cedet-uutil.el --- Unit test utilities for the CEDET suite.
+;;
+;; Copyright (C) 2011 Eric M. Ludlam
+;;
+;; Author: Eric M. Ludlam <address@hidden>
+;;
+;; 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 http://www.gnu.org/licenses/.
+
+;;; Commentary:
+;;
+;; Utilities needed to run the complete CEDET unit test suite.
+
+;;; Code:
+(defvar cedet-running-master-tests nil
+ "Non-nil when CEDET-utest is running all the tests.")
+
+(defun cedet-utest-noninteractive ()
+ "Return non-nil if running non-interactively."
+ (if (featurep 'xemacs)
+ (noninteractive)
+ noninteractive))
+
+(defvar cedet-utest-root (let ((CEDETDIR (file-name-directory
+ (or load-file-name
(buffer-file-name)))))
+ (file-name-directory CEDETDIR))
+ "Location of the CEDET test suites.")
+
+;;; Logging utility.
+;;
+(defvar cedet-utest-frame nil
+ "Frame used during cedet unit test logging.")
+(defvar cedet-utest-buffer nil
+ "Frame used during cedet unit test logging.")
+(defvar cedet-utest-frame-parameters
+ '((name . "CEDET-UTEST")
+ (width . 80)
+ (height . 25)
+ (minibuffer . t))
+ "Frame parameters used for the cedet utest log frame.")
+
+(defvar cedet-utest-last-log-item nil
+ "Remember the last item we were logging for.")
+
+(defvar cedet-utest-log-timer nil
+ "During a test, track the start time.")
+
+(defun cedet-utest-log-setup (&optional title)
+ "Setup a frame and buffer for unit testing.
+Optional argument TITLE is the title of this testing session."
+ (setq cedet-utest-log-timer (current-time))
+ (if (cedet-utest-noninteractive)
+ (message "\n>> Setting up %s tests to run @ %s\n"
+ (or title "")
+ (current-time-string))
+
+ ;; Interactive mode needs a frame and buffer.
+ (when (or (not cedet-utest-frame) (not (frame-live-p cedet-utest-frame)))
+ (setq cedet-utest-frame (make-frame cedet-utest-frame-parameters)))
+ (when (or (not cedet-utest-buffer) (not (buffer-live-p
cedet-utest-buffer)))
+ (setq cedet-utest-buffer (get-buffer-create "*CEDET utest log*")))
+ (save-excursion
+ (set-buffer cedet-utest-buffer)
+ (setq cedet-utest-last-log-item nil)
+ (when (not cedet-running-master-tests)
+ (erase-buffer))
+ (insert "\n\nSetting up "
+ (or title "")
+ " tests to run @ " (current-time-string) "\n\n"))
+ (let ((oframe (selected-frame)))
+ (unwind-protect
+ (progn
+ (select-frame cedet-utest-frame)
+ (switch-to-buffer cedet-utest-buffer t))
+ (select-frame oframe)))
+ ))
+
+(defun cedet-utest-elapsed-time (start end)
+ "Copied from elp.el. Was elp-elapsed-time.
+Argument START and END bound the time being calculated."
+ (+ (* (- (car end) (car start)) 65536.0)
+ (- (car (cdr end)) (car (cdr start)))
+ (/ (- (car (cdr (cdr end))) (car (cdr (cdr start)))) 1000000.0)))
+
+(defun cedet-utest-log-shutdown (title &optional errorcondition)
+ "Shut-down a larger test suite.
+TITLE is the section that is done.
+ERRORCONDITION is some error that may have occured durinig testing."
+ (let ((endtime (current-time))
+ )
+ (cedet-utest-log-shutdown-msg title cedet-utest-log-timer endtime)
+ (setq cedet-utest-log-timer nil)
+ ))
+
+(defun cedet-utest-log-shutdown-msg (title startime endtime)
+ "Show a shutdown message with TITLE, STARTIME, and ENDTIME."
+ (if (cedet-utest-noninteractive)
+ (progn
+ (message "\n>> Test Suite %s ended at @ %s"
+ title
+ (format-time-string "%c" endtime))
+ (message " Elapsed Time %.2f Seconds\n"
+ (cedet-utest-elapsed-time startime endtime)))
+
+ (save-excursion
+ (set-buffer cedet-utest-buffer)
+ (goto-char (point-max))
+ (insert "\n>> Test Suite " title " ended at @ "
+ (format-time-string "%c" endtime) "\n"
+ " Elapsed Time "
+ (number-to-string
+ (cedet-utest-elapsed-time startime endtime))
+ " Seconds\n * "))
+ ))
+
+(defun cedet-utest-show-log-end ()
+ "Show the end of the current unit test log."
+ (unless (cedet-utest-noninteractive)
+ (let* ((cb (current-buffer))
+ (cf (selected-frame))
+ (bw (or (get-buffer-window cedet-utest-buffer t)
+ (get-buffer-window (switch-to-buffer cedet-utest-buffer) t)))
+ (lf (window-frame bw))
+ )
+ (select-frame lf)
+ (select-window bw)
+ (goto-char (point-max))
+ (select-frame cf)
+ (set-buffer cb)
+ )))
+
+(defun cedet-utest-post-command-hook ()
+ "Hook run after the current log command was run."
+ (if (cedet-utest-noninteractive)
+ (message "")
+ (save-excursion
+ (set-buffer cedet-utest-buffer)
+ (goto-char (point-max))
+ (insert "\n\n")))
+ (setq cedet-utest-last-log-item nil)
+ (remove-hook 'post-command-hook 'cedet-utest-post-command-hook)
+ )
+
+(defun cedet-utest-add-log-item-start (item)
+ "Add ITEM into the log as being started."
+ (unless (equal item cedet-utest-last-log-item)
+ (setq cedet-utest-last-log-item item)
+ ;; This next line makes sure we clear out status during logging.
+ (add-hook 'post-command-hook 'cedet-utest-post-command-hook)
+
+ (if (cedet-utest-noninteractive)
+ (message " - Running %s ..." item)
+ (save-excursion
+ (set-buffer cedet-utest-buffer)
+ (goto-char (point-max))
+ (when (not (bolp)) (insert "\n"))
+ (insert "Running " item " ... ")
+ (sit-for 0)
+ ))
+ (cedet-utest-show-log-end)
+ ))
+
+(defun cedet-utest-add-log-item-done (&optional notes err precr)
+ "Add into the log that the last item is done.
+Apply NOTES to the doneness of the log.
+Apply ERR if there was an error in previous item.
+Optional argument PRECR indicates to prefix the done msg w/ a newline."
+ (if (cedet-utest-noninteractive)
+ ;; Non-interactive-mode - show a message.
+ (if notes
+ (message " * %s {%s}" (or err "done") notes)
+ (message " * %s" (or err "done")))
+ ;; Interactive-mode - insert into the buffer.
+ (save-excursion
+ (set-buffer cedet-utest-buffer)
+ (goto-char (point-max))
+ (when precr (insert "\n"))
+ (if err
+ (insert err)
+ (insert "done")
+ (when notes (insert " (" notes ")")))
+ (insert "\n")
+ (setq cedet-utest-last-log-item nil)
+ (sit-for 0)
+ )))
+
+;;; INDIVIDUAL TEST API
+;;
+;; Use these APIs to start and log information.
+;;
+;; The other fcns will be used to log across all the tests at once.
+(defun cedet-utest-log-start (testname)
+ "Setup the log for the test TESTNAME."
+ ;; Make sure we have a log buffer.
+ (save-window-excursion
+ (when (or (not cedet-utest-buffer)
+ (not (buffer-live-p cedet-utest-buffer))
+ (not (get-buffer-window cedet-utest-buffer t))
+ )
+ (cedet-utest-log-setup))
+ ;; Add our startup message.
+ (cedet-utest-add-log-item-start testname)
+ ))
+
+(defun cedet-utest-log(format &rest args)
+ "Log the text string FORMAT.
+The rest of the ARGS are used to fill in FORMAT with `format'."
+ (if (cedet-utest-noninteractive)
+ (apply 'message format args)
+ (save-excursion
+ (set-buffer cedet-utest-buffer)
+ (goto-char (point-max))
+ (when (not (bolp)) (insert "\n"))
+ (insert (apply 'format format args))
+ (insert "\n")
+ (sit-for 0)
+ ))
+ (cedet-utest-show-log-end)
+ )
+
+(provide 'cedet-uutil)
+
+;;; utest-util.el ends here
- [Emacs-diffs] scratch/merge-cedet-tests ede9f83 214/316: Simplify alias referencing and add tests., (continued)
- [Emacs-diffs] scratch/merge-cedet-tests ede9f83 214/316: Simplify alias referencing and add tests., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests da4dd24 253/316: New test for testing ede/cpp-root projects., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests b0da906 144/316: New unit test for EDE project detection., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests ef840da 159/316: compdb: add project detection tests, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests fba6409 297/316: Add test for parsing local variables, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests 658ff90 205/316: (cedet-utest): Add EDE sanity check to the end., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests 99ad7b6 206/316: Added security test, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests 8989dc6 313/316: New Tests for ede-java-root-project type., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests e145e4d 088/316: ("Lisp"): Add cit-cpp, cit-el, cit-texi, cit-load, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests aa72e43 200/316: Fix unit testing for several tests and do better error checking., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests b85662e 218/316: New file, derived from logging functions in cedet-utest.el,
Edward John Steere <=
- [Emacs-diffs] scratch/merge-cedet-tests 9cac087 281/316: Remove obsolete cvs-auto-updated 'X-RCS' line., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests ad45c79 263/316: Remove obsolete cvs-auto-updated 'X-RCS' line., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests 784b5c8 231/316: Make unit tests use randomized file names, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests 41c7498 284/316: Better skip message, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests 9480090 261/316: Test updating the project version, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests c89acc2 305/316: Add test code for use with sources in globalref, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests a9cd804 265/316: New tests., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests c132878 122/316: Make unit tests use randomized file names, Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests bfed386 181/316: (cit-finish-message): Add a pause, then exit with a status of "1"., Edward John Steere, 2017/01/27
- [Emacs-diffs] scratch/merge-cedet-tests ba748b5 174/316: Added gnustep tests, Edward John Steere, 2017/01/27