aboutsummaryrefslogtreecommitdiff
path: root/tests/test-meta-native-comp-speed.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-01 21:49:18 -0400
committerCraig Jennings <c@cjennings.net>2026-07-01 21:49:31 -0400
commit75198a74bfd9c50b29b13b2d9a3205504a13c4ef (patch)
tree44c2791fc10fd619bb51c7a241e24134e4c44de3 /tests/test-meta-native-comp-speed.el
parent35cbde39ffd459593589b36318a6bc2962703599 (diff)
downloaddotemacs-75198a74bfd9c50b29b13b2d9a3205504a13c4ef.tar.gz
dotemacs-75198a74bfd9c50b29b13b2d9a3205504a13c4ef.zip
fix(native-comp): compile at speed 2 to preserve redefinition semantics
At speed 3 the native compiler emits direct calls for functions in the same compilation unit, bypassing the symbol's function cell. Any cl-letf mock of a module's own helper then silently runs the real code: the recording tests' mocked wayland check and device validation were bypassed, and make test launched real wf-recorder screen captures. Speed 2 is the highest level that preserves redefinition semantics. A meta test now pins the setting; the local eln cache needs one flush so stale speed-3 artifacts recompile.
Diffstat (limited to 'tests/test-meta-native-comp-speed.el')
-rw-r--r--tests/test-meta-native-comp-speed.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test-meta-native-comp-speed.el b/tests/test-meta-native-comp-speed.el
new file mode 100644
index 00000000..35a320e5
--- /dev/null
+++ b/tests/test-meta-native-comp-speed.el
@@ -0,0 +1,35 @@
+;;; test-meta-native-comp-speed.el --- Guard native-comp-speed at 2 -*- lexical-binding: t -*-
+
+;;; Commentary:
+;; Meta test pinning `native-comp-speed' to 2 or lower.
+;;
+;; At speed 3 the native compiler emits direct calls for functions in the
+;; same compilation unit, bypassing the symbol's function cell. Any test
+;; that `cl-letf'-mocks a module's own internal helper then silently
+;; exercises the real code instead of the mock. This bit for real on
+;; 2026-07-01: the video-audio-recording tests mocked
+;; `cj/recording--wayland-p' and `cj/recording--validate-system-audio',
+;; the speed-3 eln called the real ones, and `make test' launched actual
+;; wf-recorder screen recordings and rewrote the configured audio device
+;; from live pactl state.
+;;
+;; Speed 2 is the highest level that preserves redefinition semantics.
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest test-meta-native-comp-speed-preserves-redefinition-semantics ()
+ "Normal: `native-comp-speed' stays at or below 2 after config loads.
+Speed 3 breaks function-cell redirection for same-compilation-unit
+calls, silently bypassing `cl-letf' mocks in the test suite."
+ (skip-unless (and (fboundp 'native-comp-available-p)
+ (native-comp-available-p)))
+ ;; system-defaults sets the value inside `with-eval-after-load'
+ ;; comp-run, so load comp-run first to make that form fire.
+ (require 'comp-run)
+ (require 'system-defaults)
+ (should (<= native-comp-speed 2)))
+
+(provide 'test-meta-native-comp-speed)
+;;; test-meta-native-comp-speed.el ends here