9
9
VAR_EXPECT_EXAMPLES = "EXPECT_EXAMPLES" . freeze
10
10
VAR_EXPECT_UNITTESTS = "EXPECT_UNITTESTS" . freeze
11
11
12
+ CLI_SKIP_EXAMPLES_COMPILATION = "--skip-examples-compilation" . freeze
13
+ CLI_SKIP_UNITTESTS = "--skip-unittests" . freeze
14
+
12
15
# script-level variables we'll use
13
16
@log = nil
14
17
@backend = nil
@@ -30,11 +33,11 @@ def self.parse(options)
30
33
opt_parser = OptionParser . new do |opts |
31
34
opts . banner = "Usage: #{ File . basename ( __FILE__ ) } [options]"
32
35
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 |
34
37
output_options [ :skip_unittests ] = p
35
38
end
36
39
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 |
38
41
output_options [ :skip_compilation ] = p
39
42
end
40
43
@@ -195,10 +198,11 @@ def install_all_packages(platforms, specific_config)
195
198
196
199
# @param expectation_envvar [String] the name of the env var to check
197
200
# @param operation [String] a description of what operation we might be skipping
201
+ # @param howto_skip [String] a description of how the runner can skip this
198
202
# @param filegroup_name [String] a description of the set of files without which we effectively skip the operation
199
203
# @param dir_description [String] a description of the directory where we looked for the files
200
204
# @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 )
202
206
# alert future me about running the script from the wrong directory, instead of doing the huge file dump
203
207
# otherwise, assume that the user might be running the script on a library with no actual unit tests
204
208
if Pathname . new ( __dir__ ) . parent == Pathname . new ( Dir . pwd )
@@ -222,20 +226,22 @@ def handle_expectation_of_files(expectation_envvar, operation, filegroup_name, d
222
226
end
223
227
224
228
@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 ) }
226
230
end
227
231
228
232
# @param expectation_envvar [String] the name of the env var to check
229
233
# @param operation [String] a description of what operation we might be skipping
234
+ # @param howto_skip [String] a description of how the runner can skip this
230
235
# @param block_desc [String] a description of what information will be dumped to assist the user
231
236
# @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 )
233
238
@log . inform ( "Environment variable #{ expectation_envvar } is" ) { "(#{ ENV [ expectation_envvar ] . class } ) #{ ENV [ expectation_envvar ] } " }
234
239
if ENV [ expectation_envvar ] . nil?
235
240
@log . inform_multiline ( "Skipping #{ operation } " ) do
236
241
@log . iputs "In case that's an error, displaying #{ block_desc } :"
237
242
block . call
238
243
@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 } "
239
245
true
240
246
end
241
247
else
@@ -410,14 +416,21 @@ def perform_unit_tests(cpp_library, file_config)
410
416
411
417
# Handle lack of test files
412
418
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 (
420
+ VAR_EXPECT_UNITTESTS ,
421
+ "unit tests" ,
422
+ CLI_SKIP_UNITTESTS ,
423
+ "test files" ,
424
+ "tests directory" ,
425
+ cpp_library . tests_dir
426
+ )
414
427
return
415
428
end
416
429
417
430
# Get platforms, handle lack of them
418
431
platforms = choose_platform_set ( config , "unittest" , config . platforms_to_unittest , cpp_library . library_properties )
419
432
if platforms . empty?
420
- explain_and_exercise_envvar ( VAR_EXPECT_UNITTESTS , "unit tests" , "platforms and architectures" ) do
433
+ explain_and_exercise_envvar ( VAR_EXPECT_UNITTESTS , "unit tests" , CLI_SKIP_UNITTESTS , "platforms and architectures" ) do
421
434
@log . iputs "Configured platforms: #{ config . platforms_to_unittest } "
422
435
@log . iputs "Configuration is default: #{ config . is_default } "
423
436
arches = cpp_library . library_properties . nil? ? nil : cpp_library . library_properties . architectures
@@ -479,7 +492,14 @@ def perform_example_compilation_tests(cpp_library, config)
479
492
library_examples = cpp_library . example_sketches
480
493
481
494
if library_examples . empty?
482
- handle_expectation_of_files ( VAR_EXPECT_EXAMPLES , "builds" , "examples" , "the examples directory" , cpp_library . examples_dir )
495
+ handle_expectation_of_files (
496
+ VAR_EXPECT_EXAMPLES ,
497
+ "builds" ,
498
+ CLI_SKIP_EXAMPLES_COMPILATION ,
499
+ "examples" ,
500
+ "the examples directory" ,
501
+ cpp_library . examples_dir
502
+ )
483
503
return
484
504
end
485
505
@@ -498,7 +518,12 @@ def perform_example_compilation_tests(cpp_library, config)
498
518
499
519
# having no platforms defined is probably an error
500
520
if platforms . empty?
501
- explain_and_exercise_envvar ( VAR_EXPECT_EXAMPLES , "examples compilation" , "platforms and architectures" ) do
521
+ explain_and_exercise_envvar (
522
+ VAR_EXPECT_EXAMPLES ,
523
+ "examples compilation" ,
524
+ CLI_SKIP_EXAMPLES_COMPILATION ,
525
+ "platforms and architectures"
526
+ ) do
502
527
@log . iputs "Configured platforms: #{ ovr_config . platforms_to_build } "
503
528
@log . iputs "Configuration is default: #{ ovr_config . is_default } "
504
529
arches = cpp_library . library_properties . nil? ? nil : cpp_library . library_properties . architectures
0 commit comments