3131size_comparison_tolerance = 0.03 # Maximum allowed archive size difference ratio
3232
3333
34- def test_sync (run_command , working_dir ):
35- working_dir_path = pathlib .Path (working_dir )
36- configuration = {
37- "BaseDownloadUrl" : "http://www.example.com/libraries/" ,
38- "LibrariesFolder" : working_dir_path .joinpath ("libraries" ).as_posix (),
39- "LogsFolder" : working_dir_path .joinpath ("logs" ).as_posix (),
40- "LibrariesDB" : working_dir_path .joinpath ("libraries_db.json" ).as_posix (),
41- "LibrariesIndex" : working_dir_path .joinpath ("libraries" , "library_index.json" ).as_posix (),
42- "GitClonesFolder" : working_dir_path .joinpath ("gitclones" ).as_posix (),
43- # I was unable to get clamdscan working in the GitHub Actions runner, but the tests should pass with this set to
44- # False when run on a machine with ClamAV installed.
45- "DoNotRunClamav" : True ,
46- # Arduino Lint should be installed under PATH
47- "ArduinoLintPath" : "" ,
48- }
49-
50- # Generate configuration file
51- with working_dir_path .joinpath ("config.json" ).open ("w" , encoding = "utf-8" ) as configuration_file :
52- json .dump (obj = configuration , fp = configuration_file , indent = 2 )
53-
34+ def test_sync (configuration , run_command ):
5435 libraries_repository_engine_command = [
5536 "sync" ,
5637 "--config-file" ,
57- working_dir_path . joinpath ( "config.json" ) ,
38+ configuration . path ,
5839 test_data_path .joinpath ("test_sync" , "repos.txt" ),
5940 ]
6041
@@ -63,38 +44,38 @@ def test_sync(run_command, working_dir):
6344 assert result .ok
6445
6546 # Test fresh output
66- check_libraries (configuration = configuration )
47+ check_libraries (configuration = configuration . data )
6748 check_logs (
68- configuration = configuration ,
49+ configuration = configuration . data ,
6950 golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "generate" ),
7051 logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "ArduinoCloudThing" , "index.html" ),
7152 )
7253 check_logs (
73- configuration = configuration ,
54+ configuration = configuration . data ,
7455 golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "generate" ),
7556 logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "SpacebrewYun" , "index.html" ),
7657 )
77- check_db (configuration = configuration )
78- check_index (configuration = configuration )
58+ check_db (configuration = configuration . data )
59+ check_index (configuration = configuration . data )
7960
8061 # Run the engine again
8162 result = run_command (cmd = libraries_repository_engine_command )
8263 assert result .ok
8364
8465 # Test the updated output
85- check_libraries (configuration = configuration )
66+ check_libraries (configuration = configuration . data )
8667 check_logs (
87- configuration = configuration ,
68+ configuration = configuration . data ,
8869 golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "update" ),
8970 logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "ArduinoCloudThing" , "index.html" ),
9071 )
9172 check_logs (
92- configuration = configuration ,
73+ configuration = configuration . data ,
9374 golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "update" ),
9475 logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "SpacebrewYun" , "index.html" ),
9576 )
96- check_db (configuration = configuration )
97- check_index (configuration = configuration )
77+ check_db (configuration = configuration . data )
78+ check_index (configuration = configuration . data )
9879
9980
10081def check_libraries (configuration ):
@@ -276,28 +257,11 @@ def check_index(configuration):
276257
277258
278259# The engine's Git code struggles to get a clean checkout of releases under some circumstances.
279- def test_clean_checkout (run_command , working_dir ):
280- working_dir_path = pathlib .Path (working_dir )
281- configuration = {
282- "BaseDownloadUrl" : "http://www.example.com/libraries/" ,
283- "LibrariesFolder" : working_dir_path .joinpath ("libraries" ).as_posix (),
284- "LogsFolder" : working_dir_path .joinpath ("logs" ).as_posix (),
285- "LibrariesDB" : working_dir_path .joinpath ("libraries_db.json" ).as_posix (),
286- "LibrariesIndex" : working_dir_path .joinpath ("libraries" , "library_index.json" ).as_posix (),
287- "GitClonesFolder" : working_dir_path .joinpath ("gitclones" ).as_posix (),
288- "DoNotRunClamav" : True ,
289- # Arduino Lint should be installed under PATH
290- "ArduinoLintPath" : "" ,
291- }
292-
293- # Generate configuration file
294- with working_dir_path .joinpath ("config.json" ).open ("w" , encoding = "utf-8" ) as configuration_file :
295- json .dump (obj = configuration , fp = configuration_file , indent = 2 )
296-
260+ def test_clean_checkout (configuration , run_command ):
297261 libraries_repository_engine_command = [
298262 "sync" ,
299263 "--config-file" ,
300- working_dir_path . joinpath ( "config.json" ) ,
264+ configuration . path ,
301265 test_data_path .joinpath ("test_clean_checkout" , "repos.txt" ),
302266 ]
303267
@@ -306,7 +270,7 @@ def test_clean_checkout(run_command, working_dir):
306270 assert result .ok
307271
308272 # Load generated index
309- with pathlib .Path (configuration ["LibrariesIndex" ]).open (mode = "r" , encoding = "utf-8" ) as library_index_file :
273+ with pathlib .Path (configuration . data ["LibrariesIndex" ]).open (mode = "r" , encoding = "utf-8" ) as library_index_file :
310274 library_index = json .load (fp = library_index_file )
311275
312276 for release in library_index ["libraries" ]:
0 commit comments