Skip to content

Commit

Permalink
packing gems as for GEM_PATH; populating GEM_PATH; getting remote tes…
Browse files Browse the repository at this point in the history
…t working finally
  • Loading branch information
romand committed May 31, 2012
1 parent 76240d4 commit 6374f28
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lib/iron_worker_ng/code/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class IronWorkerNGHash < Hash
Dir.chdir(root)
#{gempath_code}
suffix = ':' + prev if prev = ENV['GEM_PATH']
ENV['GEM_PATH'] = root + '__gems__' + (suffix || '')
$:.unshift("\#{root}")
require 'json'
Expand Down
9 changes: 6 additions & 3 deletions lib/iron_worker_ng/feature/ruby/merge_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ def bundle(zip)
if @spec.extensions.length == 0 || IronWorkerNG::Feature::Ruby::MergeGem.merge_binary?
IronCore::Logger.debug 'IronWorkerNG', "Bundling ruby gem with name='#{@spec.name}' and version='#{@spec.version}'"

zip.add('__gems__/' + @spec.full_name, gem_path)
zip.add('__gems__/gems/' + @spec.full_name, gem_path)
zip.add("__gems__/specifications/#{@spec.full_name}.gemspec",
File.expand_path(gem_path + '/../../specifications/' +
@spec.full_name + '.gemspec'))
Dir.glob(gem_path + '/**/**') do |path|
zip.add('__gems__/' + @spec.full_name + path[gem_path.length .. -1], path)
zip.add('__gems__/gems/' + @spec.full_name + path[gem_path.length .. -1], path)
end
else
IronCore::Logger.warn 'IronWorkerNG', "Skipping ruby gem with name='#{@spec.name}' and version='#{@spec.version}' as it contains native extensions"
Expand All @@ -53,7 +56,7 @@ def bundle(zip)

def code_for_gempath
if @spec.extensions.length == 0 || IronWorkerNG::Feature::Ruby::MergeGem.merge_binary?
'$:.unshift("#{root}/__gems__/' + @spec.full_name + '/lib")'
'$:.unshift("#{root}/__gems__/gems/' + @spec.full_name + '/lib")'
else
'# native gem ' + @spec.full_name
end
Expand Down
5 changes: 2 additions & 3 deletions ng_tests_worker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Dir.chdir Dir.glob('iwng/*').first
ENV['NG_GEM_PATH'] = $:.join ':'
exec 'rake -f test/Rakefile test TESTP=basic'
Dir.chdir 'iwng'
exec 'rake -f test/Rakefile test'
13 changes: 12 additions & 1 deletion remote_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@
exec 'ng_tests_worker.rb'
gemfile 'Gemfile'
gemfile 'test/Gemfile'
dir '.', 'iwng'

Dir.glob('*').each do |p|
dir p, 'iwng' if Dir.exist? p
file p, 'iwng' if File.exist? p
end

file( File.open(Dir.mktmpdir + '/iron.json', 'w') do |f|
f << {
token: client.api.token,
project_id: client.api.project_id
}.to_json
end.path, 'iwng' )
end

puts client.codes.create(code)
Expand Down
12 changes: 10 additions & 2 deletions test/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ require 'bundler'
require 'rake/testtask'
require 'tmpdir'

(ENV['NG_GEM_PATH'] || "").split(':').reverse.each{ $:.unshift p }

Dir.chdir(File.dirname(__FILE__) + '/..')

tmpdir = Dir.mktmpdir
File.open(tmpdir + '/Gemfile', 'w') do |f|
f << File.read('Gemfile')
f << File.read('test/Gemfile')
end
Dir.chdir tmpdir do
Bundler.setup
end

Rake::TestTask.new do |t|
examples_tests_dir = Dir.mktmpdir('iw_examples')

Expand Down Expand Up @@ -42,6 +49,7 @@ Rake::TestTask.new do |t|
t.libs << "lib" << "test" << examples_tests_dir
files = FileList['test/**/test_**.rb',
examples_tests_dir + '/**/test_*.rb']
$:.each{ |path| t.ruby_opts << "-I#{path}" }
t.test_files = files.keep_if do |f|
f =~ Regexp.new(ENV['TESTP'] || '') and
not ( r = ENV['EXCLP'] and
Expand Down

0 comments on commit 6374f28

Please sign in to comment.