Skip to content

Commit

Permalink
Set RUBY_MEMCHECK_RUNNING environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Aug 4, 2023
1 parent a295057 commit d415e82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ruby_memcheck/test_task_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def run_ruby_with_valgrind(&block)

def setup
ENV["RUBY_MEMCHECK_LOADED_FEATURES_FILE"] = File.expand_path(configuration.loaded_features_file)
ENV["RUBY_MEMCHECK_RUNNING"] = "1"
end

def report_valgrind_errors
Expand Down
12 changes: 12 additions & 0 deletions test/ruby_memcheck/shared_test_task_reporter_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ def test_test_helper_is_loaded
end
end

def test_envionment_variable_RUBY_MEMCHECK_RUNNING
Tempfile.create do |tempfile|
ok = run_with_memcheck(<<~RUBY, raise_on_failure: false)
File.write(#{tempfile.path.inspect}, ENV["RUBY_MEMCHECK_RUNNING"])
RUBY

assert(ok)
assert_empty(@test_task.reporter.errors)
assert_includes(tempfile.read, "1")
end
end

private

def run_with_memcheck(code, raise_on_failure: true, spawn_opts: {})
Expand Down

0 comments on commit d415e82

Please sign in to comment.