clucumber 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +4 -9
  3. data/lib/clucumber/clucumber-bootstrap.lisp +32 -0
  4. data/lib/clucumber/vendor/cl-interpol/alias.lisp +55 -0
  5. data/lib/clucumber/vendor/cl-interpol/cl-interpol.asd +56 -0
  6. data/lib/clucumber/vendor/cl-interpol/load.lisp +53 -0
  7. data/lib/clucumber/vendor/cl-interpol/packages.lisp +40 -0
  8. data/lib/clucumber/vendor/cl-interpol/read.lisp +716 -0
  9. data/lib/clucumber/vendor/cl-interpol/specials.lisp +113 -0
  10. data/lib/clucumber/vendor/cl-interpol/test/packages.lisp +34 -0
  11. data/lib/clucumber/vendor/cl-interpol/test/tests.lisp +128 -0
  12. data/lib/clucumber/vendor/cl-interpol/test.lisp +177 -0
  13. data/lib/clucumber/vendor/cl-interpol/test2.lisp +6254 -0
  14. data/lib/clucumber/vendor/cl-interpol/unicode.lisp +13912 -0
  15. data/lib/clucumber/vendor/cl-interpol/util.lisp +122 -0
  16. data/lib/clucumber/vendor/cl-ppcre/api.lisp +1262 -0
  17. data/lib/clucumber/vendor/cl-ppcre/charmap.lisp +152 -0
  18. data/lib/clucumber/vendor/cl-ppcre/charset.lisp +242 -0
  19. data/lib/clucumber/vendor/cl-ppcre/chartest.lisp +98 -0
  20. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-test.asd +34 -0
  21. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/packages.lisp +38 -0
  22. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/resolver.lisp +61 -0
  23. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode.asd +58 -0
  24. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre.asd +79 -0
  25. data/lib/clucumber/vendor/cl-ppcre/closures.lisp +471 -0
  26. data/lib/clucumber/vendor/cl-ppcre/convert.lisp +875 -0
  27. data/lib/clucumber/vendor/cl-ppcre/errors.lisp +84 -0
  28. data/lib/clucumber/vendor/cl-ppcre/lexer.lisp +737 -0
  29. data/lib/clucumber/vendor/cl-ppcre/lispworks-defsystem.lisp +57 -0
  30. data/lib/clucumber/vendor/cl-ppcre/load.lisp +67 -0
  31. data/lib/clucumber/vendor/cl-ppcre/optimize.lisp +578 -0
  32. data/lib/clucumber/vendor/cl-ppcre/packages.lisp +68 -0
  33. data/lib/clucumber/vendor/cl-ppcre/parser.lisp +319 -0
  34. data/lib/clucumber/vendor/cl-ppcre/ppcre-tests.lisp +269 -0
  35. data/lib/clucumber/vendor/cl-ppcre/regex-class-util.lisp +555 -0
  36. data/lib/clucumber/vendor/cl-ppcre/regex-class.lisp +259 -0
  37. data/lib/clucumber/vendor/cl-ppcre/repetition-closures.lisp +833 -0
  38. data/lib/clucumber/vendor/cl-ppcre/scanner.lisp +506 -0
  39. data/lib/clucumber/vendor/cl-ppcre/specials.lisp +172 -0
  40. data/lib/clucumber/vendor/cl-ppcre/test/packages.lisp +37 -0
  41. data/lib/clucumber/vendor/cl-ppcre/test/perl-tests.lisp +150 -0
  42. data/lib/clucumber/vendor/cl-ppcre/test/tests.lisp +159 -0
  43. data/lib/clucumber/vendor/cl-ppcre/test/unicode-tests.lisp +80 -0
  44. data/lib/clucumber/vendor/cl-ppcre/util.lisp +201 -0
  45. data/lib/clucumber/vendor/cl-unicode/alias.lisp +135 -0
  46. data/lib/clucumber/vendor/cl-unicode/api.lisp +412 -0
  47. data/lib/clucumber/vendor/cl-unicode/build/char-info.lisp +133 -0
  48. data/lib/clucumber/vendor/cl-unicode/build/dump.lisp +239 -0
  49. data/lib/clucumber/vendor/cl-unicode/build/read.lisp +280 -0
  50. data/lib/clucumber/vendor/cl-unicode/build/util.lisp +182 -0
  51. data/lib/clucumber/vendor/cl-unicode/cl-unicode.asd +90 -0
  52. data/lib/clucumber/vendor/cl-unicode/conditions.lisp +54 -0
  53. data/lib/clucumber/vendor/cl-unicode/derived.lisp +120 -0
  54. data/lib/clucumber/vendor/cl-unicode/hash-tables.lisp +20 -0
  55. data/lib/clucumber/vendor/cl-unicode/lists.lisp +10 -0
  56. data/lib/clucumber/vendor/cl-unicode/methods.lisp +15 -0
  57. data/lib/clucumber/vendor/cl-unicode/packages.lisp +76 -0
  58. data/lib/clucumber/vendor/cl-unicode/specials.lisp +135 -0
  59. data/lib/clucumber/vendor/cl-unicode/test/packages.lisp +34 -0
  60. data/lib/clucumber/vendor/cl-unicode/test/tests.lisp +150 -0
  61. data/lib/clucumber/vendor/cl-unicode/test-functions.lisp +94 -0
  62. data/lib/clucumber/vendor/cl-unicode/util.lisp +274 -0
  63. data/lib/clucumber/vendor/lift/compare/fiveam-tests.lisp +14 -0
  64. data/lib/clucumber/vendor/lift/compare/lift-tests.lisp +13 -0
  65. data/lib/clucumber/vendor/lift/compare/rt-tests.lisp +16 -0
  66. data/lib/clucumber/vendor/lift/compare/xlunit-tests.lisp +15 -0
  67. data/lib/clucumber/vendor/lift/dev/changes.lisp +61 -0
  68. data/lib/clucumber/vendor/lift/dev/config.lisp +354 -0
  69. data/lib/clucumber/vendor/lift/dev/copy-file.lisp +117 -0
  70. data/lib/clucumber/vendor/lift/dev/introspection.lisp +232 -0
  71. data/lib/clucumber/vendor/lift/dev/lift-interface.lisp +56 -0
  72. data/lib/clucumber/vendor/lift/dev/lift-notes.lisp +202 -0
  73. data/lib/clucumber/vendor/lift/dev/lift-randomized.lisp +45 -0
  74. data/lib/clucumber/vendor/lift/dev/lift.lisp +2383 -0
  75. data/lib/clucumber/vendor/lift/dev/macros.lisp +229 -0
  76. data/lib/clucumber/vendor/lift/dev/measuring.lisp +156 -0
  77. data/lib/clucumber/vendor/lift/dev/packages.lisp +161 -0
  78. data/lib/clucumber/vendor/lift/dev/port.lisp +151 -0
  79. data/lib/clucumber/vendor/lift/dev/prototypes.lisp +282 -0
  80. data/lib/clucumber/vendor/lift/dev/random-testing.lisp +124 -0
  81. data/lib/clucumber/vendor/lift/dev/report-locations.lisp +13 -0
  82. data/lib/clucumber/vendor/lift/dev/reports.lisp +916 -0
  83. data/lib/clucumber/vendor/lift/dev/utilities.lisp +242 -0
  84. data/lib/clucumber/vendor/lift/docs/package.lisp +6 -0
  85. data/lib/clucumber/vendor/lift/docs/setup.lisp +17 -0
  86. data/lib/clucumber/vendor/lift/examples/basic-examples.lisp +289 -0
  87. data/lib/clucumber/vendor/lift/examples/random-testing.lisp +32 -0
  88. data/lib/clucumber/vendor/lift/lift-documentation.asd +28 -0
  89. data/lib/clucumber/vendor/lift/lift-test.asd +35 -0
  90. data/lib/clucumber/vendor/lift/lift.asd +77 -0
  91. data/lib/clucumber/vendor/lift/test/equality-tests.lisp +40 -0
  92. data/lib/clucumber/vendor/lift/test/finding-tests.lisp +32 -0
  93. data/lib/clucumber/vendor/lift/test/lift-test.lisp +783 -0
  94. data/lib/clucumber/vendor/lift/test/order-of-operations.lisp +54 -0
  95. data/lib/clucumber/vendor/lift/test/packages.lisp +17 -0
  96. data/lib/clucumber/vendor/lift/test/test-config-files.lisp +20 -0
  97. data/lib/clucumber/vendor/lift/test/test-dynamic-variables.lisp +57 -0
  98. data/lib/clucumber/vendor/lift/test/test-maximum-problems.lisp +74 -0
  99. data/lib/clucumber/vendor/lift/test/test-prototypes.lisp +278 -0
  100. data/lib/clucumber/vendor/lift/test/test-timeout.lisp +37 -0
  101. data/lib/clucumber/vendor/lift/test/tests-in-progress.lisp +62 -0
  102. data/lib/clucumber/vendor/lift/test/testsuite-expects.lisp +60 -0
  103. data/lib/clucumber/vendor/lift/timeout/package.lisp +13 -0
  104. data/lib/clucumber/vendor/lift/timeout/with-timeout.lisp +123 -0
  105. data/lib/clucumber/vendor/lift/website/stuff/Temp.lisp +34 -0
  106. data/lib/clucumber/vendor/st-json/st-json.asd +3 -0
  107. data/lib/clucumber/vendor/st-json/st-json.lisp +310 -0
  108. data/lib/clucumber/vendor/trivial-backtrace/dev/backtrace.lisp +127 -0
  109. data/lib/clucumber/vendor/trivial-backtrace/dev/fallback.lisp +10 -0
  110. data/lib/clucumber/vendor/trivial-backtrace/dev/map-backtrace.lisp +103 -0
  111. data/lib/clucumber/vendor/trivial-backtrace/dev/mucking.lisp +75 -0
  112. data/lib/clucumber/vendor/trivial-backtrace/dev/packages.lisp +13 -0
  113. data/lib/clucumber/vendor/trivial-backtrace/dev/utilities.lisp +104 -0
  114. data/lib/clucumber/vendor/trivial-backtrace/test/packages.lisp +5 -0
  115. data/lib/clucumber/vendor/trivial-backtrace/test/test-setup.lisp +4 -0
  116. data/lib/clucumber/vendor/trivial-backtrace/test/tests.lisp +16 -0
  117. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace-test.asd +22 -0
  118. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace.asd +35 -0
  119. data/lib/clucumber/vendor/usocket/backend/allegro.lisp +199 -0
  120. data/lib/clucumber/vendor/usocket/backend/armedbear.lisp +491 -0
  121. data/lib/clucumber/vendor/usocket/backend/clisp.lisp +260 -0
  122. data/lib/clucumber/vendor/usocket/backend/cmucl.lisp +266 -0
  123. data/lib/clucumber/vendor/usocket/backend/lispworks.lisp +741 -0
  124. data/lib/clucumber/vendor/usocket/backend/mcl.lisp +369 -0
  125. data/lib/clucumber/vendor/usocket/backend/openmcl.lisp +206 -0
  126. data/lib/clucumber/vendor/usocket/backend/sbcl.lisp +424 -0
  127. data/lib/clucumber/vendor/usocket/backend/scl.lisp +261 -0
  128. data/lib/clucumber/vendor/usocket/condition.lisp +227 -0
  129. data/lib/clucumber/vendor/usocket/package.lisp +82 -0
  130. data/lib/clucumber/vendor/usocket/server.lisp +45 -0
  131. data/lib/clucumber/vendor/usocket/test/package.lisp +13 -0
  132. data/lib/clucumber/vendor/usocket/test/test-usocket.lisp +166 -0
  133. data/lib/clucumber/vendor/usocket/usocket-test.asd +26 -0
  134. data/lib/clucumber/vendor/usocket/usocket.asd +37 -0
  135. data/lib/clucumber/vendor/usocket/usocket.lisp +542 -0
  136. data/lib/clucumber/vendor/usocket/vendor/kqueue.lisp +1 -0
  137. data/lib/clucumber/vendor/usocket/vendor/split-sequence.lisp +245 -0
  138. data/lib/clucumber.rb +29 -7
  139. metadata +151 -5
