LCP: Small test fixes

Reviewers: mtomic, teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1947
This commit is contained in:
Lovro Lugovic 2019-03-23 20:44:01 +01:00
parent 9d6e025304
commit 390b6c1557
4 changed files with 36 additions and 10 deletions

View File

@ -11,7 +11,7 @@ set(lcp_src_files
${CMAKE_SOURCE_DIR}/src/lisp/slk.lisp
${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp
${CMAKE_SOURCE_DIR}/src/lisp/debug.lisp
${CMAKE_SOURCE_DIR}/src/lisp/lcp-test.lisp
${CMAKE_SOURCE_DIR}/src/lisp/test.lisp
${CMAKE_SOURCE_DIR}/tools/lcp)
add_custom_target(lcp
@ -59,8 +59,8 @@ macro(define_add_lcp name main_src_files generated_lcp_files)
${CMAKE_SOURCE_DIR}/src/lisp/code-gen.lisp
${CMAKE_SOURCE_DIR}/src/lisp/slk.lisp
${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp
${CMAKE_SOURCE_DIR}/src/lisp/lcp-test.lisp
${CMAKE_SOURCE_DIR}/src/lisp/debug.lisp
${CMAKE_SOURCE_DIR}/src/lisp/test.lisp
${CMAKE_SOURCE_DIR}/tools/lcp)
add_custom_command(OUTPUT ${h_file} ${cpp_file}
COMMAND ${CMAKE_SOURCE_DIR}/tools/lcp ${lcp_file} ${slk_serialize}

View File

@ -16,11 +16,11 @@
(defsystem "lcp/test"
:depends-on ("lcp" "prove")
:components ((:file "lcp-test"))
:components ((:file "test"))
:perform (test-op :after (op s)
(let ((*package* (find-package :lcp-test))
(let ((*package* (find-package :lcp.test))
(sym (find-symbol (string :*default-reporter*)
:prove)))
(progv (list sym) '(:fiveam)
(symbol-call :prove :plan nil)
(symbol-call :prove :run-test-package :lcp-test)))))
(symbol-call :prove :run-test-package :lcp.test)))))

View File

@ -1,9 +1,34 @@
(defpackage #:lcp-test
(defpackage #:lcp.test
(:use #:cl #:prove))
(in-package #:lcp-test)
(in-package #:lcp.test)
(named-readtables:in-readtable lcp:lcp-syntax)
;;; NOTE: Fix Prove's PROVE.TEST::IS-ERROR. It is implemented as an alias to
;;; IS-CONDITION which uses HANDLER-CASE to catch *any* condition (any subclass
;;; of CONDITION). This is wrong, because not every condition is an error.
;;; Because of this, Prove used to catch LCP's warnings and would fail because
;;; an LCP error was expected (which would have been signalled).
(in-package #:prove.test)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro is-error (form condition &optional desc)
(with-gensyms (error duration)
`(with-duration ((,duration ,error) (handler-case ,form
(error (,error) ,error)))
(test ,error
,(if (and (listp condition) (eq 'quote (car condition)))
condition
`(quote ,condition))
,desc
:duration ,duration
:got-form ',form
:test-fn #'typep
:report-expected-label "raise an error")))))
(in-package #:lcp.test)
(defun same-type-test (a b)
"Test whether A and B are the same C++ type under LCP::CPP-TYPE=."
(is a b :test #'lcp::cpp-type=))

View File

@ -4,11 +4,12 @@
(concatenate 'string (uiop:getenvp "HOME") "/quicklisp"))))
(load (concatenate 'string home "/setup.lisp")))
(ql:quickload "lcp/test")
(ql:quickload "lcp/test" :silent t)
(setf uiop:*image-entry-point*
(lambda ()
(let ((prove:*default-reporter* :fiveam))
(let ((*package* (find-package :lcp.test))
(prove:*default-reporter* :fiveam))
(prove:plan nil)
(unless (prove:run-test-package :lcp-test)
(unless (prove:run-test-package :lcp.test)
(uiop:quit 1)))))
(uiop:dump-image "test_lcp" :executable t)