@@ -75,170 +75,173 @@ def verified_install(backend, path)
75
75
RSpec . describe ArduinoCI ::CppLibrary do
76
76
next if skip_ruby_tests
77
77
78
- answers = {
79
- DoSomething : {
80
- one_five : false ,
81
- library_properties : true ,
82
- cpp_files : [ Pathname . new ( "DoSomething" ) + "do-something.cpp" ] ,
83
- cpp_files_libraries : [ ] ,
84
- header_dirs : [ Pathname . new ( "DoSomething" ) ] ,
85
- arduino_library_src_dirs : [ ] ,
86
- test_files : [
87
- "DoSomething/test/bad-errormessages.cpp" ,
88
- "DoSomething/test/bad-null.cpp" ,
89
- "DoSomething/test/good-assert.cpp" ,
90
- "DoSomething/test/good-library.cpp" ,
91
- "DoSomething/test/good-null.cpp" ,
92
- ] . map { |f | Pathname . new ( f ) }
93
- } ,
94
- OnePointOhDummy : {
95
- one_five : false ,
96
- library_properties : false ,
97
- cpp_files : [
98
- "OnePointOhDummy/YesBase.cpp" ,
99
- "OnePointOhDummy/utility/YesUtil.cpp" ,
100
- ] . map { |f | Pathname . new ( f ) } ,
101
- cpp_files_libraries : [ ] ,
102
- header_dirs : [
103
- "OnePointOhDummy" ,
104
- "OnePointOhDummy/utility"
105
- ] . map { |f | Pathname . new ( f ) } ,
106
- arduino_library_src_dirs : [ ] ,
107
- test_files : [
108
- "OnePointOhDummy/test/null.cpp" ,
109
- ] . map { |f | Pathname . new ( f ) }
110
- } ,
111
- OnePointFiveMalformed : {
112
- one_five : false ,
113
- library_properties : false ,
114
- cpp_files : [
115
- "OnePointFiveMalformed/YesBase.cpp" ,
116
- "OnePointFiveMalformed/utility/YesUtil.cpp" ,
117
- ] . map { |f | Pathname . new ( f ) } ,
118
- cpp_files_libraries : [ ] ,
119
- header_dirs : [
120
- "OnePointFiveMalformed" ,
121
- "OnePointFiveMalformed/utility"
122
- ] . map { |f | Pathname . new ( f ) } ,
123
- arduino_library_src_dirs : [ ] ,
124
- test_files : [ ]
125
- } ,
126
- OnePointFiveDummy : {
78
+ context "arduino-library-specification detection" do
79
+
80
+ answers = {
81
+ DoSomething : {
82
+ one_five : false ,
83
+ library_properties : true ,
84
+ cpp_files : [ Pathname . new ( "DoSomething" ) + "do-something.cpp" ] ,
85
+ cpp_files_libraries : [ ] ,
86
+ header_dirs : [ Pathname . new ( "DoSomething" ) ] ,
87
+ arduino_library_src_dirs : [ ] ,
88
+ test_files : [
89
+ "DoSomething/test/bad-errormessages.cpp" ,
90
+ "DoSomething/test/bad-null.cpp" ,
91
+ "DoSomething/test/good-assert.cpp" ,
92
+ "DoSomething/test/good-library.cpp" ,
93
+ "DoSomething/test/good-null.cpp" ,
94
+ ] . map { |f | Pathname . new ( f ) }
95
+ } ,
96
+ OnePointOhDummy : {
97
+ one_five : false ,
98
+ library_properties : false ,
99
+ cpp_files : [
100
+ "OnePointOhDummy/YesBase.cpp" ,
101
+ "OnePointOhDummy/utility/YesUtil.cpp" ,
102
+ ] . map { |f | Pathname . new ( f ) } ,
103
+ cpp_files_libraries : [ ] ,
104
+ header_dirs : [
105
+ "OnePointOhDummy" ,
106
+ "OnePointOhDummy/utility"
107
+ ] . map { |f | Pathname . new ( f ) } ,
108
+ arduino_library_src_dirs : [ ] ,
109
+ test_files : [
110
+ "OnePointOhDummy/test/null.cpp" ,
111
+ ] . map { |f | Pathname . new ( f ) }
112
+ } ,
113
+ OnePointFiveMalformed : {
114
+ one_five : false ,
115
+ library_properties : false ,
116
+ cpp_files : [
117
+ "OnePointFiveMalformed/YesBase.cpp" ,
118
+ "OnePointFiveMalformed/utility/YesUtil.cpp" ,
119
+ ] . map { |f | Pathname . new ( f ) } ,
120
+ cpp_files_libraries : [ ] ,
121
+ header_dirs : [
122
+ "OnePointFiveMalformed" ,
123
+ "OnePointFiveMalformed/utility"
124
+ ] . map { |f | Pathname . new ( f ) } ,
125
+ arduino_library_src_dirs : [ ] ,
126
+ test_files : [ ]
127
+ } ,
128
+ OnePointFiveDummy : {
129
+ one_five : true ,
130
+ library_properties : true ,
131
+ cpp_files : [
132
+ "OnePointFiveDummy/src/YesSrc.cpp" ,
133
+ "OnePointFiveDummy/src/subdir/YesSubdir.cpp" ,
134
+ ] . map { |f | Pathname . new ( f ) } ,
135
+ cpp_files_libraries : [ ] ,
136
+ header_dirs : [
137
+ "OnePointFiveDummy/src" ,
138
+ "OnePointFiveDummy/src/subdir" ,
139
+ ] . map { |f | Pathname . new ( f ) } ,
140
+ arduino_library_src_dirs : [ ] ,
141
+ test_files : [
142
+ "OnePointFiveDummy/test/null.cpp" ,
143
+ ] . map { |f | Pathname . new ( f ) }
144
+ }
145
+ }
146
+
147
+ # easier to construct this one from the other test cases
148
+ answers [ :DependOnSomething ] = {
127
149
one_five : true ,
128
150
library_properties : true ,
129
- cpp_files : [
130
- "OnePointFiveDummy/src/YesSrc.cpp" ,
131
- "OnePointFiveDummy/src/subdir/YesSubdir.cpp" ,
132
- ] . map { |f | Pathname . new ( f ) } ,
133
- cpp_files_libraries : [ ] ,
134
- header_dirs : [
135
- "OnePointFiveDummy/src" ,
136
- "OnePointFiveDummy/src/subdir" ,
137
- ] . map { |f | Pathname . new ( f ) } ,
138
- arduino_library_src_dirs : [ ] ,
151
+ cpp_files : [ "DependOnSomething/src/YesDeps.cpp" ] . map { |f | Pathname . new ( f ) } ,
152
+ cpp_files_libraries : answers [ :OnePointOhDummy ] [ :cpp_files ] + answers [ :OnePointFiveDummy ] [ :cpp_files ] ,
153
+ header_dirs : [ "DependOnSomething/src" ] . map { |f | Pathname . new ( f ) } , # this is not recursive!
154
+ arduino_library_src_dirs : answers [ :OnePointOhDummy ] [ :header_dirs ] + answers [ :OnePointFiveDummy ] [ :header_dirs ] ,
139
155
test_files : [
140
- "OnePointFiveDummy /test/null.cpp",
141
- ] . map { |f | Pathname . new ( f ) }
156
+ "DependOnSomething /test/null.cpp",
157
+ ] . map { |f | Pathname . new ( f ) }
142
158
}
143
- }
144
-
145
- # easier to construct this one from the other test cases
146
- answers [ :DependOnSomething ] = {
147
- one_five : true ,
148
- library_properties : true ,
149
- cpp_files : [ "DependOnSomething/src/YesDeps.cpp" ] . map { |f | Pathname . new ( f ) } ,
150
- cpp_files_libraries : answers [ :OnePointOhDummy ] [ :cpp_files ] + answers [ :OnePointFiveDummy ] [ :cpp_files ] ,
151
- header_dirs : [ "DependOnSomething/src" ] . map { |f | Pathname . new ( f ) } , # this is not recursive!
152
- arduino_library_src_dirs : answers [ :OnePointOhDummy ] [ :header_dirs ] + answers [ :OnePointFiveDummy ] [ :header_dirs ] ,
153
- test_files : [
154
- "DependOnSomething/test/null.cpp" ,
155
- ] . map { |f | Pathname . new ( f ) }
156
- }
157
159
158
- answers . freeze
160
+ answers . freeze
159
161
160
- answers . each do |sampleproject , expected |
162
+ answers . each do |sampleproject , expected |
161
163
162
- # we will need to install some dummy libraries into a fake location, so do that on demand
163
- fld = FakeLibDir . new
164
- backend = fld . backend
164
+ # we will need to install some dummy libraries into a fake location, so do that on demand
165
+ fld = FakeLibDir . new
166
+ backend = fld . backend
165
167
166
- context "#{ sampleproject } " do
167
- cpp_lib_path = sampleproj_path + sampleproject . to_s
168
- around ( :example ) { |example | fld . in_pristine_fake_libraries_dir ( example ) }
169
- before ( :each ) do
170
- @base_dir = fld . libraries_dir
171
- @cpp_library = verified_install ( backend , cpp_lib_path )
172
- end
168
+ context "#{ sampleproject } " do
169
+ cpp_lib_path = sampleproj_path + sampleproject . to_s
170
+ around ( :example ) { |example | fld . in_pristine_fake_libraries_dir ( example ) }
171
+ before ( :each ) do
172
+ @base_dir = fld . libraries_dir
173
+ @cpp_library = verified_install ( backend , cpp_lib_path )
174
+ end
173
175
174
- it "is a sane test env" do
175
- expect ( sampleproject . to_s ) . to eq ( @cpp_library . name )
176
- end
176
+ it "is a sane test env" do
177
+ expect ( sampleproject . to_s ) . to eq ( @cpp_library . name )
178
+ end
177
179
178
- it "detects 1.5 format" do
179
- expect ( @cpp_library . one_point_five? ) . to eq ( expected [ :one_five ] )
180
- end
180
+ it "detects 1.5 format" do
181
+ expect ( @cpp_library . one_point_five? ) . to eq ( expected [ :one_five ] )
182
+ end
181
183
182
- it "detects library.properties" do
183
- expect ( @cpp_library . library_properties? ) . to eq ( expected [ :library_properties ] )
184
- end
184
+ it "detects library.properties" do
185
+ expect ( @cpp_library . library_properties? ) . to eq ( expected [ :library_properties ] )
186
+ end
185
187
186
188
187
- context "cpp_files" do
188
- it "finds cpp files in directory" do
189
- relative_paths = @cpp_library . cpp_files . map { |f | f . relative_path_from ( @base_dir ) }
190
- expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :cpp_files ] . map ( &:to_s ) )
189
+ context "cpp_files" do
190
+ it "finds cpp files in directory" do
191
+ relative_paths = @cpp_library . cpp_files . map { |f | f . relative_path_from ( @base_dir ) }
192
+ expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :cpp_files ] . map ( &:to_s ) )
193
+ end
191
194
end
192
- end
193
195
194
- context "cpp_files_libraries" do
195
- it "finds cpp files in directories of dependencies" do
196
- @cpp_library . all_arduino_library_dependencies! # side effect: installs them
197
- dependencies = @cpp_library . arduino_library_dependencies . nil? ? [ ] : @cpp_library . arduino_library_dependencies
198
- dependencies . each { |d | verified_install ( backend , sampleproj_path + d ) }
199
- relative_paths = @cpp_library . cpp_files_libraries ( dependencies ) . map { |f | f . relative_path_from ( @base_dir ) }
200
- expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :cpp_files_libraries ] . map ( &:to_s ) )
196
+ context "cpp_files_libraries" do
197
+ it "finds cpp files in directories of dependencies" do
198
+ @cpp_library . all_arduino_library_dependencies! # side effect: installs them
199
+ dependencies = @cpp_library . arduino_library_dependencies . nil? ? [ ] : @cpp_library . arduino_library_dependencies
200
+ dependencies . each { |d | verified_install ( backend , sampleproj_path + d ) }
201
+ relative_paths = @cpp_library . cpp_files_libraries ( dependencies ) . map { |f | f . relative_path_from ( @base_dir ) }
202
+ expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :cpp_files_libraries ] . map ( &:to_s ) )
203
+ end
201
204
end
202
- end
203
205
204
- context "header_dirs" do
205
- it "finds directories containing h files" do
206
- relative_paths = @cpp_library . header_dirs . map { |f | f . relative_path_from ( @base_dir ) }
207
- expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :header_dirs ] . map ( &:to_s ) )
206
+ context "header_dirs" do
207
+ it "finds directories containing h files" do
208
+ relative_paths = @cpp_library . header_dirs . map { |f | f . relative_path_from ( @base_dir ) }
209
+ expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :header_dirs ] . map ( &:to_s ) )
210
+ end
208
211
end
209
- end
210
212
211
- context "tests_dir" do
212
- it "locates the tests directory" do
213
- # since we don't know where the CI system will install this stuff,
214
- # we need to go looking for a relative path to the SampleProjects directory
215
- # just to get our "expected" value
216
- relative_path = @cpp_library . tests_dir . relative_path_from ( @base_dir )
217
- expect ( relative_path . to_s ) . to eq ( "#{ sampleproject } /test" )
213
+ context "tests_dir" do
214
+ it "locates the tests directory" do
215
+ # since we don't know where the CI system will install this stuff,
216
+ # we need to go looking for a relative path to the SampleProjects directory
217
+ # just to get our "expected" value
218
+ relative_path = @cpp_library . tests_dir . relative_path_from ( @base_dir )
219
+ expect ( relative_path . to_s ) . to eq ( "#{ sampleproject } /test" )
220
+ end
218
221
end
219
- end
220
222
221
- context "examples_dir" do
222
- it "locates the examples directory" do
223
- relative_path = @cpp_library . examples_dir . relative_path_from ( @base_dir )
224
- expect ( relative_path . to_s ) . to eq ( "#{ sampleproject } /examples" )
223
+ context "examples_dir" do
224
+ it "locates the examples directory" do
225
+ relative_path = @cpp_library . examples_dir . relative_path_from ( @base_dir )
226
+ expect ( relative_path . to_s ) . to eq ( "#{ sampleproject } /examples" )
227
+ end
225
228
end
226
- end
227
229
228
- context "test_files" do
229
- it "finds cpp files in directory" do
230
- relative_paths = @cpp_library . test_files . map { |f | f . relative_path_from ( @base_dir ) }
231
- expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :test_files ] . map ( &:to_s ) )
230
+ context "test_files" do
231
+ it "finds cpp files in directory" do
232
+ relative_paths = @cpp_library . test_files . map { |f | f . relative_path_from ( @base_dir ) }
233
+ expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :test_files ] . map ( &:to_s ) )
234
+ end
232
235
end
233
- end
234
236
235
- context "arduino_library_src_dirs" do
236
- it "finds src dirs from dependent libraries" do
237
- # we explicitly feed in the internal dependencies
238
- dependencies = @cpp_library . arduino_library_dependencies . nil? ? [ ] : @cpp_library . arduino_library_dependencies
239
- dependencies . each { |d | verified_install ( backend , sampleproj_path + d ) }
240
- relative_paths = @cpp_library . arduino_library_src_dirs ( dependencies ) . map { |f | f . relative_path_from ( @base_dir ) }
241
- expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :arduino_library_src_dirs ] . map ( &:to_s ) )
237
+ context "arduino_library_src_dirs" do
238
+ it "finds src dirs from dependent libraries" do
239
+ # we explicitly feed in the internal dependencies
240
+ dependencies = @cpp_library . arduino_library_dependencies . nil? ? [ ] : @cpp_library . arduino_library_dependencies
241
+ dependencies . each { |d | verified_install ( backend , sampleproj_path + d ) }
242
+ relative_paths = @cpp_library . arduino_library_src_dirs ( dependencies ) . map { |f | f . relative_path_from ( @base_dir ) }
243
+ expect ( relative_paths . map ( &:to_s ) ) . to match_array ( expected [ :arduino_library_src_dirs ] . map ( &:to_s ) )
244
+ end
242
245
end
243
246
end
244
247
end
0 commit comments