Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running sinol-make from package's subdirectory #129

Merged
merged 5 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/sinol_make/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ def check_if_package():
"""
Function to check if current directory is a package
"""

cwd = os.getcwd()
if os.path.exists(os.path.join(cwd, 'config.yml')):
if os.path.exists(os.path.join(os.getcwd(), 'config.yml')):
return True
elif os.path.exists(os.path.join(os.getcwd(), '..', 'config.yml')):
os.chdir('..')
return True
return False
else:
return False


def exit_if_not_package():
Expand Down
14 changes: 14 additions & 0 deletions tests/commands/run/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,17 @@ def test_flag_tests_not_existing_tests(create_package, time_tool, capsys):
assert e.value.code == 1
out = capsys.readouterr().out
assert "There are no tests to run." in out


@pytest.mark.parametrize("create_package", [get_simple_package_path()], indirect=True)
def test_cwd_in_prog(create_package):
"""
Test if `sinol-make` works when cwd is in prog.
"""
package_path = create_package
os.chdir("prog")
create_ins_outs(package_path)
parser = configure_parsers()
args = parser.parse_args(["run"])
command = Command()
command.run(args)
Loading