@@ -58,7 +58,7 @@ def test_all(run_command, working_dir):
58
58
59
59
libraries_repository_engine_command = [
60
60
working_dir_path .joinpath ("config.json" ),
61
- test_data_path .joinpath ("repos.txt" ),
61
+ test_data_path .joinpath ("test_all" , " repos.txt" ),
62
62
]
63
63
64
64
# Run the engine
@@ -69,12 +69,12 @@ def test_all(run_command, working_dir):
69
69
check_libraries (configuration = configuration )
70
70
check_logs (
71
71
configuration = configuration ,
72
- golden_logs_parent_path = test_data_path .joinpath ("golden" , "logs" , "generate" ),
72
+ golden_logs_parent_path = test_data_path .joinpath ("test_all" , " golden" , "logs" , "generate" ),
73
73
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "ArduinoCloudThing" , "index.html" ),
74
74
)
75
75
check_logs (
76
76
configuration = configuration ,
77
- golden_logs_parent_path = test_data_path .joinpath ("golden" , "logs" , "generate" ),
77
+ golden_logs_parent_path = test_data_path .joinpath ("test_all" , " golden" , "logs" , "generate" ),
78
78
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "SpacebrewYun" , "index.html" ),
79
79
)
80
80
check_index (configuration = configuration )
@@ -87,12 +87,12 @@ def test_all(run_command, working_dir):
87
87
check_libraries (configuration = configuration )
88
88
check_logs (
89
89
configuration = configuration ,
90
- golden_logs_parent_path = test_data_path .joinpath ("golden" , "logs" , "update" ),
90
+ golden_logs_parent_path = test_data_path .joinpath ("test_all" , " golden" , "logs" , "update" ),
91
91
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "ArduinoCloudThing" , "index.html" ),
92
92
)
93
93
check_logs (
94
94
configuration = configuration ,
95
- golden_logs_parent_path = test_data_path .joinpath ("golden" , "logs" , "update" ),
95
+ golden_logs_parent_path = test_data_path .joinpath ("test_all" , " golden" , "logs" , "update" ),
96
96
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "SpacebrewYun" , "index.html" ),
97
97
)
98
98
check_index (configuration = configuration )
@@ -160,7 +160,9 @@ def check_index(configuration):
160
160
del release ["checksum" ]
161
161
162
162
# Load golden index
163
- golden_library_index_template = test_data_path .joinpath ("golden" , "library_index.json" ).read_text (encoding = "utf-8" )
163
+ golden_library_index_template = test_data_path .joinpath ("test_all" , "golden" , "library_index.json" ).read_text (
164
+ encoding = "utf-8"
165
+ )
164
166
# Fill in mutable content
165
167
golden_library_index_string = string .Template (template = golden_library_index_template ).substitute (
166
168
base_download_url = configuration ["BaseDownloadUrl" ]
@@ -173,6 +175,43 @@ def check_index(configuration):
173
175
assert release in golden_library_index ["libraries" ]
174
176
175
177
178
+ # The engine's Git code struggles to get a clean checkout of releases under some circumstances.
179
+ def test_clean_checkout (run_command , working_dir ):
180
+ working_dir_path = pathlib .Path (working_dir )
181
+ configuration = {
182
+ "BaseDownloadUrl" : "http://www.example.com/libraries/" ,
183
+ "LibrariesFolder" : working_dir_path .joinpath ("libraries" ).as_posix (),
184
+ "LogsFolder" : working_dir_path .joinpath ("logs" ).as_posix (),
185
+ "LibrariesDB" : working_dir_path .joinpath ("libraries_db.json" ).as_posix (),
186
+ "LibrariesIndex" : working_dir_path .joinpath ("libraries" , "library_index.json" ).as_posix (),
187
+ "GitClonesFolder" : working_dir_path .joinpath ("gitclones" ).as_posix (),
188
+ "DoNotRunClamav" : True ,
189
+ # Arduino Lint should be installed under PATH
190
+ "ArduinoLintPath" : "" ,
191
+ }
192
+
193
+ # Generate configuration file
194
+ with working_dir_path .joinpath ("config.json" ).open ("w" , encoding = "utf-8" ) as configuration_file :
195
+ json .dump (obj = configuration , fp = configuration_file , indent = 2 )
196
+
197
+ libraries_repository_engine_command = [
198
+ working_dir_path .joinpath ("config.json" ),
199
+ test_data_path .joinpath ("test_clean_checkout" , "repos.txt" ),
200
+ ]
201
+
202
+ # Run the engine
203
+ result = run_command (cmd = libraries_repository_engine_command )
204
+ assert result .ok
205
+
206
+ # Load generated index
207
+ with pathlib .Path (configuration ["LibrariesIndex" ]).open (mode = "r" , encoding = "utf-8" ) as library_index_file :
208
+ library_index = json .load (fp = library_index_file )
209
+
210
+ for release in library_index ["libraries" ]:
211
+ # ssd1306@1.0.0 contains a .exe and so should fail validation.
212
+ assert not (release ["name" ] == "ssd1306" and release ["version" ] == "1.0.0" )
213
+
214
+
176
215
@pytest .fixture (scope = "function" )
177
216
def run_command (pytestconfig , working_dir ) -> typing .Callable [..., invoke .runners .Result ]:
178
217
"""Provide a wrapper around invoke's `run` API so that every test will work in the same temporary folder.
0 commit comments