]> git.eshelyaron.com Git - emacs.git/commitdiff
Validate project overrides
authorEric Ludlam <zappo@gnu.org>
Thu, 28 Mar 2013 02:25:00 +0000 (22:25 -0400)
committerEdward John Steere <edward.steere@gmail.com>
Wed, 25 Jan 2017 15:48:36 +0000 (17:48 +0200)
* test/manual/cedet/cit-srec.el: (cit-srecode-map-test): Expand tests
 to validate that project settings correctly override system level
 templates.

test/manual/cedet/cit-srec.el

index 40492d7272f347c8000b9672649fb8fc390deea6..71267a8ffb180cc33b54c9b6050a22f962c09126 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cit-srec.el --- Test SRecode template mapping and such.
 
-;; Copyright (C) 2008 Eric M. Ludlam
+;; Copyright (C) 2008, 2013 Eric M. Ludlam
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -30,7 +30,8 @@
   (interactive)
 
   (let ((extradir cit-src-dir)
-       (oldpath srecode-map-load-path))
+       (oldpath srecode-map-load-path)
+       (tmpbuff (get-buffer-create "proj-test")))
     (add-to-list 'srecode-map-load-path extradir)
     (srecode-map-update-map t)
 
     (srecode-load-tables-for-mode 'c++-mode 'cit-test)
 
     (unwind-protect
-       (when (not (srecode-template-get-table (srecode-table 'c++-mode)
-                                              "cit-test-template"
-                                              "test"
-                                              'cit-test
-                                              ))
-         (error "Failed to find augmented template"))
+       (let (tmpl1 tmpl2)
+         ;; Test that a new template was detected
+         (when (not (srecode-template-get-table (srecode-table 'c++-mode)
+                                                "cit-test-template"
+                                                "test"
+                                                'cit-test
+                                                ))
+           (error "Failed to find augmented template"))
+
+         ;; Test the project distinction template.
+         (save-excursion
+           (set-buffer tmpbuff)
+
+           ;; Ok, this restricts us to testing on unix...
+           (setq default-directory "/usr/local")
+           (setq tmpl1 (srecode-template-get-table (srecode-table 'c++-mode)
+                                                   "cit-project-template"
+                                                   "test"
+                                                   'cit-test
+                                                   ))
+
+           (setq default-directory "/tmp/test")
+           (setq tmpl2 (srecode-template-get-table (srecode-table 'c++-mode)
+                                                   "cit-project-template"
+                                                   "test"
+                                                   'cit-test
+                                                   ))
+
+           (when (eq tmpl1 tmpl2)
+             (error "Failed to differentiate between Project and Non-Project templates"))
+
+           (when (not (string= (nth 1 (oref tmpl1 :code))
+                               "THIS IS NOT IN A PROJECT"))
+             (error "Failed to get the correct text for non-project template."))
+
+           (when (not (string= (nth 1 (oref tmpl2 :code))
+                               "THIS FILE IS IN /tmp"))
+             (error "Failed to get the correct text for-project template."))
+           ))
 
       ;; Get rid of our adaptation.  Double check.
       (setq srecode-map-load-path oldpath)