Skip to content

Commit e44da15

Browse files
committed
Generalize perform_custom_initialization into run_custom_script
1 parent 5140bc8 commit e44da15

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

exe/arduino_ci.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,20 @@ def get_annotated_compilers(config, cpp_library)
325325
compilers
326326
end
327327

328-
# Handle existence or nonexistence of custom initialization script -- run it if you have it
328+
# Run custom custom script specified by user.
329329
#
330330
# This feature is to drive GitHub actions / docker image installation where the container is
331331
# in a clean-slate state but needs some way to have custom library versions injected into it.
332332
# In this case, the user provided script would fetch a git repo or some other method.
333-
def perform_custom_initialization()
334-
script_path = ENV[VAR_CUSTOM_INIT_SCRIPT]
335-
script_shell = ENV[VAR_CUSTOM_INIT_SCRIPT + "_SHELL"] || "/bin/sh"
336-
inform("Environment variable #{VAR_CUSTOM_INIT_SCRIPT}") { "'#{script_path}'" }
333+
def run_custom_script(env_var)
334+
script_path = ENV[env_var]
335+
script_shell = ENV[env_var + "_SHELL"] || "/bin/sh"
336+
inform("Environment variable #{env_var}") { "'#{script_path}'" }
337337
return if script_path.nil?
338338
return if script_path.empty?
339339

340340
script_pathname = Pathname.getwd + script_path
341-
assure("Script at #{VAR_CUSTOM_INIT_SCRIPT} exists") { script_pathname.exist? }
341+
assure("Script at #{env_var} exists") { script_pathname.exist? }
342342

343343
assure_multiline("Running #{script_pathname} with #{script_shell} in libraries working dir") do
344344
Dir.chdir(@backend.lib_dir) do
@@ -555,7 +555,7 @@ def perform_example_compilation_tests(cpp_library, config)
555555
end
556556

557557
# run any library init scripts from the library itself.
558-
perform_custom_initialization()
558+
run_custom_script(VAR_CUSTOM_INIT_SCRIPT)
559559

560560
# initialize library under test
561561
inform("Environment variable #{VAR_USE_SUBDIR}") { "'#{ENV[VAR_USE_SUBDIR]}'" }

0 commit comments

Comments
 (0)