diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-21 03:19:08 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-21 03:19:08 -0400 |
| commit | a249e415c7199e3d4698f1956687fa351296a357 (patch) | |
| tree | bdc9efadba60e08a43a5f687110fe12651172525 /tests/test-video-audio-recording-test-mic.el | |
| parent | a8571effadacd6f94291bfd57b7e58900a2e5816 (diff) | |
| download | dotemacs-a249e415c7199e3d4698f1956687fa351296a357.tar.gz dotemacs-a249e415c7199e3d4698f1956687fa351296a357.zip | |
test: make subr mocks variadic for native-comp, add arity meta-test
Re-enabling native-comp surfaced a suite-wide fragility. When a test redefines a C primitive (or a native-compiled function), native-comp routes native callers through a trampoline that calls the mock with the primitive's maximum arity. A fixed-arity mock narrower than the primitive then throws wrong-number-of-arguments, intermittently, as the eln-cache fills.
I swept every arity-narrow subr mock to append &rest _ (188 sites, preserving any named args the body uses), and added tests/test-meta-subr-mock-arity.el, which fails make test on any subr mock too narrow for the primitive's arity. The rule isn't "never mock a subr". The suite mocks message and completing-read freely. It's "a subr mock must accept the primitive's arity."
Background, the three failure modes, and the research are in docs/native-comp-subr-mocking.org.
Diffstat (limited to 'tests/test-video-audio-recording-test-mic.el')
| -rw-r--r-- | tests/test-video-audio-recording-test-mic.el | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/test-video-audio-recording-test-mic.el b/tests/test-video-audio-recording-test-mic.el index 60b9eb0b..64ef0eaa 100644 --- a/tests/test-video-audio-recording-test-mic.el +++ b/tests/test-video-audio-recording-test-mic.el @@ -36,11 +36,11 @@ (let ((temp-file nil)) ;; Mock make-temp-file to capture filename (cl-letf (((symbol-function 'make-temp-file) - (lambda (prefix _dir-flag suffix) + (lambda (prefix _dir-flag suffix &rest _) (setq temp-file (concat prefix "12345" suffix)) temp-file)) ((symbol-function 'shell-command) - (lambda (_cmd) 0))) + (lambda (_cmd &rest _) 0))) (cj/recording-test-mic) (should (string-match-p "\\.wav$" temp-file))))) (test-mic-teardown))) @@ -54,7 +54,7 @@ (let ((commands nil)) ;; Mock shell-command to capture all commands (cl-letf (((symbol-function 'shell-command) - (lambda (cmd) (push cmd commands) 0))) + (lambda (cmd &rest _) (push cmd commands) 0))) (cj/recording-test-mic) (should (= 2 (length commands))) ;; First command should be ffmpeg (stored last in list due to push) @@ -74,7 +74,7 @@ (let ((commands nil)) ;; Capture all shell commands (cl-letf (((symbol-function 'shell-command) - (lambda (cmd) (push cmd commands) 0))) + (lambda (cmd &rest _) (push cmd commands) 0))) (cj/recording-test-mic) (should (= 2 (length commands))) ;; Second command should be ffplay @@ -93,7 +93,7 @@ (cl-letf (((symbol-function 'message) (lambda (fmt &rest args) (push (apply #'format fmt args) messages))) ((symbol-function 'shell-command) - (lambda (_cmd) 0))) + (lambda (_cmd &rest _) 0))) (cj/recording-test-mic) (should (>= (length messages) 3)) ;; Check for recording message @@ -135,7 +135,7 @@ (setq cj/recording-mic-device "test-mic-device") ;; Mock shell-command to fail (cl-letf (((symbol-function 'shell-command) - (lambda (_cmd) 1))) ;; Non-zero exit code + (lambda (_cmd &rest _) 1))) ;; Non-zero exit code ;; Should complete without crashing (ffmpeg errors are ignored) ;; No error is raised - function just completes (cj/recording-test-mic) |
