Skip to content

Commit

Permalink
fix: create-project & create_component with proper file permission
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan4yin committed Jul 9, 2023
1 parent d2471b1 commit 9b20a76
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tools/test_build_system/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import pytest
from test_build_system_helpers import (EnvDict, IdfPyFunc, append_to_file, find_python, get_snapshot, replace_in_file,
run_idf_py)
run_idf_py, get_idf_build_env)


def get_subdirs_absolute_paths(path: Path) -> List[str]:
Expand Down Expand Up @@ -237,6 +237,24 @@ 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:
logging.info('Check that command for creating new project will success if the IDF itself is readonly.')
def change_to_readonly(src):
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
change_to_readonly(idf_copy)
ret = run_idf_py(
'create-project', '--path', str(idf_copy / 'example_proj'), 'temp_test_project', check=False,
env=get_idf_build_env(idf_copy)
)
assert ret.returncode == 0, 'Command create-project exit value is wrong.'


@pytest.mark.usefixtures('test_app_copy')
def test_docs_command(idf_py: IdfPyFunc) -> None:
logging.info('Check docs command')
Expand Down

0 comments on commit 9b20a76

Please sign in to comment.