<s> from glob import glob <EOL> from os import listdir , walk <EOL> from os . path import dirname , getsize , isdir , isfile , join , normpath <EOL> from shutil import rmtree <EOL> import pytest <EOL> from platformio . util import exec_command <EOL> def pytest_generate_tests ( metafunc ) : <EOL> if "<STR_LIT>" not in metafunc . fixturenames : <EOL> return <EOL> example_dirs = normpath ( join ( dirname ( __file__ ) , "<STR_LIT:..>" , "<STR_LIT>" ) ) <EOL> project_dirs = [ ] <EOL> for root , _ , files in walk ( example_dirs ) : <EOL> if "<STR_LIT>" not in files or "<STR_LIT>" in files : <EOL> continue <EOL> project_dirs . append ( root ) <EOL> project_dirs . sort ( ) <EOL> metafunc . parametrize ( "<STR_LIT>" , project_dirs ) <EOL> @ pytest . mark . examples <EOL> def test_run ( platformio_setup , pioproject_dir ) : <EOL> if isdir ( join ( pioproject_dir , "<STR_LIT>" ) ) : <EOL> rmtree ( join ( pioproject_dir , "<STR_LIT>" ) ) <EOL> result = exec_command ( <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , pioproject_dir ] <EOL> ) <EOL> if result [ '<STR_LIT>' ] != <NUM_LIT:0> : <EOL> pytest . fail ( result ) <EOL> pioenvs_dir = join ( pioproject_dir , "<STR_LIT>" ) <EOL> for item in listdir ( pioenvs_dir ) : <EOL> if not isdir ( item ) : <EOL> continue <EOL> assert isfile ( join ( pioenvs_dir , item , "<STR_LIT>" ) ) <EOL> firmwares = [ ] <EOL> for ext in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> firmwares += glob ( join ( pioenvs_dir , item , "<STR_LIT>" % ext ) ) <EOL> if not firmwares : <EOL> pytest . fail ( "<STR_LIT>" ) <EOL> for firmware in firmwares : <EOL> assert getsize ( firmware ) > <NUM_LIT:0> </s>
