Skip to content

Commit

Permalink
friendly error message when trying modal shell on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kramstrom committed Jul 12, 2024
1 parent d9eef7f commit 649ef0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modal/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ def shell(
if not console.is_terminal:
raise click.UsageError("`modal shell` can only be run from a terminal.")

if sys.platform in ("cygwin", "win32"):
# sys.platform values
# https://docs.python.org/3/library/sys.html#sys.platform
raise InvalidError("`modal shell` is currently not supported on Windows")

app = App("modal shell")

if func_ref is not None:
Expand Down
13 changes: 13 additions & 0 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,19 @@ def test_shell_cmd(servicer, set_env_client, test_dir, mock_shell_pty):
assert captured_out == [(1, shell_prompt), (1, expected_output)]


@pytest.mark.parametrize(("platform", "expected_exit_code"), [("win32", 1), ("cygwin", 1), ("linux", 0), ("darwin", 0)])
def test_shell_cmd_fails_on_windows(
servicer, set_env_client, mock_shell_pty, monkeypatch, platform, expected_exit_code
):
# sys.platform values
# https://docs.python.org/3/library/sys.html#sys.platform
monkeypatch.setattr("sys.platform", platform)
res = _run(["shell"], expected_exit_code=expected_exit_code)

if expected_exit_code != 0:
assert re.search("Windows", str(res.exception)), "exception message does not match expected string"


def test_app_descriptions(servicer, server_url_env, test_dir):
app_file = test_dir / "supports" / "app_run_tests" / "prints_desc_app.py"
_run(["run", "--detach", app_file.as_posix() + "::foo"])
Expand Down

0 comments on commit 649ef0d

Please sign in to comment.