@@ -0,0 +1,103 @@
1
+ (in-package #:trivial-backtrace)
2
+
3
+ (defstruct frame
4
+ func
5
+ source-filename
6
+ source-pos
7
+ vars)
8
+
9
+ (defstruct var
10
+ name
11
+ value)
12
+
13
+ (defstruct pos-form-number
14
+ number)
15
+
16
+ (defmethod print-object ((pos-form-number pos-form-number) stream)
17
+ (cond
18
+ (*print-readably* (call-next-method))
19
+ (t
20
+ (format stream "f~A" (pos-form-number-number pos-form-number)))))
21
+
22
+
23
+ (defvar *trivial-backtrace-frame-print-specials*
24
+ '((*print-length* . 100)
25
+ (*print-level* . 20)
26
+ (*print-lines* . 5)
27
+ (*print-pretty* . t)
28
+ (*print-readably* . nil)))
29
+
30
+ (defun print-frame (frame stream)
31
+ (format stream "~A:~@[~A:~] ~A: ~%"
32
+ (or (ignore-errors (translate-logical-pathname (frame-source-filename frame))) (frame-source-filename frame) "<unknown>")
33
+ (frame-source-pos frame)
34
+ (frame-func frame))
35
+ (loop for var in (frame-vars frame)
36
+ do
37
+ (format stream " ~A = ~A~%" (var-name var)
38
+ (or (ignore-errors
39
+ (progv
40
+ (mapcar #'car *trivial-backtrace-frame-print-specials*)
41
+ (mapcar #'cdr *trivial-backtrace-frame-print-specials*)
42
+ (prin1-to-string
43
+ (var-value var))))
44
+ "<error>"))))
45
+
46
+ (defun map-backtrace (function)
47
+ (impl-map-backtrace function))
48
+
49
+ (defun print-map-backtrace (&optional (stream *debug-io*) &rest args)
50
+ (apply 'map-backtrace
51
+ (lambda (frame)
52
+ (print-frame frame stream)) args))
53
+
54
+ (defun backtrace-string (&rest args)
55
+ (with-output-to-string (stream)
56
+ (apply 'print-map-backtrace stream args)))
57
+
58
+
59
+ #+ccl
60
+ (defun impl-map-backtrace (func)
61
+ (ccl::map-call-frames (lambda (ptr)
62
+ (multiple-value-bind (lfun pc)
63
+ (ccl::cfp-lfun ptr)
64
+ (let ((source-note (ccl:function-source-note lfun)))
65
+ (funcall func
66
+ (make-frame :func (ccl::lfun-name lfun)
67
+ :source-filename (ccl:source-note-filename source-note)
68
+ :source-pos (let ((form-number (ccl:source-note-start-pos source-note)))
69
+ (when form-number (make-pos-form-number :number form-number)))
70
+ :vars (loop for (name . value) in (ccl::arguments-and-locals nil ptr lfun pc)
71
+ collect (make-var :name name :value value)))))))))
72
+
73
+ #+sbcl
74
+ (defun impl-map-backtrace (func)
75
+ (loop for f = (or sb-debug:*stack-top-hint* (sb-di:top-frame)) then (sb-di:frame-down f)
76
+ while f
77
+ do (funcall func
78
+ (make-frame :func
79
+ (ignore-errors
80
+ (sb-di:debug-fun-name
81
+ (sb-di:frame-debug-fun f)))
82
+ :source-filename
83
+ (ignore-errors
84
+ (sb-di:debug-source-namestring (sb-di:code-location-debug-source (sb-di:frame-code-location f))))
85
+ :source-pos
86
+ (ignore-errors ;;; XXX does not work
87
+ (let ((cloc (sb-di:frame-code-location f)))
88
+ (unless (sb-di:code-location-unknown-p cloc)
89
+ (format nil "tlf~Dfn~D"
90
+ (sb-di:code-location-toplevel-form-offset cloc)
91
+ (sb-di:code-location-form-number cloc)))))
92
+ :vars
93
+ (remove-if 'not
94
+ (map 'list (lambda(v)
95
+ (ignore-errors
96
+ (when (eq :valid
97
+ (sb-di:debug-var-validity v (sb-di:frame-code-location f)))
98
+ (make-var :name (sb-di:debug-var-symbol v)
99
+ :value (sb-di:debug-var-value v f)))))
100
+ (ignore-errors (sb-di::debug-fun-debug-vars (sb-di:frame-debug-fun f)))))))))
101
+
102
+
103
+
@@ -0,0 +1,75 @@
1
+ (in-package #:metabang.gsn)
2
+
3
+ #|
4
+ Need to account for different kinds of links
5
+ in gsn-nodes-from-json, need to return pairs of node and attributes
6
+
7
+ hash-table for nodes to prevent duplicates
8
+ queue or stack for nodes to expand
9
+ hash-table for links (triples of A link B?) to handle duplicates
10
+ |#
11
+
12
+ (defgeneric expand-node (context node)
13
+ )
14
+
15
+ (defgeneric find-neighbors (context node)
16
+ )
17
+
18
+ (defgeneric expand-node-p (context node)
19
+ )
20
+
21
+ (defgeneric add-node (context node)
22
+ )
23
+
24
+ (defgeneric add-link (context node neighbor direction)
25
+ )
26
+
27
+ (defgeneric update-node-data (context node data)
28
+ )
29
+
30
+ (defclass abstract-context ()
31
+ ())
32
+
33
+ (defclass gsn-context (abstract-context)
34
+ ())
35
+
36
+ (defparameter +gsn-root+ "http://socialgraph.apis.google.com/")
37
+
38
+ (defmethod expand-node ((context abstract-context) node)
39
+ (bind (((to from) (find-neighbors context node)))
40
+ (dolist (neighbor to)
41
+ (add-node context neighbor)
42
+ (add-link context node neighbor :to))
43
+ (dolist (neighbor from)
44
+ (add-node context neighbor)
45
+ (add-link context node neighbor :from))))
46
+
47
+
48
+
49
+ (defmethod find-neighbors ((context gsn-context) node)
50
+ (bind (((result headers stream)
51
+ (http-get
52
+ (format nil "~alookup?edo=1&edi=1&pretty=1&q=~a"
53
+ +gsn-root+ node)))
54
+ json)
55
+ (unwind-protect
56
+ (setf json (json:decode-json stream))
57
+ (close strea))
58
+ (update-node-data context node json)
59
+ (list (gsn-nodes-from-json json :to)
60
+ (gsn-nodes-from-json json :from))))
61
+
62
+ (gsn-nodes-from-json x :from)
63
+
64
+ (defun gsn-test (who)
65
+ (destructuring-bind (result headers stream)
66
+ (http-get
67
+ (format nil "http://socialgraph.apis.google.com/lookup?edo=1&edi=1&pretty=1&q=~a" who))
68
+ (declare (ignore result headers))
69
+ (json:decode-json stream)))
70
+
71
+ (assoc :nodes_referenced
72
+ (assoc :nodes (gsn-test "TWITTER.COM/GWKING") :key #'first))
73
+
74
+
75
+ (setf x (gsn-test "TWITTER.COM/GWKING"))
@@ -0,0 +1,13 @@
1
+ (in-package #:common-lisp-user)
2
+
3
+ (defpackage #:trivial-backtrace
4
+ (:use #:common-lisp)
5
+ (:export #:print-backtrace
6
+ #:print-backtrace-to-stream
7
+ #:print-condition
8
+ #:*date-time-format*
9
+
10
+
11
+ #:backtrace-string
12
+ #:map-backtrace))
13
+
@@ -0,0 +1,104 @@
1
+ (in-package #:trivial-backtrace)
2
+
3
+ (defparameter *date-time-format* "%Y-%m-%d-%H:%M"
4
+ "The default format to use when printing dates and times.
5
+
6
+ * %% - A '%' character
7
+ * %d - Day of the month as a decimal number [01-31]
8
+ * %e - Same as %d but does not print the leading 0 for days 1 through 9
9
+ [unlike strftime[], does not print a leading space]
10
+ * %H - Hour based on a 24-hour clock as a decimal number [00-23]
11
+ *%I - Hour based on a 12-hour clock as a decimal number [01-12]
12
+ * %m - Month as a decimal number [01-12]
13
+ * %M - Minute as a decimal number [00-59]
14
+ * %S - Second as a decimal number [00-59]
15
+ * %w - Weekday as a decimal number [0-6], where Sunday is 0
16
+ * %y - Year without century [00-99]
17
+ * %Y - Year with century [such as 1990]
18
+
19
+ This code is borrowed from the `format-date` function in
20
+ [metatilities-base][].")
21
+
22
+ ;; modified from metatilities-base
23
+ (eval-when (:compile-toplevel :load-toplevel :execute)
24
+ (defmacro generate-time-part-function (part-name position)
25
+ (let ((function-name
26
+ (intern
27
+ (concatenate 'string
28
+ (symbol-name 'time) "-" (symbol-name part-name))
29
+ :trivial-backtrace)))
30
+ `(eval-when (:compile-toplevel :load-toplevel :execute)
31
+ (defun ,function-name
32
+ (&optional (universal-time (get-universal-time))
33
+ (time-zone nil))
34
+ ,(format nil "Returns the ~(~A~) part of the given time." part-name)
35
+ (nth-value ,position
36
+ (apply #'decode-universal-time
37
+ universal-time time-zone))))))
38
+
39
+ (generate-time-part-function second 0)
40
+ (generate-time-part-function minute 1)
41
+ (generate-time-part-function hour 2)
42
+ (generate-time-part-function date 3)
43
+ (generate-time-part-function month 4)
44
+ (generate-time-part-function year 5)
45
+ (generate-time-part-function day-of-week 6)
46
+ (generate-time-part-function daylight-savings-time-p 7))
47
+
48
+ (defun date-time-string (&key (date/time (get-universal-time))
49
+ (format *date-time-format*))
50
+ (format-date format date/time nil))
51
+
52
+ (defun format-date (format date &optional stream time-zone)
53
+ (declare (ignore time-zone))
54
+ (let ((format-length (length format)))
55
+ (format
56
+ stream "~{~A~}"
57
+ (loop for index = 0 then (1+ index)
58
+ while (< index format-length) collect
59
+ (let ((char (aref format index)))
60
+ (cond
61
+ ((char= #\% char)
62
+ (setf char (aref format (incf index)))
63
+ (cond
64
+ ;; %% - A '%' character
65
+ ((char= char #\%) #\%)
66
+
67
+ ;; %d - Day of the month as a decimal number [01-31]
68
+ ((char= char #\d) (format nil "~2,'0D" (time-date date)))
69
+
70
+ ;; %e - Same as %d but does not print the leading 0 for
71
+ ;; days 1 through 9. Unlike strftime, does not print a
72
+ ;; leading space
73
+ ((char= char #\e) (format nil "~D" (time-date date)))
74
+
75
+ ;; %H - Hour based on a 24-hour clock as a decimal number [00-23]
76
+ ((char= char #\H) (format nil "~2,'0D" (time-hour date)))
77
+
78
+ ;; %I - Hour based on a 12-hour clock as a decimal number [01-12]
79
+ ((char= char #\I) (format nil "~2,'0D"
80
+ (1+ (mod (time-hour date) 12))))
81
+
82
+ ;; %m - Month as a decimal number [01-12]
83
+ ((char= char #\m) (format nil "~2,'0D" (time-month date)))
84
+
85
+ ;; %M - Minute as a decimal number [00-59]
86
+ ((char= char #\M) (format nil "~2,'0D" (time-minute date)))
87
+
88
+ ;; %S - Second as a decimal number [00-59]
89
+ ((char= char #\S) (format nil "~2,'0D" (time-second date)))
90
+
91
+ ;; %w - Weekday as a decimal number [0-6], where Sunday is 0
92
+ ((char= char #\w) (format nil "~D" (time-day-of-week date)))
93
+
94
+ ;; %y - Year without century [00-99]
95
+ ((char= char #\y)
96
+ (let ((year-string (format nil "~,2A" (time-year date))))
97
+ (subseq year-string (- (length year-string) 2))))
98
+
99
+ ;; %Y - Year with century [such as 1990]
100
+ ((char= char #\Y) (format nil "~D" (time-year date)))
101
+
102
+ (t
103
+ (error "Ouch - unknown formatter '%~c" char))))
104
+ (t char)))))))
@@ -0,0 +1,5 @@
1
+ (in-package #:common-lisp-user)
2
+
3
+ (defpackage #:trivial-backtrace-test
4
+ (:use #:common-lisp #:lift #:trivial-backtrace))
5
+
@@ -0,0 +1,4 @@
1
+ (in-package #:trivial-backtrace-test)
2
+
3
+ (deftestsuite trivial-backtrace-test ()
4
+ ())
@@ -0,0 +1,16 @@
1
+ (in-package #:trivial-backtrace-test)
2
+
3
+ (deftestsuite generates-backtrace (trivial-backtrace-test)
4
+ ())
5
+
6
+ (addtest (generates-backtrace)
7
+ test-1
8
+ (let ((output nil))
9
+ (handler-case
10
+ (let ((x 1))
11
+ (let ((y (- x (expt 1024 0))))
12
+ (/ 2 y)))
13
+ (error (c)
14
+ (setf output (print-backtrace c :output nil))))
15
+ (ensure (stringp output))
16
+ (ensure (plusp (length output)))))
@@ -0,0 +1,22 @@
1
+ (defpackage #:trivial-backtrace-test-system (:use #:asdf #:cl))
2
+ (in-package #:trivial-backtrace-test-system)
3
+
4
+ (defsystem trivial-backtrace-test
5
+ :author "Gary Warren King <gwking@metabang.com>"
6
+ :maintainer "Gary Warren King <gwking@metabang.com>"
7
+ :licence "MIT Style License; see file COPYING for details"
8
+ :components ((:module
9
+ "setup"
10
+ :pathname "test/"
11
+ :components ((:file "packages")
12
+ (:file "test-setup"
13
+ :depends-on ("packages"))))
14
+ (:module
15
+ "test"
16
+ :pathname "test/"
17
+ :depends-on ("setup")
18
+ :components ((:file "tests"))))
19
+ :depends-on (:lift :trivial-backtrace))
20
+
21
+
22
+
@@ -0,0 +1,35 @@
1
+ (in-package #:common-lisp-user)
2
+
3
+ (defpackage #:trivial-backtrace-system (:use #:asdf #:cl))
4
+ (in-package #:trivial-backtrace-system)
5
+
6
+ (defsystem trivial-backtrace
7
+ :version "1.0.2"
8
+ :author "Gary Warren King <gwking@metabang.com>"
9
+ :maintainer "Gary Warren King <gwking@metabang.com>"
10
+ :licence "MIT Style license "
11
+ :description "trivial-backtrace"
12
+ :depends-on ()
13
+ :components
14
+ ((:static-file "COPYING")
15
+ (:module
16
+ "setup"
17
+ :pathname "dev/"
18
+ :components ((:file "packages")))
19
+ (:module
20
+ "dev"
21
+ :depends-on ("setup")
22
+ :components ((:file "utilities")
23
+ (:file "backtrace")
24
+ (:file "map-backtrace")
25
+ (:file "fallback" :depends-on ("backtrace" "map-backtrace")))))
26
+ :in-order-to ((test-op (load-op trivial-backtrace-test)))
27
+ :perform (test-op :after (op c)
28
+ (funcall
29
+ (intern (symbol-name '#:run-tests) :lift)
30
+ :config :generic)))
31
+
32
+ (defmethod operation-done-p
33
+ ((o test-op)
34
+ (c (eql (find-system 'trivial-backtrace))))
35
+ (values nil))
@@ -0,0 +1,199 @@
1
+ ;;;; $Id: allegro.lisp 515 2010-01-07 18:26:06Z ctian $
2
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/backend/allegro.lisp $
3
+
4
+ ;;;; See LICENSE for licensing information.
5
+
6
+ (in-package :usocket)
7
+
8
+ (eval-when (:compile-toplevel :load-toplevel :execute)
9
+ (require :sock)
10
+ ;; for wait-for-input:
11
+ (require :process)
12
+ ;; note: the line below requires ACL 6.2+
13
+ (require :osi))
14
+
15
+ (defun get-host-name ()
16
+ ;; note: the line below requires ACL 7.0+ to actually *work* on windows
17
+ (excl.osi:gethostname))
18
+
19
+ (defparameter +allegro-identifier-error-map+
20
+ '((:address-in-use . address-in-use-error)
21
+ (:address-not-available . address-not-available-error)
22
+ (:network-down . network-down-error)
23
+ (:network-reset . network-reset-error)
24
+ (:network-unreachable . network-unreachable-error)
25
+ (:connection-aborted . connection-aborted-error)
26
+ (:connection-reset . connection-reset-error)
27
+ (:no-buffer-space . no-buffers-error)
28
+ (:shutdown . shutdown-error)
29
+ (:connection-timed-out . timeout-error)
30
+ (:connection-refused . connection-refused-error)
31
+ (:host-down . host-down-error)
32
+ (:host-unreachable . host-unreachable-error)))
33
+
34
+ (defun handle-condition (condition &optional (socket nil))
35
+ "Dispatch correct usocket condition."
36
+ (typecase condition
37
+ (excl:socket-error
38
+ (let ((usock-err
39
+ (cdr (assoc (excl:stream-error-identifier condition)
40
+ +allegro-identifier-error-map+))))
41
+ (if usock-err
42
+ (error usock-err :socket socket)
43
+ (error 'unknown-error
44
+ :real-error condition
45
+ :socket socket))))))
46
+
47
+ (defun to-format (element-type)
48
+ (if (subtypep element-type 'character)
49
+ :text
50
+ :binary))
51
+
52
+ (defun socket-connect (host port &key (protocol :stream) (element-type 'character)
53
+ timeout deadline
54
+ (nodelay t) ;; nodelay == t is the ACL default
55
+ local-host local-port)
56
+ (when timeout (unsupported 'timeout 'socket-connect))
57
+ (when deadline (unsupported 'deadline 'socket-connect))
58
+
59
+ (let ((socket))
60
+ (setf socket
61
+ (with-mapped-conditions (socket)
62
+ (ecase protocol
63
+ (:stream
64
+ (labels ((make-socket ()
65
+ (socket:make-socket :remote-host (host-to-hostname host)
66
+ :remote-port port
67
+ :local-host (when local-host
68
+ (host-to-hostname local-host))
69
+ :local-port local-port
70
+ :format (to-format element-type)
71
+ :nodelay nodelay)))
72
+ (if timeout
73
+ (mp:with-timeout (timeout nil)
74
+ (make-socket))
75
+ (make-socket))))
76
+ (:datagram
77
+ (apply #'socket:make-socket
78
+ (nconc (list :type protocol
79
+ :address-family :internet
80
+ :local-host (when local-host
81
+ (host-to-hostname local-host))
82
+ :local-port local-port
83
+ :format (to-format element-type))
84
+ (if (and host port)
85
+ (list :connect :active
86
+ :remote-host (host-to-hostname host)
87
+ :remote-port port)
88
+ (list :connect :passive))))))))
89
+ (ecase protocol
90
+ (:stream
91
+ (make-stream-socket :socket socket :stream socket))
92
+ (:datagram
93
+ (make-datagram-socket socket)))))
94
+
95
+ ;; One socket close method is sufficient,
96
+ ;; because socket-streams are also sockets.
97
+ (defmethod socket-close ((usocket usocket))
98
+ "Close socket."
99
+ (when (wait-list usocket)
100
+ (remove-waiter (wait-list usocket) usocket))
101
+ (with-mapped-conditions (usocket)
102
+ (close (socket usocket))))
103
+
104
+ (defun socket-listen (host port
105
+ &key reuseaddress
106
+ (reuse-address nil reuse-address-supplied-p)
107
+ (backlog 5)
108
+ (element-type 'character))
109
+ ;; Allegro and OpenMCL socket interfaces bear very strong resemblence
110
+ ;; whatever you change here, change it also for OpenMCL
111
+ (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
112
+ (sock (with-mapped-conditions ()
113
+ (apply #'socket:make-socket
114
+ (append (list :connect :passive
115
+ :reuse-address reuseaddress
116
+ :local-port port
117
+ :backlog backlog
118
+ :format (to-format element-type)
119
+ ;; allegro now ignores :format
120
+ )
121
+ (when (ip/= host *wildcard-host*)
122
+ (list :local-host host)))))))
123
+ (make-stream-server-socket sock :element-type element-type)))
124
+
125
+ (defmethod socket-accept ((socket stream-server-usocket) &key element-type)
126
+ (declare (ignore element-type)) ;; allegro streams are multivalent
127
+ (let ((stream-sock
128
+ (with-mapped-conditions (socket)
129
+ (socket:accept-connection (socket socket)))))
130
+ (make-stream-socket :socket stream-sock :stream stream-sock)))
131
+
132
+ (defmethod get-local-address ((usocket usocket))
133
+ (hbo-to-vector-quad (socket:local-host (socket usocket))))
134
+
135
+ (defmethod get-peer-address ((usocket stream-usocket))
136
+ (hbo-to-vector-quad (socket:remote-host (socket usocket))))
137
+
138
+ (defmethod get-local-port ((usocket usocket))
139
+ (socket:local-port (socket usocket)))
140
+
141
+ (defmethod get-peer-port ((usocket stream-usocket))
142
+ (socket:remote-port (socket usocket)))
143
+
144
+ (defmethod get-local-name ((usocket usocket))
145
+ (values (get-local-address usocket)
146
+ (get-local-port usocket)))
147
+
148
+ (defmethod get-peer-name ((usocket stream-usocket))
149
+ (values (get-peer-address usocket)
150
+ (get-peer-port usocket)))
151
+
152
+ (defmethod socket-send ((socket datagram-usocket) buffer length &key host port)
153
+ (with-mapped-conditions (socket)
154
+ (let ((s (socket socket)))
155
+ (socket:send-to s buffer length :remote-host host :remote-port port))))
156
+
157
+ (defmethod socket-receive ((socket datagram-usocket) buffer length &key)
158
+ (with-mapped-conditions (socket)
159
+ (let ((s (socket socket)))
160
+ (socket:receive-from s length :buffer buffer :extract t))))
161
+
162
+ (defun get-host-by-address (address)
163
+ (with-mapped-conditions ()
164
+ (socket:ipaddr-to-hostname (host-to-hbo address))))
165
+
166
+ (defun get-hosts-by-name (name)
167
+ ;;###FIXME: ACL has the acldns module which returns all A records
168
+ ;; only problem: it doesn't fall back to tcp (from udp) if the returned
169
+ ;; structure is too long.
170
+ (with-mapped-conditions ()
171
+ (list (hbo-to-vector-quad (socket:lookup-hostname
172
+ (host-to-hostname name))))))
173
+
174
+ (defun %setup-wait-list (wait-list)
175
+ (declare (ignore wait-list)))
176
+
177
+ (defun %add-waiter (wait-list waiter)
178
+ (push (socket waiter) (wait-list-%wait wait-list)))
179
+
180
+ (defun %remove-waiter (wait-list waiter)
181
+ (setf (wait-list-%wait wait-list)
182
+ (remove (socket waiter) (wait-list-%wait wait-list))))
183
+
184
+ (defun wait-for-input-internal (wait-list &key timeout)
185
+ (with-mapped-conditions ()
186
+ (let ((active-internal-sockets
187
+ (if timeout
188
+ (mp:wait-for-input-available (wait-list-%wait wait-list)
189
+ :timeout timeout)
190
+ (mp:wait-for-input-available (wait-list-%wait wait-list)))))
191
+ ;; this is quadratic, but hey, the active-internal-sockets
192
+ ;; list is very short and it's only quadratic in the length of that one.
193
+ ;; When I have more time I could recode it to something of linear
194
+ ;; complexity.
195
+ ;; [Same code is also used in openmcl.lisp]
196
+ (dolist (x active-internal-sockets)
197
+ (setf (state (gethash x (wait-list-map wait-list)))
198
+ :READ))
199
+ wait-list)))