Skip to content

Commit 5140bc8

Browse files
committed
Add support for overriding shell to execute CUSTOM_INIT_SCRIPT with
1 parent 705e8db commit 5140bc8

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Added
1010

1111
- Added support for `ARDUINO_CI_UNIT_TEST_EXTRA_COMPILER_FLAGS` environment variable.
12+
- Added support for overriding the shell used to execute `CUSTOM_INIT_SCRIPT`
13+
by setting `CUSTOM_INIT_SCRIPT_SHELL` (defaults to `/bin/sh`).
1214

1315
### Changed
1416

REFERENCE.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ This allows a file (or glob) pattern to be executed in your tests directory, cre
4646

4747
### `CUSTOM_INIT_SCRIPT` environment variable
4848

49-
If set, testing will execute (using `/bin/sh`) the script referred to by this
50-
variable -- relative to the current working directory (i.e. the root directory
51-
of the library). The script will _run_ in the Arduino Libraries directory
49+
If set, testing will execute the script referred to by this variable -- relative
50+
to the current working directory (i.e. the root directory of the library). By
51+
default the script will be executed using `/bin/sh` but you can override by
52+
setting `CUSTOM_INIT_SCRIPT_SHELL` (e.g to `powershell`, `/usr/bin/perl` etc).
53+
The script will _run_ in the Arduino Libraries directory
5254
(changing to the Libraries directory, running the script, and returning to the
5355
individual library root afterward). This enables use cases like the GitHub
5456
action to install custom library versions (i.e. a version of a library that

exe/arduino_ci.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def self.parse(options)
6666
puts "Additionally, the following environment variables control the script:"
6767
puts " - #{VAR_CUSTOM_INIT_SCRIPT} - if set, this script will be run from the Arduino/libraries directory"
6868
puts " prior to any automated library installation or testing (e.g. to install unofficial libraries)"
69+
puts " - #{VAR_CUSTOM_INIT_SCRIPT_SHELL} - if set, this will override the"
70+
puts " default shell (/bin/sh) used to execute #{VAR_CUSTOM_INIT_SCRIPT} with."
6971
puts " - #{VAR_USE_SUBDIR} - if set, the script will install the library from this subdirectory of the cwd"
7072
puts " - #{VAR_EXPECT_EXAMPLES} - if set, testing will fail if no example sketches are present"
7173
puts " - #{VAR_EXPECT_UNITTESTS} - if set, testing will fail if no unit tests are present"
@@ -330,16 +332,17 @@ def get_annotated_compilers(config, cpp_library)
330332
# In this case, the user provided script would fetch a git repo or some other method.
331333
def perform_custom_initialization()
332334
script_path = ENV[VAR_CUSTOM_INIT_SCRIPT]
335+
script_shell = ENV[VAR_CUSTOM_INIT_SCRIPT + "_SHELL"] || "/bin/sh"
333336
inform("Environment variable #{VAR_CUSTOM_INIT_SCRIPT}") { "'#{script_path}'" }
334337
return if script_path.nil?
335338
return if script_path.empty?
336339

337340
script_pathname = Pathname.getwd + script_path
338341
assure("Script at #{VAR_CUSTOM_INIT_SCRIPT} exists") { script_pathname.exist? }
339342

340-
assure_multiline("Running #{script_pathname} with sh in libraries working dir") do
343+
assure_multiline("Running #{script_pathname} with #{script_shell} in libraries working dir") do
341344
Dir.chdir(@backend.lib_dir) do
342-
IO.popen(["/bin/sh", script_pathname.to_s], err: [:child, :out]) do |io|
345+
IO.popen([script_shell, script_pathname.to_s], err: [:child, :out]) do |io|
343346
io.each_line { |line| puts " #{line}" }
344347
end
345348
end

0 commit comments

Comments
 (0)