[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/merge-cedet-tests c89acc2 305/316: Add test code f
From: |
Edward John Steere |
Subject: |
[Emacs-diffs] scratch/merge-cedet-tests c89acc2 305/316: Add test code for use with sources in globalref |
Date: |
Sat, 28 Jan 2017 09:10:13 +0000 (UTC) |
branch: scratch/merge-cedet-tests
commit c89acc276c480ce2da32d25adfcf16b4ea400712
Author: Eric Ludlam <address@hidden>
Commit: Edward John Steere <address@hidden>
Add test code for use with sources in globalref
* test/manual/cedet/cit-globalref.el: New test code for use with
sources in tests/integ_src/globalref. Makes sure GNU Global will
create tags database, jump to correct impl from a prototype, and
also checks how many buffers are opened along the way to make sure
the expected number are found.
---
test/manual/cedet/cit-globalref.el | 185 ++++++++++++++++++++++++++++++++++++
1 file changed, 185 insertions(+)
diff --git a/test/manual/cedet/cit-globalref.el
b/test/manual/cedet/cit-globalref.el
new file mode 100644
index 0000000..50d1b75
--- /dev/null
+++ b/test/manual/cedet/cit-globalref.el
@@ -0,0 +1,185 @@
+;;; cit-globalref.el --- Test GNU Global being used for finding references
+;;
+;; Copyright (C) 2013, 2014 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:
+;;
+;; Using srcs by Barry OReilly, test out GNU Global running against
+;; the src, then use the symref tool to find a deep tag (A::B::MyFcn)
+;; where the namespaces appear all over. Can we find the right symbol
+;; without loading all the crazy code?
+
+;;; Code:
+
+(defvar cit-integ-target-globalref
+ (expand-file-name "edeproj_ede_globalref" cedet-integ-base)
+ "Root of the EDE project integration tests for the ede/java-root project.")
+
+(defvar cit-integ-globalref-subdir "integ_src/globalref/"
+ "Directory of files to copy into the tmp project dir.")
+
+(defvar cit-integ-globalref-srcdir
+ (expand-file-name
+ cit-integ-globalref-subdir
+ (file-name-directory (locate-library "cit-globalref")))
+ "The source directory for the JAVA root sources.")
+
+
+
+(defun cit-globalref-test ()
+ "Test the use of GNU Global and minimal file loading."
+ ;; Make sure we can use GNU Global.
+ (if (not (cedet-gnu-global-version-check t))
+ (error "WARNING: Failed cedet-gnu-global-version-check "))
+
+ ;; Create directory for the project
+ (cit-make-dir cit-integ-target-globalref)
+
+ ;; Copy source files into the globalref directory
+ (condition-case nil
+ ;; Emacs 24.2
+ (copy-directory (file-name-as-directory cit-integ-globalref-srcdir)
cit-integ-target-globalref t t t)
+
+ ;; Emacs 23
+ (error
+ (copy-directory (file-name-as-directory cit-integ-globalref-srcdir)
cit-integ-target-globalref t t)))
+
+ ;; Create the ede-java-root-project class directly.
+ (ede-cpp-root-project
+ "TESTGLOBALREF"
+ :file (expand-file-name "README" cit-integ-target-globalref)
+ :include-path '( "/inc" )
+ )
+
+ ;; Bootstrap GNU Global in the test directory
+ (cedet-gnu-global-create/update-database
+ (file-name-as-directory cit-integ-target-globalref))
+
+ ;; Enable GNU Global Database
+ (semanticdb-enable-gnu-global-databases 'c-mode)
+ (semanticdb-enable-gnu-global-databases 'c++-mode)
+
+ ;; Setup file loading/logging in C files.
+ (add-hook 'c-mode-common-hook 'cit-globalref-cmode-hook)
+
+ ;; Hook into the system.
+ (find-file (cit-file-globalref "inc/Util.hh"))
+
+ ;; Quick check - basics working???
+ (when (not (member "inc/Util.hh" cit-globalref-file-log))
+ (error "Basic logging failed. Skipping globalref test."))
+
+ (setq cit-globalref-file-log nil) ;; Reset
+
+ ;; Do a generic semanticdb search for the symbol w/out prototypes.
+ (let ((ans (semanticdb-find-tags-by-name "myUtilFunc"))
+ )
+ (when (not (= (semanticdb-find-result-length ans) 1))
+ (error "Global should have returned only 1 tag for myUtilFunc"))
+ ;;(message "Answer: %S" (semanticdb-fast-strip-find-results ans))
+
+ (when (not (= (length cit-globalref-file-log) 1))
+ (error "Global should have only loaded 1 file for myUtilFunc"))
+
+ (setq cit-globalref-file-log nil) ;; Reset
+ (semantic-symref-cleanup-recent-buffers-fcn) ;; Simulate end of command
+ )
+
+ ;; Now do a full search for the impl with proto-impl toggle.
+ (goto-char (point-min))
+ (re-search-forward "myUtilFun")
+ (semantic-analyze-proto-impl-toggle)
+
+ (when (not (string= (buffer-name) "Util.cc"))
+ (message "Jumped to: [%S]" (buffer-name))
+ (error "proto-impl-toggle failed to find Util.cc"))
+
+ (message "Jump to myUtilFun success.")
+
+ ;; The only file it needed to find
+ (when (not (equal cit-globalref-file-log '("test/ManagerTest.cc"
"src/Manager.cc" "src/Util.cc")))
+ (message "Too many/wrong files searched, should have only found
src/Util.cc, test/ManagerTest.cc, and src/Manager.cc")
+ (error "Found %S" cit-globalref-file-log))
+
+ ;; Debug reporting.
+ (message "Files loaded in globalref test: %S"
+ cit-globalref-file-log)
+
+ (setq cit-globalref-file-log nil) ;; Reset
+ (semantic-symref-cleanup-recent-buffers-fcn) ;; Simulate end of command
+
+ ;; Now make sure some of the buffers weren't left hanging around.
+ (when (get-file-buffer "test/ManagerTest.cc")
+ (error "Buffer left open for test/ManagerTest.cc"))
+
+ ;;; Now Check for the impl for a symbol not in a namespace.
+ ;; Now do a full search for the impl with proto-impl toggle.
+ (find-file (cit-file-globalref "inc/Util.hh"))
+ (goto-char (point-min))
+ (re-search-forward "myUtilFuncNoNS")
+ (semantic-analyze-proto-impl-toggle)
+
+ (when (not (string= (buffer-name) "Util.cc"))
+ (message "Jumped to: [%S]" (buffer-name))
+ (error "proto-impl-toggle failed to find Util.cc"))
+
+ (message "Jump to myUtilFunNoNS success.")
+
+ ;; The only file it needed to find
+ (when (not (equal cit-globalref-file-log '("src/Util.cc")))
+ (message "Too many files searched, should have only found src/Util.cc")
+ (error "Found %S" cit-globalref-file-log))
+
+ ;; Debug reporting.
+ (message "Files loaded in globalref no NS test: %S"
+ cit-globalref-file-log)
+
+ (setq cit-globalref-file-log nil) ;; Reset
+ (semantic-symref-cleanup-recent-buffers-fcn) ;; Simulate end of command
+
+ ;; Now make sure some of the buffers weren't left hanging around.
+ (when (get-file-buffer "test/Util.cc")
+ (error "Buffer left open for test/Util.cc"))
+
+ )
+
+(defvar cit-globalref-file-log nil
+ "Log of all the C files pulled into Emacs.")
+
+(defun cit-globalref-cmode-hook ()
+ "Hook to run in C mode.
+Logs all the C files initailized in Emacs."
+ (let ((fname
+ (condition-case nil
+ (if (string-match cit-integ-target-globalref (buffer-file-name))
+ (file-relative-name (buffer-file-name)
+ (file-name-as-directory
+ cit-integ-target-globalref))
+ (buffer-file-name))
+ ;; Use condition case so I can debug from here.
+ (error (buffer-file-name)))))
+ (push fname cit-globalref-file-log)))
+
+(defun cit-file-globalref (filename)
+ "Return a testing filename.
+Append FILENAME to the target directory."
+ (expand-file-name filename cit-integ-target-globalref))
+
+(provide 'cit-globalref)
+
+;;; cit-globalref.el ends here
- [Emacs-diffs] scratch/merge-cedet-tests 1373a94 285/316: (cit-gnu-externaldb-test-one): Improve test for bad search result., (continued)
- [Emacs-diffs] scratch/merge-cedet-tests 1373a94 285/316: (cit-gnu-externaldb-test-one): Improve test for bad search result., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 816e083 151/316: (ede-detect-utest-project-list): Add test for generic VC type project. (ede-detect-utest): Add fake autoloader for VC. (ede-detect-utest-generic-vc-p): New., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests e9c9716 279/316: Fixes for external db tests, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests e0d3d7b 303/316: New tests., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests ec14f1c 315/316: Move tests in cedet/semantic, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests c2f09c4 182/316: (cedet-integ-test-proj): Add cit-remove-and-do-shared-lib., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 63dbe0c 276/316: Move tests in cedet/semantic, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 9480090 261/316: Test updating the project version, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests e78d9b8 201/316: Fix merge error in unit tests., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 8989dc6 313/316: New Tests for ede-java-root-project type., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests c89acc2 305/316: Add test code for use with sources in globalref,
Edward John Steere <=
- [Emacs-diffs] scratch/merge-cedet-tests 9b72617 282/316: Don't set :filename if it's already set, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 2448a55 268/316: Fix unit testing for several tests and do better error checking., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 6adc6be 266/316: Move tests in cedet/semantic, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 3cb2319 243/316: Added code for test tags, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 101da66 306/316: Don't scan other files because Util.cc is already in a buffer, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 3cc63e2 316/316: Remove tests and redundant resources not destined for merge, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests d8c1209 234/316: CPP integration support. Core bits copied originally from cedet-integ-test.el, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 82586cd 209/316: eieio: Move to obsolete and use the one that ships with Emacs, Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests e54714f 227/316: Add header comments and provide., Edward John Steere, 2017/01/28
- [Emacs-diffs] scratch/merge-cedet-tests 4730d02 197/316: Refactor tests, Edward John Steere, 2017/01/28