[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master fb38d36: Make module function finalizer test less brittle.
From: |
Philipp Stephani |
Subject: |
master fb38d36: Make module function finalizer test less brittle. |
Date: |
Sat, 4 Jan 2020 06:35:55 -0500 (EST) |
branch: master
commit fb38d367f4a46c580510f8a6510ae8fb5f39222f
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Make module function finalizer test less brittle.
* test/src/emacs-module-tests.el (module/function-finalizer): Create
100 leaked functions to increase the probability that at least one
gets garbage-collected.
---
test/src/emacs-module-tests.el | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 4f5871b..c61abfd 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -403,11 +403,23 @@ See Bug#36226."
(delete-file so))))
(ert-deftest module/function-finalizer ()
- (mod-test-make-function-with-finalizer)
- (let* ((previous-calls (mod-test-function-finalizer-calls))
- (expected-calls (copy-sequence previous-calls)))
- (cl-incf (car expected-calls))
+ "Test that module function finalizers are properly called."
+ ;; We create and leak a couple of module functions with attached
+ ;; finalizer. Creating only one function risks spilling it to the
+ ;; stack, where it wouldn't be garbage-collected. However, with one
+ ;; hundred functions, there should be at least one that's
+ ;; unreachable.
+ (dotimes (_ 100)
+ (mod-test-make-function-with-finalizer))
+ (cl-destructuring-bind (valid-before invalid-before)
+ (mod-test-function-finalizer-calls)
+ (should (zerop invalid-before))
(garbage-collect)
- (should (equal (mod-test-function-finalizer-calls) expected-calls))))
+ (cl-destructuring-bind (valid-after invalid-after)
+ (mod-test-function-finalizer-calls)
+ (should (zerop invalid-after))
+ ;; We don't require exactly 100 invocations of the finalizer,
+ ;; but at least one.
+ (should (> valid-after valid-before)))))
;;; emacs-module-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master fb38d36: Make module function finalizer test less brittle.,
Philipp Stephani <=