Skip to content

Commit

Permalink
Fix spaces for envvars in submit.yml.erb (#202)
Browse files Browse the repository at this point in the history
Authored-by: Matthew Hu <mhu@owens-rw02.ten.osc.edu>
  • Loading branch information
matthu017 authored Jun 20, 2020
1 parent 7e2e4d7 commit 9eaf3cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ood_core/job/adapters/torque.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "ood_core/refinements/hash_extensions"
require "ood_core/job/adapters/helper"
require 'shellwords'

module OodCore
module Job
Expand Down Expand Up @@ -129,6 +130,9 @@ def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
envvars.merge! script.native.fetch(:envvars, {})
end

# Destructively change envvars to shellescape values
envvars.transform_values! { |v| Shellwords.escape(v) }

# Submit job
@pbs.submit_string(script.content, queue: script.queue_name, headers: headers, resources: resources, envvars: envvars)
else
Expand Down
6 changes: 6 additions & 0 deletions spec/job/adapters/torque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ def build_script(opts = {})
it { expect(pbs).to have_received(:submit_string).with(content, queue: nil, headers: {Join_Path: "oe"}, resources: {}, envvars: {"key" => "value"}) }
end

context "with :job_environment having spaces" do
before { adapter.submit(build_script(job_environment: {"key" => "value value"})) }

it { expect(pbs).to have_received(:submit_string).with(content, queue: nil, headers: {Join_Path: "oe"}, resources: {}, envvars: {"key" => "value\\ value"}) }
end

context "with :workdir" do
before { adapter.submit(build_script(workdir: "/path/to/workdir")) }

Expand Down

0 comments on commit 9eaf3cf

Please sign in to comment.