-
Notifications
You must be signed in to change notification settings - Fork 883
feat(manage_editor): add wait_for_compilation action #978
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
Open
smuhlaci
wants to merge
8
commits into
CoplayDev:beta
Choose a base branch
from
smuhlaci:issue-814-wait-for-compilation
base: beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fa3771c
feat(manage_editor): add wait_for_compilation action
smuhlaci d77ac45
docs(manage_editor): add wait_for_compilation and CLI wait-compile to…
smuhlaci 99921b3
Address code review: remove unused constant, surface server error in …
smuhlaci 16ed5d8
docs: add wait-compile to editor subcommands in CLI reference table
smuhlaci 3e5c14a
cli: pass transport timeout for editor wait-compile so long waits are…
smuhlaci a6d8384
fix(manage_editor): surface wait timeout bounds
smuhlaci 4a3c899
fix(cli): clamp wait-compile timeout before sending
smuhlaci f4f3c55
test(cli): cover wait-compile timeout clamping in failure path
smuhlaci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| import asyncio | ||
| import os | ||
| import time | ||
|
|
||
| import pytest | ||
|
|
||
| from .test_helpers import DummyContext | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_wait_for_compilation_returns_immediately_when_ready(monkeypatch): | ||
| """If compilation is already done, returns immediately with waited_seconds ~0.""" | ||
| from services.tools import manage_editor as mod | ||
| from services.tools import refresh_unity as refresh_mod | ||
|
|
||
| monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False) | ||
|
|
||
| async def fake_get_editor_state(ctx): | ||
| return {"data": {"advice": {"ready_for_tools": True, "blocking_reasons": []}}} | ||
|
|
||
| monkeypatch.setattr(refresh_mod.editor_state, "get_editor_state", fake_get_editor_state) | ||
|
|
||
| ctx = DummyContext() | ||
| result = await mod._wait_for_compilation(ctx, timeout=10) | ||
| assert result["success"] is True | ||
| assert result["data"]["ready"] is True | ||
| assert result["data"]["waited_seconds"] < 2.0 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_wait_for_compilation_polls_until_ready(monkeypatch): | ||
| """Waits while compiling, returns success when compilation finishes.""" | ||
| from services.tools import manage_editor as mod | ||
| from services.tools import refresh_unity as refresh_mod | ||
|
|
||
| monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False) | ||
|
|
||
| call_count = 0 | ||
|
|
||
| async def fake_get_editor_state(ctx): | ||
| nonlocal call_count | ||
| call_count += 1 | ||
| if call_count < 3: | ||
| return {"data": {"advice": {"ready_for_tools": False, "blocking_reasons": ["compiling"]}}} | ||
| return {"data": {"advice": {"ready_for_tools": True, "blocking_reasons": []}}} | ||
|
|
||
| monkeypatch.setattr(refresh_mod.editor_state, "get_editor_state", fake_get_editor_state) | ||
|
|
||
| ctx = DummyContext() | ||
| result = await mod._wait_for_compilation(ctx, timeout=10) | ||
| assert result["success"] is True | ||
| assert result["data"]["ready"] is True | ||
| assert call_count >= 3 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_wait_for_compilation_timeout(monkeypatch): | ||
| """Returns failure when compilation doesn't finish within timeout.""" | ||
| from services.tools import manage_editor as mod | ||
| from services.tools import refresh_unity as refresh_mod | ||
|
|
||
| monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False) | ||
|
|
||
| async def fake_get_editor_state(ctx): | ||
| return {"data": {"advice": {"ready_for_tools": False, "blocking_reasons": ["compiling"]}}} | ||
|
|
||
| monkeypatch.setattr(refresh_mod.editor_state, "get_editor_state", fake_get_editor_state) | ||
|
|
||
| ctx = DummyContext() | ||
| result = await mod._wait_for_compilation(ctx, timeout=1) | ||
| assert result["success"] is False | ||
| assert result["data"]["ready"] is False | ||
| assert result["data"]["timeout_seconds"] == 1.0 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_wait_for_compilation_default_timeout(monkeypatch): | ||
| """None timeout defaults to 30s (clamped).""" | ||
| from services.tools import manage_editor as mod | ||
| from services.tools import refresh_unity as refresh_mod | ||
|
|
||
| monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False) | ||
|
|
||
| async def fake_get_editor_state(ctx): | ||
| return {"data": {"advice": {"ready_for_tools": True, "blocking_reasons": []}}} | ||
|
|
||
| monkeypatch.setattr(refresh_mod.editor_state, "get_editor_state", fake_get_editor_state) | ||
|
|
||
| ctx = DummyContext() | ||
| result = await mod._wait_for_compilation(ctx, timeout=None) | ||
| assert result["success"] is True | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_wait_for_compilation_via_manage_editor(monkeypatch): | ||
| """The action is routed correctly through the main manage_editor function.""" | ||
| from services.tools import manage_editor as mod | ||
| from services.tools import refresh_unity as refresh_mod | ||
|
|
||
| monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False) | ||
|
|
||
| async def fake_get_editor_state(ctx): | ||
| return {"data": {"advice": {"ready_for_tools": True, "blocking_reasons": []}}} | ||
|
|
||
| monkeypatch.setattr(refresh_mod.editor_state, "get_editor_state", fake_get_editor_state) | ||
|
|
||
| ctx = DummyContext() | ||
| result = await mod.manage_editor(ctx, action="wait_for_compilation", timeout=5) | ||
| assert result["success"] is True | ||
| assert result["data"]["ready"] is True | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_wait_for_compilation_domain_reload(monkeypatch): | ||
| """Waits through domain_reload blocking reason too.""" | ||
| from services.tools import manage_editor as mod | ||
| from services.tools import refresh_unity as refresh_mod | ||
|
|
||
| monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False) | ||
|
|
||
| call_count = 0 | ||
|
|
||
| async def fake_get_editor_state(ctx): | ||
| nonlocal call_count | ||
| call_count += 1 | ||
| if call_count == 1: | ||
| return {"data": {"advice": {"ready_for_tools": False, "blocking_reasons": ["compiling"]}}} | ||
| if call_count == 2: | ||
| return {"data": {"advice": {"ready_for_tools": False, "blocking_reasons": ["domain_reload"]}}} | ||
| return {"data": {"advice": {"ready_for_tools": True, "blocking_reasons": []}}} | ||
|
|
||
| monkeypatch.setattr(refresh_mod.editor_state, "get_editor_state", fake_get_editor_state) | ||
|
|
||
| ctx = DummyContext() | ||
| result = await mod._wait_for_compilation(ctx, timeout=10) | ||
| assert result["success"] is True | ||
| assert call_count >= 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.