Sha256: c524cdf55e331549586800780c6ffe3d3aca847f4119620f53c56ac6902af37a

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

unless defined? JRUBY_VERSION
  exit
end

$: << File.expand_path( '../../lib', __FILE__ )

describe 'cleanup tempfiles' do

  it 'cleanup  /tmp/jruby-*/jruby*.jar' do
    args = [ RbConfig.ruby,
             '-J-cp',
             File.expand_path( '../test.jar', __FILE__ ),
             '-e',
             'require \'uri:classloader:/my.jar\'; sleep 1234;' ]

    pid = Process.spawn(*args)
    # give jruby some time to start
    sleep 10

    tmpdir = File.join( ENV_JAVA['java.io.tmpdir'], "jruby-#{pid}" )
    unless File.directory?(tmpdir)
      # some OS give the right PID some uses bash to start java
      tmpdir = File.join( ENV_JAVA['java.io.tmpdir'], "jruby-#{pid + 1}" )
    end

    tmpfiles = File.join( tmpdir, 'jruby*.jar' )
 
    expect(Dir[tmpfiles].size).to be > 0

    if JRUBY_VERSION.start_with?('1.')
      system("kill -9 #{pid}")
    else
      Process.kill(9, pid)
    end

    # be sure it is killed
    sleep 1

    require 'lookout/jruby'

    # execute the clean manually for the test
    Lookout::Jruby.cleanup_tempfiles

    
    if JRUBY_VERSION.start_with?('1.')
      expect(Dir[tmpfiles].size).to eq 0
    else
      warn( 'pending: can not kill process with jruby-9k' )
    end
  end

end
 

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookout-jruby-2.4.0 spec/cleanup_tempfile_spec.rb
lookout-jruby-2.3.0 spec/cleanup_tempfile_spec.rb