File tree Expand file tree Collapse file tree 7 files changed +46
-0
lines changed Expand file tree Collapse file tree 7 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
## [ Unreleased]
8
8
### Added
9
9
- Yaml files can have either ` .yml ` or ` .yaml ` extensions
10
+ - Yaml files support select/reject critera for paths of unit tests for targeted testing
10
11
11
12
### Changed
12
13
Original file line number Diff line number Diff line change 27
27
UNITTEST_SCHEMA = {
28
28
platforms : Array ,
29
29
libraries : Array ,
30
+ testfiles : {
31
+ select : Array ,
32
+ reject : Array ,
33
+ }
30
34
} . freeze
31
35
module ArduinoCI
32
36
@@ -223,6 +227,21 @@ def aux_libraries_for_unittest
223
227
@unittest_info [ :libraries ]
224
228
end
225
229
230
+ # Config allows select / reject (aka whitelist / blacklist) criteria. Enforce on a dir
231
+ # @param paths [Array<String>] the initial set of test files
232
+ # @return [Array<String>] files that match the select/reject criteria
233
+ def allowable_unittest_files ( paths )
234
+ return if @unittest_info [ :testfiles ] . nil?
235
+ ret = paths
236
+ unless @unittest_info [ :testfiles ] [ :select ] . nil? || @unittest_info [ :testfiles ] [ :select ] . empty?
237
+ ret = ret . select { |p | unittest_info [ :testfiles ] [ :select ] . any? { |glob | File . fnmatch ( glob , File . basename ( p ) ) } }
238
+ end
239
+ unless @unittest_info [ :testfiles ] [ :reject ] . nil?
240
+ ret = ret . reject { |p | unittest_info [ :testfiles ] [ :reject ] . any? { |glob | File . fnmatch ( glob , File . basename ( p ) ) } }
241
+ end
242
+ ret
243
+ end
244
+
226
245
# get GCC configuration for a given platform
227
246
# @param platform_name [String] The name of the platform as defined in yaml
228
247
# @return [Hash] the settings
Original file line number Diff line number Diff line change 66
66
end
67
67
end
68
68
69
+ context "allowable_unittest_files" do
70
+ cpp_lib_path = File . join ( File . dirname ( __FILE__ ) , "fake_library" )
71
+ cpp_library = ArduinoCI ::CppLibrary . new ( cpp_lib_path )
72
+
73
+ it "starts with a known set of files" do
74
+ expect ( cpp_library . test_files . map { |f | File . basename ( f ) } ) . to match_array ( [
75
+ "sam-squamsh.cpp" ,
76
+ "yes-good.cpp" ,
77
+ "mars.cpp"
78
+ ] )
79
+ end
80
+
81
+ it "filters that set of files" do
82
+ override_file = File . join ( File . dirname ( __FILE__ ) , "yaml" , "o1.yaml" )
83
+ combined_config = ArduinoCI ::CIConfig . default . with_override ( override_file )
84
+ expect ( combined_config . allowable_unittest_files ( cpp_library . test_files ) . map { |f | File . basename ( f ) } ) . to match_array ( [
85
+ "yes-good.cpp" ,
86
+ ] )
87
+ end
88
+ end
89
+
69
90
end
70
91
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ compile:
32
32
- esp8266
33
33
34
34
unittest :
35
+ testfiles :
36
+ select :
37
+ - " *-*.*"
38
+ reject :
39
+ - " sam-squamsh.*"
35
40
libraries :
36
41
- " abc123"
37
42
- " def456"
You can’t perform that action at this time.
0 commit comments