gtk-screen: Implement make target "check".
authorMatt Birkholz <matt@birkholz.chandler.az.us>
Tue, 17 Sep 2013 00:30:20 +0000 (17:30 -0700)
committerMatt Birkholz <matt@birkholz.chandler.az.us>
Tue, 17 Sep 2013 00:30:20 +0000 (17:30 -0700)
src/TAGS
src/gtk-screen/Makefile
src/gtk-screen/check.scm [new file with mode: 0644]
src/gtk-screen/gtk-screen-check.scm [new file with mode: 0644]
src/gtk-screen/gtk-screen-optiondb.scm [new file with mode: 0644]
src/gtk-screen/gtk-screen.pkg

index bc04cc88373f128be285385ddfb1e49e8584419c..e0668593b9f1c08e4c01a0e000c0644f769bdb34 100644 (file)
--- a/src/TAGS
+++ b/src/TAGS
@@ -15,9 +15,4 @@ cref/TAGS,include
 \f
 rcs/TAGS,include
 \f
-<<<<<<< HEAD
-imail/TAGS,include
-\f
-=======
->>>>>>> e15962eff9573c3e57401773ef469d514789414e
 ffi/TAGS,include
index fc04e30bfcadf812a8382d14722630fa534b3a3a..aa601261e3275867cdbb1f43903480ccf91be253 100644 (file)
 # 02110-1301, USA.
 
 MIT_SCHEME_EXE = mit-scheme
-EXE = '$(MIT_SCHEME_EXE)' --batch-mode
+exe = '$(MIT_SCHEME_EXE)' --batch-mode
 
 all:
-       echo '(load "compile")' | $(EXE)
+       echo '(load "compile")' | $(exe)
        @if [ -s gtk-screen-unx.crf ]; then \
             echo "gtk-screen-unx.crf:0: warning: non-empty"; exit 1; fi
 
 check:
-       echo '(load "check")' | $(EXE)
+       echo '(load "check")' | $(exe)
 
 install:
-       echo '(install-shim)' | $(EXE) -- *.com *.bci *.pkd make.scm
+       echo '(install-load-option "gtk-screen")' \
+       | $(exe) -- *.com *.bci *.pkd make.scm
 
 clean distclean maintainer-clean:
        rm -f *.bin *.ext *.com *.bci *.moc *.fni *.crf *.fre *.pkd
diff --git a/src/gtk-screen/check.scm b/src/gtk-screen/check.scm
new file mode 100644 (file)
index 0000000..d93183a
--- /dev/null
@@ -0,0 +1,13 @@
+#| -*-Scheme-*- |#
+
+;;;; Test the gtk screen.
+
+(let ((env (->environment '(runtime pathname)))
+      (dirname (directory-pathname (current-load-pathname))))
+  (set! (access library-directory-path env)
+       (cons dirname (access library-directory-path env)))
+  (set! *initial-options-file* (merge-pathnames "gtk-screen-optiondb" dirname)))
+
+(load-option 'GTK-SCREEN)
+(if (gtk-thread-running?)
+    (load "gtk-screen-check"))
\ No newline at end of file
diff --git a/src/gtk-screen/gtk-screen-check.scm b/src/gtk-screen/gtk-screen-check.scm
new file mode 100644 (file)
index 0000000..2b4b52d
--- /dev/null
@@ -0,0 +1,91 @@
+#| -*-Scheme-*-
+
+Copyright (C) 2012, 2013  Matthew Birkholz
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme 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 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme 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 MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+|#
+
+;;;; Test the Gtk Screen
+
+(let ((dirname (directory-pathname (current-load-pathname)))
+      (ffi (->environment '(runtime ffi))))
+  (let ((registered-callback-count (access registered-callback-count ffi))
+       (malloced-aliens (named-lambda (malloced-aliens)
+                          (access malloced-aliens ffi))))
+
+    (define (run-test name thunk)
+      (let ((condition (ignore-errors thunk)))
+       (cond ((eq? condition #t)
+              (for-each display (list "; Test "name" succeeded.\n")))
+             ((condition? condition)
+              (for-each display (list "; Test "name" failed with error:\n"))
+              (write-condition-report condition (current-output-port))
+              (newline))
+             (else
+              (for-each display (list "; Test "name" returned "condition
+                                      ".\n"))))))
+
+    (define (assert = obj1 obj2 form)
+      (if (not (= obj1 obj2))
+         (error "Assertion failed:" form))
+      #t)
+
+    (define (await-closed-windows)
+      (gtk-time-slice-window! #t)
+      (spawn-edit)
+      (let loop ()
+       (sleep-current-thread 1000)
+       (if (not (null? (access toplevel-windows
+                               (->environment '(gtk gtk-widget)))))
+           (loop))))
+
+    (define (note* . args)
+      (with-notification
+       (lambda (port)
+        (for-each (lambda (o) (display o port)) args))
+       #f))
+
+    (define (spawn-edit)
+      (call-with-current-continuation
+       (lambda (continue)
+        (detach-thread
+         (create-thread continue
+           (lambda ()
+             (let ((self (current-thread)))
+               (note* "Edwin thread: "self)
+               (edit)
+               (note* "Edwin thread "self" finished.")
+               (stop-current-thread))))))))
+
+    (run-test 'gtk-screens
+      (lambda ()
+       (with-gc-notification! #t await-closed-windows)
+       (gc-flip)))
+
+    (run-test 'gtk-screens.callbacks
+      (lambda ()
+       (assert = (car (registered-callback-count))
+                 0
+                 '(REGISTERED-CALLBACK-COUNT))))
+
+    (run-test 'gtk-screens.mallocs
+      (lambda ()
+       (assert = (length (malloced-aliens))
+                 0
+                 '(LENGTH MALLOCED-ALIENS))))))
\ No newline at end of file
diff --git a/src/gtk-screen/gtk-screen-optiondb.scm b/src/gtk-screen/gtk-screen-optiondb.scm
new file mode 100644 (file)
index 0000000..0b31b29
--- /dev/null
@@ -0,0 +1,15 @@
+#| -*-Scheme-*- |#
+
+;;;; Test optiondb, includes the installed system's optiondb.
+
+(define-load-option 'GTK-SCREEN
+  (let ((pathname
+        (merge-pathnames "make"
+                         (directory-pathname (current-load-pathname)))))
+    (named-lambda (gtk-screen-option-loader)
+      (load pathname))))
+
+(further-load-options
+ (merge-pathnames "optiondb"
+                 (last (access library-directory-path
+                               (->environment '(runtime pathname))))))
\ No newline at end of file
index f9be66f5aa6e19a2b25e32e5c25d02cb5167ba52..6d66e36233686063a2b32464489d2f8e5087af70 100644 (file)
@@ -23,10 +23,10 @@ USA.
 
 ;;;; Gtk-Screen System Packaging
 
-(global-definitions "../runtime/runtime")
-(global-definitions "../sos/sos")
-(global-definitions "../gtk/gtk")
-(global-definitions "../edwin/edwin")
+(global-definitions runtime/)
+(global-definitions sos/)
+(global-definitions gtk/)
+(global-definitions edwin/)
 
 (define-package (edwin screen gtk-screen)
   (files "gtk-screen" "gtk-faces")