@@ -147,6 +147,37 @@ pub fn setup_features(
147
147
if (! features .title ) try env .put ("GHOSTTY_SHELL_INTEGRATION_NO_TITLE" , "1" );
148
148
}
149
149
150
+ test "setup_features" {
151
+ const testing = std .testing ;
152
+
153
+ var arena = ArenaAllocator .init (testing .allocator );
154
+ defer arena .deinit ();
155
+ const alloc = arena .allocator ();
156
+
157
+ var env = EnvMap .init (alloc );
158
+ defer env .deinit ();
159
+
160
+ // Test: all features enabled (no environment variables should be set)
161
+ try setup_features (& env , .{ .cursor = true , .sudo = true , .title = true });
162
+ try testing .expect (env .get ("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR" ) == null );
163
+ try testing .expect (env .get ("GHOSTTY_SHELL_INTEGRATION_NO_SUDO" ) == null );
164
+ try testing .expect (env .get ("GHOSTTY_SHELL_INTEGRATION_NO_TITLE" ) == null );
165
+
166
+ // Test: all features disabled
167
+ try setup_features (& env , .{ .cursor = false , .sudo = false , .title = false });
168
+ try testing .expectEqualStrings ("1" , env .get ("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR" ).? );
169
+ try testing .expectEqualStrings ("1" , env .get ("GHOSTTY_SHELL_INTEGRATION_NO_SUDO" ).? );
170
+ try testing .expectEqualStrings ("1" , env .get ("GHOSTTY_SHELL_INTEGRATION_NO_TITLE" ).? );
171
+
172
+ // Test: mixed features
173
+ env .deinit ();
174
+ env = EnvMap .init (alloc );
175
+ try setup_features (& env , .{ .cursor = false , .sudo = true , .title = false });
176
+ try testing .expectEqualStrings ("1" , env .get ("GHOSTTY_SHELL_INTEGRATION_NO_CURSOR" ).? );
177
+ try testing .expect (env .get ("GHOSTTY_SHELL_INTEGRATION_NO_SUDO" ) == null );
178
+ try testing .expectEqualStrings ("1" , env .get ("GHOSTTY_SHELL_INTEGRATION_NO_TITLE" ).? );
179
+ }
180
+
150
181
/// Setup the bash automatic shell integration. This works by
151
182
/// starting bash in POSIX mode and using the ENV environment
152
183
/// variable to load our bash integration script. This prevents
0 commit comments