Skip to content

Commit e083bee

Browse files
johrstromgerald-byrket
authored andcommitted
Add PR #1636
1 parent c218475 commit e083bee

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

apps/dashboard/app/models/batch_connect/app.rb

+11
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,17 @@ def submit_opts(session_context, fmt: nil, staged_root: nil)
227227
ctx_binding.local_variable_set(:staged_root, staged_root.to_s)
228228

229229
hsh = hsh.deep_merge submit_config(binding: ctx_binding)
230+
231+
# let's write the file out if it's a submit.yml.erb that isn't valid yml
232+
rescue Psych::SyntaxError => e
233+
unless staged_root.nil?
234+
yml = submit_file(root: root)
235+
bad_content = render_erb_file(path: yml, contents: yml.read, binding: ctx_binding)
236+
Pathname.new(staged_root).tap { |p| p.mkpath unless p.exist? }
237+
File.open("#{staged_root}/submit.yml", 'w+') { |file| file.write(bad_content) }
238+
end
239+
240+
raise e
230241
end
231242

232243
# View used for session if it exists
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
script:
3+
native:
4+
bad_yml_syntax

apps/dashboard/test/models/batch_connect/app_test.rb

+30
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,34 @@ def bad_clusters
239239
assert_equal opts[:script][:error_path], "#{dir}/error.log"
240240
end
241241
end
242+
243+
test "select widgets with no options values throws error" do
244+
r = PathRouter.new("test/fixtures/sys_with_interactive_apps/broken_app")
245+
app = BatchConnect::App.new(router: r)
246+
247+
Dir.mktmpdir do |dir|
248+
exception = assert_raise StandardError do
249+
app.submit_opts(app.build_session_context, staged_root: dir)
250+
end
251+
assert_equal "The form.yml has missing options in the node_type form field.", exception.message
252+
end
253+
end
254+
255+
test "bad submit.yml.erb files write submit.yml" do
256+
r = PathRouter.new("test/fixtures/sys_with_interactive_apps/bc_paraview")
257+
app = BatchConnect::App.new(router: r)
258+
expected_file = <<~HEREDOC
259+
---
260+
script:
261+
native:
262+
bad_yml_syntax
263+
HEREDOC
264+
265+
Dir.mktmpdir do |dir|
266+
assert_raise Psych::SyntaxError do
267+
app.submit_opts(app.build_session_context, staged_root: dir)
268+
end
269+
assert_equal expected_file, File.read("#{dir}/submit.yml")
270+
end
271+
end
242272
end

0 commit comments

Comments
 (0)