Commit abd5aea0 authored by Attila Lendvai's avatar Attila Lendvai
Browse files

clean up .asd

Ignore-this: e7a4a65a3643d29f99f7454caa101d14

don't reuse the same fasl path for completely different
contents, e.g. tests use symbols from fiveam that is
not even loaded with the main asdf system.

darcs-hash:f06b73438ca6a3962fb39355d9cd9a2a8d7af79f
parent 5f01c779
Loading
Loading
Loading
Loading
+31 −15
Original line number Diff line number Diff line
;-*- mode: lisp -*-
(in-package :cl-user)

(defpackage #:rfc2109-system
(cl:defpackage #:rfc2109-system
  (:use #:cl #:asdf))

(in-package #:rfc2109-system)
(cl:in-package #:rfc2109-system)

(defsystem "rfc2109"
  :depends-on (:split-sequence)
  :version "0.4"
  :components ((:file "rfc2109")))

;;;;;;
;;; The test system

;; It loads the same file with :test in *features*. We need to use a different
;; name for the fasl file to avoid clashes (different packages are needed to
;; load the two different systems/fasl files).

(defclass load-file-with-tests (cl-source-file)
  ())

(defmethod perform ((op load-op) (component load-file-with-tests))
(defmethod perform :around (op (component load-file-with-tests))
  (let ((*features* *features*))
    (push :test *features*)
    (perform (make-instance 'compile-op) component)
    (pushnew :test *features*)
    (call-next-method)))

(defsystem "rfc2109"
  :depends-on (:split-sequence)
  :version "0.4"
  :components
  ((:file "rfc2109")))
(defmethod output-files :around ((op compile-op) (c load-file-with-tests))
  (multiple-value-bind
        (files fixedp)
      (call-next-method)
    (values
     (loop
       :for file :in files
       :collect (make-pathname :name (concatenate 'string
                                                  (pathname-name file)
                                                  "-with-tests")
                               :defaults file))
     fixedp)))

(defsystem "rfc2109.test"
(defsystem "rfc2109/test"
  :depends-on (:split-sequence :fiveam)
  :components
  ((:load-file-with-tests "rfc2109")))
  :components ((:load-file-with-tests "rfc2109")))
+9 −11
Original line number Diff line number Diff line
@@ -65,9 +65,10 @@
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


(defpackage :rfc2109
  (:use :common-lisp)
(defpackage #+test :rfc2109/test
            #-test :rfc2109
  (:use :common-lisp
        #+test :it.bese.fiveam)
  (:export :cookie-string
	   :cookie-string-from-cookie-struct
	   :make-cookie :cookie-name :cookie-value :cookie-comment
@@ -78,11 +79,8 @@
  (:documentation "This package implements RFC2109 - the original cookie specification.
Use it to generate (and eventually parse) cookies in an RFC-compliant way."))

(in-package :rfc2109)

#+test(eval-when (:compile-toplevel :load-toplevel)
        (unintern 'rfc2109::test)
        (use-package (find-package :it.bese.fiveam)))
(in-package #+test :rfc2109/test
            #-test :rfc2109)

#+test(def-suite :rfc2109)
#+test(in-suite :rfc2109)
@@ -936,7 +934,7 @@ Cookie text:
#+test
(test cookie-value-with-equals-sign
  ;; this cookie apparently came back from an "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/532.4 (KHTML, like Gecko) rekonq Safari/532.4"
  ;; (rfc2109:parse-cookies "$Version=1; __utmz=112789265.1271340080.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=112789265.1789515954.1271340080.1271340080.1271340080.1; sid=OLgKAPmRjIeCVqYYIouvbEQQuHxXvfyIVlCXWFlV; $Path=\"/\"; $Domain=\".dwim.hu\"")
  ;; (parse-cookies "$Version=1; __utmz=112789265.1271340080.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=112789265.1789515954.1271340080.1271340080.1271340080.1; sid=OLgKAPmRjIeCVqYYIouvbEQQuHxXvfyIVlCXWFlV; $Path=\"/\"; $Domain=\".dwim.hu\"")
  ;; IOW, the value part contains #\= characters, so split-sequence:split can not be used here.
  (is (equal (cookie-value (first (parse-cookies "$Version=1; c1=v1=v1.1; c2=v2"))) "v1=v1.1")))

@@ -952,9 +950,9 @@ Cookie text:

#+test
(test cookie-domain
  (is (cookie-p (first (rfc2109:parse-cookies "$Version=1;keyyy=valueee;$Domain=.176.9.81.202;$Path=\"/\""))))
  (is (cookie-p (first (parse-cookies "$Version=1;keyyy=valueee;$Domain=.176.9.81.202;$Path=\"/\""))))
  (signals invalid-cookie-parameter
    (rfc2109:parse-cookies "$Version=1;keyyy=valueee;$Domain=.176.9.81.202<title>phpMyAdmin;$Path=\"/\"")))
    (parse-cookies "$Version=1;keyyy=valueee;$Domain=.176.9.81.202<title>phpMyAdmin;$Path=\"/\"")))

(defun parse-cookies (cookie-string)
  "Parses cookies in a Cookie: request header, returning a list of COOKIE structs.