feat: fix: create-project & create_component with proper file permission

This commit is contained in:
Ryan Yin
2023-07-09 02:54:42 +08:00
parent 4fc2e5cb95
commit 354e2c4673
2 changed files with 24 additions and 2 deletions

View File

@@ -237,6 +237,20 @@ def test_create_project(idf_py: IdfPyFunc, idf_copy: Path) -> None:
assert ret.returncode == 4, 'Command create-project exit value is wrong.'
def test_create_project_with_idf_readonly(idf_copy: Path) -> None:
def change_to_readonly(src: Path) -> None:
for root, dirs, files in os.walk(src):
for name in dirs:
os.chmod(os.path.join(root, name), 0o555) # read & execute
for name in files:
path = os.path.join(root, name)
if '/bin/' in path: continue # skip excutables
os.chmod(os.path.join(root, name), 0o444) # readonly
logging.info('Check that command for creating new project will success if the IDF itself is readonly.')
change_to_readonly(idf_copy)
run_idf_py('create-project', '--path', str(idf_copy / 'example_proj'), 'temp_test_project')
@pytest.mark.usefixtures('test_app_copy')
def test_docs_command(idf_py: IdfPyFunc) -> None:
logging.info('Check docs command')