From ab505859b64749115169ca58dbb942adb39fd38d Mon Sep 17 00:00:00 2001
From: Matthew Flatt <mflatt@racket-lang.org>
Date: Tue, 25 Apr 2017 09:58:40 -0600
Subject: [PATCH] add a test for use by distribution builds

---
 gui-lib/racket/gui/private/distro-test.rkt | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 gui-lib/racket/gui/private/distro-test.rkt

diff --git a/gui-lib/racket/gui/private/distro-test.rkt b/gui-lib/racket/gui/private/distro-test.rkt
new file mode 100644
index 00000000..cc606378
--- /dev/null
+++ b/gui-lib/racket/gui/private/distro-test.rkt
@@ -0,0 +1,28 @@
+#lang racket/base
+(require setup/dirs
+         racket/system)
+
+;; Sanity checks to run in an installer-building context to make sure
+;; that things bascially work. This test is in the "-lib" package,
+;; instead of the "-test" package, so that it's lightweight to run
+;; (without installing lots of other packages)
+
+(define bin-dir (find-gui-bin-dir))
+(define console-bin-dir (find-console-bin-dir))
+
+(define (try-exe p)
+  (printf "Trying ~a\n" p)
+  (let ([o (open-output-bytes)])
+    (parameterize ([current-output-port o])
+      (system* p "-e" "'hello"))
+    ;; For historical reasons, `gracket` still uses `scheme` printing
+    (unless (equal? #"hello\n" (get-output-bytes o))
+      (error "sanity check failed" p))))
+
+(try-exe (build-path console-bin-dir (if (eq? (system-type) 'windows)
+                                         "gracket-text.exe"
+                                         "gracket-text")))
+(unless (eq? (system-type) 'unix) ; may not have a GUI connection on Unix
+  (case (system-type)
+    [(windows) (try-exe (build-path bin-dir "GRacket.exe"))]
+    [(macosx) (try-exe (build-path console-bin-dir "gracket"))]))