Skip to content

Commit 9250281

Browse files
committed
Check that $VERBOSE and $DEBUG are not changed by specs
1 parent 5c94a6a commit 9250281

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

spec/mspec/lib/mspec/runner/actions/leakchecker.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def initialize
3636
@thread_info = find_threads
3737
@env_info = find_env
3838
@argv_info = find_argv
39+
@globals_info = find_globals
3940
@encoding_info = find_encodings
4041
end
4142

@@ -48,9 +49,10 @@ def check(state)
4849
check_process_leak
4950
check_env
5051
check_argv
52+
check_globals
5153
check_encodings
5254
check_tracepoints
53-
GC.start if !@leaks.empty?
55+
GC.start unless @leaks.empty?
5456
@leaks.empty?
5557
end
5658

@@ -244,6 +246,19 @@ def check_argv
244246
end
245247
end
246248

249+
def find_globals
250+
{ verbose: $VERBOSE, debug: $DEBUG }
251+
end
252+
253+
def check_globals
254+
old_globals = @globals_info
255+
new_globals = find_globals
256+
if new_globals != old_globals
257+
leak "Globals changed: #{old_globals.inspect} to #{new_globals.inspect}"
258+
@globals_info = new_globals
259+
end
260+
end
261+
247262
def find_encodings
248263
[Encoding.default_internal, Encoding.default_external]
249264
end

0 commit comments

Comments
 (0)