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