Enforce still more purity of pure tests

Disallow IN-PACKAGE which was an all-to-easy way to escape from jail.
And due to a typo, DEFMETHOD was accidentally allowed.

Rename two test files from impure to pure, and move one LOAD test from a
pure file into an impure file since it sneakily loaded a "data" file
containing an IN-PACKAGE followed by a DEFCLASS.
This commit is contained in:
Douglas Katzman 2019-04-06 11:42:26 -04:00
parent 3e4e20fcf4
commit fdb6e0d535
10 changed files with 59 additions and 28 deletions

View file

@ -1,4 +1,7 @@
(in-package "SB-THREAD")
(use-package "SB-INT")
(import 'sb-thread::(avlnode-key avlnode-data avlnode-left avlnode-right
avl-insert avl-delete avl-find
avl-balance-factor avl-count))
(defun tree-to-dot (tree output)
(with-open-file (stream output :direction :output :if-exists :supersede)

View file

@ -208,7 +208,7 @@
'`(,@(list 1 2 3) 4) nil)
'(sb-impl::|Append| (list 1 2 3) '(4)))))
(in-package sb-impl)
(import 'sb-int:quasiquote)
(test-util:with-test (:name :backquote-more-weirdness)
;; No expectation on any other Lisp.

View file

@ -11,7 +11,16 @@
(enable-test-parallelism)
(in-package :sb-c)
(import '(sb-c::combination-fun-debug-name
sb-c::combination-fun-source-name
sb-c::*compile-component-hook*
sb-c::basic-combination-p
sb-c::basic-combination-info
sb-c::node-tail-p
sb-c::do-blocks
sb-c::do-nodes
sb-c::%check-bound
sb-kernel:%bit-position/1))
(defun inspect-ir (form fun &rest checked-compile-args)
(let ((*compile-component-hook* fun))

View file

@ -13,6 +13,29 @@
(defvar *tmp-filename* "load-test.tmp")
;;; These tests are essentially the same as in compiler.pure.lisp
;;; They have to be run before we mess up *DEFAULT-PATHNAME-DEFAULTS*
(with-test (:name :load-as-source-error-position-reporting)
;; These test errors that occur during READ
(dolist (input '("data/wonky1.lisp" "data/wonky2.lisp" "data/wonky3.lisp"))
(let ((expect (with-open-file (f input) (read f))))
(assert (stringp expect))
(let ((err-string
(block foo
;; you can't query the stream position with HANDLER-CASE
;; because it closes before the condition is formatted.
(handler-bind ((error (lambda (c)
(return-from foo
(write-to-string c :escape nil)))))
(load input)))))
(assert (search expect err-string)))))
;; This tests an error that occur during EVAL
(let ((s (with-output-to-string (*error-output*)
(handler-bind ((error #'abort)) (load "data/wonky4.lisp")))))
(assert (search "While evaluating the form starting at line 16, column 1"
s))))
;;; Save this because we're going to mess up the path in the following SETQ.
(defvar *parallel-load-source-file* (truename "parallel-fasl-load-test.lisp"))

View file

@ -23,25 +23,3 @@
;;; IF-DOES-NOT-EXIST was true.
(assert (typep (nth-value 1 (ignore-errors (load "i-am-not"))) 'file-error))
(assert (typep (nth-value 1 (ignore-errors (load "i-am-not" :if-does-not-exist t))) 'file-error))
;; These tests are essentially the same as in compiler.pure.lisp
(with-test (:name :load-as-source-error-position-reporting)
;; These test errors that occur during READ
(dolist (input '("data/wonky1.lisp" "data/wonky2.lisp" "data/wonky3.lisp"))
(let ((expect (with-open-file (f input) (read f))))
(assert (stringp expect))
(let ((err-string
(block foo
;; you can't query the stream position with HANDLER-CASE
;; because it closes before the condition is formatted.
(handler-bind ((error (lambda (c)
(return-from foo
(write-to-string c :escape nil)))))
(load input)))))
(assert (search expect err-string)))))
;; This tests an error that occur during EVAL
(let ((s (with-output-to-string (*error-output*)
(handler-bind ((error #'abort)) (load "data/wonky4.lisp")))))
(assert (search "While evaluating the form starting at line 16, column 1"
s))))

View file

@ -138,7 +138,12 @@
;; DEF{constant,fun,macro,parameter,setf,type,var} are generally ok
;; except when DEFfoo defines something too hairy to hang off a symbol.
(cond (actually-pure
(shadow '("DEFSTRUCT" "DEFMETHDO") test-package)
(shadow '("DEFSTRUCT" "DEFMETHOD"
;; Hiding IN-PACKAGE is a good preventative measure.
;; There are other ways to do nasty things of course.
;; Deliberately violating a package lock has got to be impure.
"IN-PACKAGE" "WITHOUT-PACKAGE-LOCKS")
test-package)
;; We have pure tests that exercise the DEFCLASS and DEFGENERIC
;; macros to generate macroexpansion-time errors. That's mostly ok.
;; We can trap attempts to use SB-KERNEL::%COMPILER-mumble

View file

@ -11,7 +11,10 @@
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
(in-package sb-impl)
(import '(sb-impl::make-handler
sb-impl::handler-descriptor
sb-impl::handler-bogus
sb-impl::compute-pollfds))
;; Tests for SERVE-EVENT are somewhat lacking,
;; although RUN-PROGRAM exercises some multiplexed I/O.

View file

@ -560,7 +560,17 @@
(with-test (:name :typep-satisfies-boolean)
(assert (eq (eval '(typep 1 '(satisfies eval))) t)))
(in-package "SB-KERNEL")
(import '(sb-kernel:specifier-type
sb-kernel:type-specifier
sb-kernel:type-intersection
sb-kernel::character-string
sb-kernel:simple-character-string
sb-kernel:type=
sb-kernel:find-classoid
sb-kernel:make-numeric-type
sb-kernel::numeric-types-adjacent
sb-kernel::numeric-types-intersect
sb-kernel:*empty-type*))
(test-util:with-test (:name :partition-array-into-simple/hairy)
;; Some tests that (simple-array | hairy-array) = array