Skip to content

Commit

Permalink
New test suite for EDE project detection.
Browse files Browse the repository at this point in the history
Includes several directories of minimal projects of different types.
  • Loading branch information
Eric Ludlam committed Apr 20, 2014
2 parents 829a1e7 + 24b5991 commit f740351
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/cedet-utests.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; cedet-utests.el --- Run all unit tests in the CEDET suite.

;; Copyright (C) 2008, 2009, 2010, 2012, 2013 Eric M. Ludlam
;; Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014 Eric M. Ludlam

;; Author: Eric M. Ludlam <eric@siege-engine.com>

Expand Down Expand Up @@ -31,6 +31,7 @@
(require 'pulse-utest)
(require 'cedet-files-utests)
(require 'cedet-compat)
(require 'cedet/ede/detect-utest)
(require 'cedet/semantic/lex-utest)
(require 'cedet/semantic/lex-spp-utest)
(require 'cedet/semantic/utest-parse)
Expand Down Expand Up @@ -92,9 +93,7 @@
;;
;; EDE
;;

;; @todo - Currently handled in the integration tests. Need
;; some simpler unit tests here.
("ede: project detection tests" . ede-detect-utest)

;;
;; SEMANTIC
Expand Down
102 changes: 102 additions & 0 deletions tests/cedet/ede/detect-utest.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
;;; ede/detect.el --- Tests for detecting different kinds of projects.
;;
;; Copyright (C) 2014 Eric M. Ludlam
;;
;; Author: Eric M. Ludlam <eric@siege-engine.com>
;;
;; 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/.

;;; Code:

(require 'ede/linux)

(defvar ede-detect-utest-project-list
'(
( "src/proj/Project.ede" . ede-proj-project-p )
( "src/automake/Makefile.am" . project-am-makefile-p )
( "src/android/AndroidManifest.xml" . ede-android-project-p )
( "src/android/src/test.java" . ede-android-project-p )
( "src/emacs/Makefile" . ede-emacs-project-p )
( "src/emacs/src/emacs.c" . ede-emacs-project-p )
;( "src/ant/build.xml" . ede-ant-project-p )
( "src/linux/Makefile" . ede-linux-project-p )
( "src/linux/scripts/ver_linux" . ede-linux-project-p )
)
"List of sources to load in ndetectable projects.
Each entry is a cons cell:
( SRCFILE . PROJECT-TYPE )")

;;;###autoload
(defun ede-detect-utest ()
"Test out the detection scheme for EDE."
(interactive)
(save-excursion

(let ((errlog nil)
(project-linux-build-directory-default 'same)
(project-linux-architecture-default "glnx")
(ede-project-directories t) ; safe to load Project.ede
)
(cedet-utest-log-setup "EDE DETECT")

(set-buffer (semantic-find-file-noselect
(expand-file-name "cedet/ede/detect.el"
cedet-utest-root)))

(dolist (fl ede-detect-utest-project-list)

;; Make sure we have the files we think we have.
(when (not (file-exists-p (car fl)))
(error "Cannot find unit test file: %s" (car fl)))

;; Do the detection
(let ((fb (find-buffer-visiting (car fl)))
(b (semantic-find-file-noselect (car fl))))

(save-excursion
(set-buffer b)

;; Run the EDE detection code. Firing up the mode isn't really needed.
(ede-initialize-state-current-buffer)

;; Test the result.
(unless (funcall (cdr fl) ede-object-root-project)

(message "Found %S, wanted %S"
ede-object-root-project
(cdr fl))

(push fl errlog))
)

;; If it wasn't already in memory, whack it.
(when (and b (not fb))
(kill-buffer b))
))

(cedet-utest-log-shutdown
"EDE DETECT"
(when errlog
(format "%s Failures found." (length errlog))))

(when errlog
(error "Failures found looking for project in %s" (car (car errlog))))
))

)


(provide 'cedet/ede/detect-utest)

;;; detect.el ends here
12 changes: 12 additions & 0 deletions tests/cedet/ede/src/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.face.project"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/icon">

<activity android:name="ArduinoBot"/>

</application>
</manifest>

1 change: 1 addition & 0 deletions tests/cedet/ede/src/android/src/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Test Java File in a subdirectory */
1 change: 1 addition & 0 deletions tests/cedet/ede/src/automake/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test makefile.
1 change: 1 addition & 0 deletions tests/cedet/ede/src/emacs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test makefile.
2 changes: 2 additions & 0 deletions tests/cedet/ede/src/emacs/configure.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dnl Test configure for Emacs
AC_INIT(emacs, 1.0.0)
1 change: 1 addition & 0 deletions tests/cedet/ede/src/emacs/src/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* config for test */
1 change: 1 addition & 0 deletions tests/cedet/ede/src/emacs/src/emacs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Fake emacs.c for faking out EDE tests */
1 change: 1 addition & 0 deletions tests/cedet/ede/src/emacs/src/lisp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* lisp for test */
3 changes: 3 additions & 0 deletions tests/cedet/ede/src/linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VERSION = 1
PATCHLEVEL = 2
SUBLEVEL = 3
2 changes: 2 additions & 0 deletions tests/cedet/ede/src/linux/scripts/ver_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.0
# Fake linux marker
11 changes: 11 additions & 0 deletions tests/cedet/ede/src/proj/Project.ede
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
;; Object proj
;; EDE Project Files are auto generated: Do Not Edit
(ede-proj-project "proj"
:file "Project.ede"
:name "proj"
:targets
(list
(ede-proj-target-makefile-miscelaneous "misc"
:name "misc"
:path ""
:source '("TEST"))))
1 change: 1 addition & 0 deletions tests/cedet/ede/src/proj/TEST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TEST

0 comments on commit f740351

Please sign in to comment.