/sandbox/old-src/test-generate-application.ss

https://github.com/jsjohnst/moby-scheme · Scheme · 166 lines · 126 code · 29 blank · 11 comment · 0 complexity · 65ade11a4d509af4cb504024a99ca734 MD5 · raw file

  1. #lang scheme/base
  2. (require "generate-application.ss"
  3. "config.ss"
  4. scheme/runtime-path)
  5. (define (start-up-debug-printing)
  6. (let ([receiver (make-log-receiver (current-logger)
  7. 'debug
  8. #;'info
  9. #;'error)])
  10. (thread (lambda ()
  11. (let loop ()
  12. (let ([v (sync receiver)])
  13. (display (vector-ref v 1))
  14. (newline))
  15. (loop))))
  16. receiver))
  17. (define receiver (start-up-debug-printing))
  18. ;; The regressing test programs live here:
  19. (define-runtime-path test-path "test")
  20. ;; Applications will be written to bin.
  21. (define-runtime-path test-app-j2me-path "bin/j2me")
  22. (define-runtime-path test-app-android-path "bin/android")
  23. (define-runtime-path test-app-js-path "bin/js")
  24. ;; make-test: string -> void
  25. ;; Builds the test application.
  26. (define (make-test filename)
  27. (lambda (generator where)
  28. (generator
  29. (regexp-replace #rx".(ss|scm)$" (format "~a" filename) "")
  30. (build-path test-path filename)
  31. (build-path where (regexp-replace #rx".(ss|scm)$" (format "~a" filename) "")))))
  32. ;; Here are a few small examples that exercise small portions of the compiler.
  33. (define test-falling-ball (make-test "falling-ball.ss"))
  34. (define test-falling-cow (make-test "falling-cow.ss"))
  35. (define test-falling-ball-posn (make-test "falling-ball-posn.ss"))
  36. (define test-falling-ball-pair (make-test "falling-ball-pair.ss"))
  37. (define test-pinholes (make-test "pinholes.ss"))
  38. (define test-rectangles (make-test "rectangles.ss"))
  39. (define test-hello-world (make-test "hello-world.ss"))
  40. (define test-approx-equal (make-test "approx-equal.ss"))
  41. (define test-struct-question (make-test "struct-question.ss"))
  42. (define test-move-ball (make-test "move-ball.ss"))
  43. (define test-image-question (make-test "image-question.ss"))
  44. (define test-location (make-test "location.ss"))
  45. (define test-location-2 (make-test "location-2.ss"))
  46. (define test-tilt (make-test "tilt.ss"))
  47. (define test-bubble (make-test "bubble.ss"))
  48. (define test-sketch (make-test "sketch.ss"))
  49. (define test-sketch-2 (make-test "sketch-2.ss"))
  50. (define test-upside-down (make-test "upside-down.ss"))
  51. (define test-bubble-2 (make-test "bubble-2.ss"))
  52. (define test-bubble-3 (make-test "bubble-3.ss"))
  53. (define test-sms (make-test "sms.ss"))
  54. (define test-homeward-bound (make-test "homeward-bound.ss"))
  55. (define test-homeward-bound-single (make-test "homeward-bound-single.ss"))
  56. (define test-net (make-test "net.ss"))
  57. (define test-get-ip-address (make-test "get-ip-address.ss"))
  58. (define test-parse-google-maps-places (make-test "parse-google-maps-places.ss"))
  59. (define test-grocery-shopper (make-test "grocery-shopper.ss"))
  60. (define test-local (make-test "local.ss"))
  61. (define test-gui-world-hello-world (make-test "gui-world-hello-world.ss"))
  62. (define test-gui-world-drop-down (make-test "gui-world-drop-down.ss"))
  63. (define test-gui-world-text-field (make-test "gui-world-text-field.ss"))
  64. (define test-gui-world-box-group (make-test "gui-world-box-group.ss"))
  65. (define test-gui-world-checkbox (make-test "gui-world-checkbox.ss"))
  66. (define test-gui-world-location (make-test "gui-world-location.ss"))
  67. (define test-simple-bootstrap-game (make-test "simple-bootstrap-game.ss"))
  68. ;; The programs here are the five programs of
  69. ;; How To Design Worlds (http://world.cs.brown.edu)
  70. (define test-cowabunga (make-test "cowabunga.ss"))
  71. (define test-flight-lander (make-test "flight-lander.ss"))
  72. (define test-chicken (make-test "chicken.ss"))
  73. (define test-fire-fighter (make-test "fire-fighter.ss"))
  74. (define test-spaceflight (make-test "spaceflight.ss"))
  75. ;; Exercises the application generator.
  76. (define (test-all g w)
  77. (for ([test (list test-hello-world
  78. test-falling-ball
  79. test-falling-cow
  80. test-falling-ball-posn
  81. test-falling-ball-pair
  82. test-pinholes
  83. test-rectangles
  84. test-approx-equal
  85. test-struct-question
  86. test-move-ball
  87. test-image-question
  88. test-local
  89. test-location
  90. test-location-2
  91. test-tilt
  92. test-bubble
  93. test-sketch
  94. test-sketch-2
  95. test-upside-down
  96. test-bubble-2
  97. test-bubble-3
  98. test-sms
  99. test-homeward-bound
  100. test-homeward-bound-single
  101. ;; Commented out: uses deprecated gui-world
  102. #;test-net
  103. #;test-get-ip-address
  104. #;test-parse-google-maps-places
  105. #;test-grocery-shopper
  106. #;test-gui-world-hello-world
  107. #;test-gui-world-drop-down
  108. #;test-gui-world-text-field
  109. #;test-gui-world-box-group
  110. #;test-gui-world-checkbox
  111. test-cowabunga
  112. test-flight-lander
  113. test-chicken
  114. test-fire-fighter
  115. test-spaceflight
  116. test-simple-bootstrap-game)])
  117. (test g w)))
  118. (define (run-all-tests #:android (with-android? #f)
  119. #:js (with-js? #t))
  120. (define should-run-android?
  121. (and (directory-exists? (current-android-sdk-path)) with-android?))
  122. ;; Compile with javascript backend.
  123. (when with-js?
  124. (test-all generate-javascript-application test-app-js-path))
  125. ;; If you do not have the Android SDK, change the value in config.ss.
  126. #;(when should-run-android?
  127. (test-all generate-javascript+android-phonegap-application test-app-android-path)))
  128. (define (run-single-test a-test
  129. #:android (with-android? #f)
  130. #:js (with-js? #t))
  131. (define should-run-android?
  132. (and (directory-exists? (current-android-sdk-path)) with-android?))
  133. (when with-js?
  134. (a-test generate-javascript-application test-app-js-path))
  135. #;(when should-run-android?
  136. (a-test generate-javascript+android-phonegap-application test-app-android-path)))
  137. (run-all-tests)