Permalink
Browse files

adding basic test for builder; making it pass

  • Loading branch information...
1 parent 846a971 commit 556cf8ecdbd7856831f68386b1d7dcfe50179855 @romand romand committed Jun 29, 2012
@@ -77,7 +77,7 @@ def codes_create(code, options = {})
raise IronCore::IronError.new("Error while remote building: " + log)
end
- res = JSON.parse(task.msg)
+ res = JSON.parse(builder_task.msg)
end
File.unlink(zip_file)
@@ -216,6 +216,7 @@ def create_zip
if @remote_build_command
IronCore::Logger.info 'IronWorkerNG', 'Creating builder'
builder = IronWorkerNG::Builder.new self
+ builder.fixate
builder.bundle(zip)
end
end
@@ -15,15 +15,15 @@ def initialize(src)
gem 'iron_worker_ng'
- file(File.open(Dir.mktmpdir + '/__builder__.sh') do |f|
- f <<BUILDER_SH
+ file(File.open(Dir.mktmpdir + '/__builder__.sh', 'w') do |f|
+ f <<<<BUILDER_SH
# iron_worker_ng-#{IronWorkerNG.full_version}
#{src.remote_build_command}
BUILDER_SH
end.path)
exec(File.open(Dir.mktmpdir + '/__builder__.rb', 'w') do |f|
- f <<BUILDER_RUBY
+ f <<<<BUILDER_RUBY
# iron_worker_ng-#{IronWorkerNG.full_version}
require 'iron_worker_ng'
@@ -33,10 +33,11 @@ def initialize(src)
Dir.chdir('__build__')
-code = IronWorkerNG::Code.new do
- runtime '#{src.runtime}'
+code = IronWorkerNG::Code::Creator.create do
+ runtime 'binary'
name '#{src.name}'
- exec '#{src.exec}'
+ `mv __runner__.sh __actual_runner__.sh`
+ exec '__actual_runner__.sh'
dir '.'
end
@@ -23,9 +23,11 @@ def bundle(zip)
end
module InstanceMethods
- def merge_exec(path)
+ def merge_exec(path=nil)
@exec ||= nil
+ return @exec unless path
+
unless @exec.nil?
IronCore::Logger.warn 'IronWorkerNG', "Ignoring attempt to merge binary exec with path='#{path}'"
return
@@ -29,9 +29,11 @@ def code_for_classpath
end
module InstanceMethods
- def merge_exec(path, klass = nil)
+ def merge_exec(path = nil, klass = nil)
@exec ||= nil
+ return @exec unless path
+
unless @exec.nil?
IronCore::Logger.warn 'IronWorkerNG', "Ignoring attempt to merge java exec with path='#{path}' and class='#{klass}'"
return
@@ -23,9 +23,11 @@ def bundle(zip)
end
module InstanceMethods
- def merge_exec(path)
+ def merge_exec(path=nil)
@exec ||= nil
+ return @exec unless path
+
unless @exec.nil?
IronCore::Logger.warn 'IronWorkerNG', "Ignoring attempt to merge node exec with path='#{path}'"
return
@@ -25,9 +25,11 @@ def bundle(zip)
end
module InstanceMethods
- def merge_exec(path, klass = nil)
+ def merge_exec(path = nil, klass = nil)
@exec ||= nil
+ return @exec unless path
+
unless @exec.nil?
IronCore::Logger.warn 'IronWorkerNG', "Ignoring attempt to merge ruby exec with path='#{path}' and class='#{klass}'"
return
View
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main()
+{
+ printf("hello\n");
+ return 0;
+}
View
@@ -0,0 +1,26 @@
+require 'helpers'
+
+class BuilderTest < IWNGTest
+
+ def test_basic
+ code = code_bundle do
+ runtime 'ruby'
+ name 'CHello'
+ file 'test/hello.c'
+ remote_build_command 'gcc hello.c'
+ worker_code 'exec("./a.out")'
+ end
+
+ puts code.create_zip
+
+ start = Time.now
+ client.codes.create(code)
+ puts "uploading finished in #{(Time.now - start).to_i} seconds"
+
+ task = client.tasks.create('CHello')
+ client.tasks.wait_for(task.id)
+
+ assert_equal "hello\n", client.tasks.log(task.id)
+ end
+
+end

0 comments on commit 556cf8e

Please sign in to comment.