1515VAR_USE_SUBDIR = "USE_SUBDIR" . freeze
1616VAR_EXPECT_EXAMPLES = "EXPECT_EXAMPLES" . freeze
1717VAR_EXPECT_UNITTESTS = "EXPECT_UNITTESTS" . freeze
18+ VAR_ARDUINO_CI_PRE_UNIT_TEST_RUN_SCRIPT = "ARDUINO_CI_PRE_UNIT_TEST_RUN_SCRIPT" . freeze
19+ VAR_ARDUINO_CI_POST_UNIT_TEST_RUN_SCRIPT = "ARDUINO_CI_POST_UNIT_TEST_RUN_SCRIPT" . freeze
1820
1921@failure_count = 0
2022@passfail = proc { |result | result ? "✓" : "✗" }
@@ -68,6 +70,8 @@ def self.parse(options)
6870 puts " prior to any automated library installation or testing (e.g. to install unofficial libraries)"
6971 puts " - #{ VAR_CUSTOM_INIT_SCRIPT_SHELL } - if set, this will override the"
7072 puts " default shell (/bin/sh) used to execute #{ VAR_CUSTOM_INIT_SCRIPT } with."
73+ puts " - #{ VAR_ARDUINO_CI_PRE_UNIT_TEST_RUN_SCRIPT } and/or #{ VAR_ARDUINO_CI_POST_UNIT_TEST_RUN_SCRIPT } "
74+ puts " if set, run the script before/after each unit test run"
7175 puts " - #{ VAR_USE_SUBDIR } - if set, the script will install the library from this subdirectory of the cwd"
7276 puts " - #{ VAR_EXPECT_EXAMPLES } - if set, testing will fail if no example sketches are present"
7377 puts " - #{ VAR_EXPECT_UNITTESTS } - if set, testing will fail if no unit tests are present"
@@ -444,6 +448,7 @@ def perform_unit_tests(cpp_library, file_config)
444448 platforms . each do |p |
445449 puts
446450 compilers . each do |gcc_binary |
451+ run_custom_script ( VAR_ARDUINO_CI_PRE_UNIT_TEST_RUN_SCRIPT , p , gcc_binary )
447452 # before compiling the tests, build a shared library of everything except the test code
448453 next @failure_count += 1 unless build_shared_library ( gcc_binary , p , config , cpp_library )
449454
@@ -463,6 +468,7 @@ def perform_unit_tests(cpp_library, file_config)
463468 cpp_library . run_test_file ( exe )
464469 end
465470 end
471+ run_custom_script ( VAR_ARDUINO_CI_POST_UNIT_TEST_RUN_SCRIPT , p , gcc_binary )
466472 end
467473 end
468474end
0 commit comments