Skip to content

Commit 0f573b5

Browse files
committed
Add information about skipping unnecessary tests
1 parent ddf67d2 commit 0f573b5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

exe/arduino_ci.rb

+15-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
VAR_EXPECT_EXAMPLES = "EXPECT_EXAMPLES".freeze
1010
VAR_EXPECT_UNITTESTS = "EXPECT_UNITTESTS".freeze
1111

12+
CLI_SKIP_EXAMPLES_COMPILATION = "--skip-examples-compilation"
13+
CLI_SKIP_UNITTESTS = "--skip-unittests"
14+
1215
# script-level variables we'll use
1316
@log = nil
1417
@backend = nil
@@ -30,11 +33,11 @@ def self.parse(options)
3033
opt_parser = OptionParser.new do |opts|
3134
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
3235

33-
opts.on("--skip-unittests", "Don't run unit tests") do |p|
36+
opts.on(CLI_SKIP_UNITTESTS, "Don't run unit tests") do |p|
3437
output_options[:skip_unittests] = p
3538
end
3639

37-
opts.on("--skip-examples-compilation", "Don't compile example sketches") do |p|
40+
opts.on(CLI_SKIP_EXAMPLES_COMPILATION, "Don't compile example sketches") do |p|
3841
output_options[:skip_compilation] = p
3942
end
4043

@@ -195,10 +198,11 @@ def install_all_packages(platforms, specific_config)
195198

196199
# @param expectation_envvar [String] the name of the env var to check
197200
# @param operation [String] a description of what operation we might be skipping
201+
# @param howto_skip [String] a descripton of how the runner can skip this
198202
# @param filegroup_name [String] a description of the set of files without which we effectively skip the operation
199203
# @param dir_description [String] a description of the directory where we looked for the files
200204
# @param dir [Pathname] the directory where we looked for the files
201-
def handle_expectation_of_files(expectation_envvar, operation, filegroup_name, dir_description, dir_path)
205+
def handle_expectation_of_files(expectation_envvar, operation, howto_skip, filegroup_name, dir_description, dir_path)
202206
# alert future me about running the script from the wrong directory, instead of doing the huge file dump
203207
# otherwise, assume that the user might be running the script on a library with no actual unit tests
204208
if Pathname.new(__dir__).parent == Pathname.new(Dir.pwd)
@@ -222,20 +226,22 @@ def handle_expectation_of_files(expectation_envvar, operation, filegroup_name, d
222226
end
223227

224228
@log.inform(problem) { dir_path }
225-
explain_and_exercise_envvar(expectation_envvar, operation, "contents of #{dir_desc}") { display_files(dir) }
229+
explain_and_exercise_envvar(expectation_envvar, operation, howto_skip, "contents of #{dir_desc}") { display_files(dir) }
226230
end
227231

228232
# @param expectation_envvar [String] the name of the env var to check
229233
# @param operation [String] a description of what operation we might be skipping
234+
# @param howto_skip [String] a descripton of how the runner can skip this
230235
# @param block_desc [String] a description of what information will be dumped to assist the user
231236
# @param block [Proc] a function that dumps information
232-
def explain_and_exercise_envvar(expectation_envvar, operation, block_desc, &block)
237+
def explain_and_exercise_envvar(expectation_envvar, operation, howto_skip, block_desc, &block)
233238
@log.inform("Environment variable #{expectation_envvar} is") { "(#{ENV[expectation_envvar].class}) #{ENV[expectation_envvar]}" }
234239
if ENV[expectation_envvar].nil?
235240
@log.inform_multiline("Skipping #{operation}") do
236241
@log.iputs "In case that's an error, displaying #{block_desc}:"
237242
block.call
238243
@log.iputs "To force an error in this case, set the environment variable #{expectation_envvar}"
244+
@log.iputs "To explicitly skip this check, use #{howto_skip}"
239245
true
240246
end
241247
else
@@ -410,14 +416,14 @@ def perform_unit_tests(cpp_library, file_config)
410416

411417
# Handle lack of test files
412418
if cpp_library.test_files.empty?
413-
handle_expectation_of_files(VAR_EXPECT_UNITTESTS, "unit tests", "test files", "tests directory", cpp_library.tests_dir)
419+
handle_expectation_of_files(VAR_EXPECT_UNITTESTS, "unit tests", CLI_SKIP_UNITTESTS, "test files", "tests directory", cpp_library.tests_dir)
414420
return
415421
end
416422

417423
# Get platforms, handle lack of them
418424
platforms = choose_platform_set(config, "unittest", config.platforms_to_unittest, cpp_library.library_properties)
419425
if platforms.empty?
420-
explain_and_exercise_envvar(VAR_EXPECT_UNITTESTS, "unit tests", "platforms and architectures") do
426+
explain_and_exercise_envvar(VAR_EXPECT_UNITTESTS, "unit tests", CLI_SKIP_UNITTESTS, "platforms and architectures") do
421427
@log.iputs "Configured platforms: #{config.platforms_to_unittest}"
422428
@log.iputs "Configuration is default: #{config.is_default}"
423429
arches = cpp_library.library_properties.nil? ? nil : cpp_library.library_properties.architectures
@@ -479,7 +485,7 @@ def perform_example_compilation_tests(cpp_library, config)
479485
library_examples = cpp_library.example_sketches
480486

481487
if library_examples.empty?
482-
handle_expectation_of_files(VAR_EXPECT_EXAMPLES, "builds", "examples", "the examples directory", cpp_library.examples_dir)
488+
handle_expectation_of_files(VAR_EXPECT_EXAMPLES, "builds", CLI_SKIP_EXAMPLES_COMPILATION, "examples", "the examples directory", cpp_library.examples_dir)
483489
return
484490
end
485491

@@ -498,7 +504,7 @@ def perform_example_compilation_tests(cpp_library, config)
498504

499505
# having no platforms defined is probably an error
500506
if platforms.empty?
501-
explain_and_exercise_envvar(VAR_EXPECT_EXAMPLES, "examples compilation", "platforms and architectures") do
507+
explain_and_exercise_envvar(VAR_EXPECT_EXAMPLES, "examples compilation", CLI_SKIP_EXAMPLES_COMPILATION, "platforms and architectures") do
502508
@log.iputs "Configured platforms: #{ovr_config.platforms_to_build}"
503509
@log.iputs "Configuration is default: #{ovr_config.is_default}"
504510
arches = cpp_library.library_properties.nil? ? nil : cpp_library.library_properties.architectures

0 commit comments

Comments
 (0)