Class: LeakChecker

Inherits:
Object show all
Defined in:
lib/mspec/runner/actions/leakchecker.rb

Overview

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS “AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Instance Method Summary collapse

Constructor Details

#initializeLeakChecker

Returns a new instance of LeakChecker


28
29
30
31
32
33
34
35
# File 'lib/mspec/runner/actions/leakchecker.rb', line 28

def initialize
  @fd_info = find_fds
  @tempfile_info = find_tempfiles
  @thread_info = find_threads
  @env_info = find_env
  @argv_info = find_argv
  @encoding_info = find_encodings
end

Instance Method Details

#check(test_name) ⇒ Object


37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mspec/runner/actions/leakchecker.rb', line 37

def check(test_name)
  @no_leaks = true
  leaks = [
    check_fd_leak(test_name),
    check_thread_leak(test_name),
    check_tempfile_leak(test_name),
    check_env(test_name),
    check_argv(test_name),
    check_encodings(test_name)
  ]
  GC.start if leaks.any?
  return leaks.none?
end