From 3448fdb66e43251a768cd7bc11efab4f4d2525ee Mon Sep 17 00:00:00 2001 From: Jeff Charles Date: Fri, 24 Jan 2025 16:59:54 -0500 Subject: [PATCH] Add tests to check binary path is set correctly --- spec/script_service_spec.rb | 67 ++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/spec/script_service_spec.rb b/spec/script_service_spec.rb index 006a1a3..1f25a7e 100644 --- a/spec/script_service_spec.rb +++ b/spec/script_service_spec.rb @@ -295,7 +295,72 @@ def foo expect(result.success?).to be(true) expect(result.output).to eq([26803196617, 0.475]) expect(result.stdout).to eq("hello") - end + end + + it "calls the binary with GC when generational gc is unset" do + expect(EnterpriseScriptService::ServiceProcess).to receive(:new).with( + Pathname.new(__dir__).parent.join("bin/enterprise_script_service").to_s, + anything, + anything, + anything + ) + runner = double("runner") + allow(runner).to receive(:run) + allow(EnterpriseScriptService::Runner).to receive(:new).and_return(runner) + + EnterpriseScriptService.run( + input: {result: [26803196617, 0.475]}, + sources: [ + ["stdout", "@stdout_buffer = 'hello'"], + ["foo", "@output = @input[:result]"], + ], + timeout: 1000, + ) + end + + it "calls the binary with GC when generational gc is true" do + expect(EnterpriseScriptService::ServiceProcess).to receive(:new).with( + Pathname.new(__dir__).parent.join("bin/enterprise_script_service").to_s, + anything, + anything, + anything + ) + runner = double("runner") + allow(runner).to receive(:run) + allow(EnterpriseScriptService::Runner).to receive(:new).and_return(runner) + + EnterpriseScriptService.run( + input: {result: [26803196617, 0.475]}, + sources: [ + ["stdout", "@stdout_buffer = 'hello'"], + ["foo", "@output = @input[:result]"], + ], + timeout: 1000, + generational_gc: true + ) + end + + it "calls the binary with no gen GC when generational gc is false" do + expect(EnterpriseScriptService::ServiceProcess).to receive(:new).with( + Pathname.new(__dir__).parent.join("bin/enterprise_script_service_no_gen_gc").to_s, + anything, + anything, + anything + ) + runner = double("runner") + allow(runner).to receive(:run) + allow(EnterpriseScriptService::Runner).to receive(:new).and_return(runner) + + EnterpriseScriptService.run( + input: {result: [26803196617, 0.475]}, + sources: [ + ["stdout", "@stdout_buffer = 'hello'"], + ["foo", "@output = @input[:result]"], + ], + timeout: 1000, + generational_gc: false + ) + end private